Download presentation
Presentation is loading. Please wait.
Published byJeffry Stafford Modified over 9 years ago
1
Computer Science CPSC 502 Lecture 6 Finish Planning Start Logic (Ch 5)
2
Lecture Overview Finish Planning Logics Propositional, Definite Clause Logic: Syntax and Semantics Two different proof Procedures Reasoning with individuals and relations 2
3
Where Are We? Environment Problem Type Query Planning Deterministic Stochastic Constraint Satisfaction Search Arc Consistency Search Logics STRIPS Vars + Constraints Value Iteration Variable Elimination Belief Nets Decision Nets Markov Processes Static Sequential Representation Reasoning Technique Variable Elimination First Part of the Course
4
Where Are We? Environment Problem Type Query Planning Deterministic Stochastic Constraint Satisfaction Search Arc Consistency Search Logics STRIPS Vars + Constraints Value Iteration Variable Elimination Belief Nets Decision Nets Markov Processes Static Sequential Representation Reasoning Technique Variable Elimination Back to static problems, but with richer representation
5
5 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
6
6 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 Configuration Ontologies Semantic Web Information Extraction Summarization Production Systems Tutoring Systems Software Verification You will know You will know a little Applications Satisfiability Testing (SAT)
7
7 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 System that can be used to formalize a domain and to reason about it
8
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)http://en.wikipedia.org/wiki/John_McCarthy Logic and AI “The Advice Taker” Coined “Artificial Intelligence”. Dartmouth W’shop (1956) 8
9
9 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
10
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 Logic 1.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 ontologyChoose 4.Tell the system knowledge about the domainTell 5.Ask the system whether new statements about the domain are true or false live_w 4 ? lit_l 2 ?
11
Example: Electrical Circuit / up /down
12
/ up /down Sintax: are these sentences that a reasoning procedure can process? Sematic: what do these statements say about the world I need to represent?
13
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
14
Propositional Definite Clauses We 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
15
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 b 1 ∧ b 2 where b 1 and b 2 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: p 1 ; live_l 1 Examples: p 1 ∧ p 2 ; ok_w 1 ∧ live_w 0 Examples: p 1 ← p 2 ; live_w 0 ← live_w 1 ∧ up_s 2
16
atoms rules definite clauses, KB Do any of these statements mean anything? Syntax doesn't answer this question!
17
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 Which of the following are legal PDC clause? 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.’)
18
PDC Syntax: more examples a)ai_is_fun YES b)ai_is_fun ∨ ai_is_boring NO c)ai_is_fun ← learn_useful_techniques YES d)ai_is_fun ← learn_useful_techniques ∧ notTooMuch_work YES e)ai_is_fun ← learn_useful_techniques ∧ TooMuch_work NO f)ai_is_fun ← f(time_spent, material_learned) NO g)srtsyj ← errt ∧ gffdgdgd NO Which of the following are legal PDC clause? 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.’)
19
Propositional Definite Clauses: Semantics Semantics allows you to relate the symbols in the logic to the domain you're trying to model. If our domain has 5 atoms, how many interpretations are there? ……. values for each atom, so ……. combinations Similar to possible worlds in CSPs Definition (interpretation) An interpretation I assigns a truth value to each atom.
20
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 b 1 ∧ b 2 is true in I if and only if b 1 is true in I and b 2 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.
21
hbh ← bh ← b I1I1 FFT I2I2 FTF I3I3 TFT I4I4 TTT PDC Semantics: Example a1a1 a2a2 a1 ∧ a2a1 ∧ a2 I1I1 FFF I2I2 FTF I3I3 TFF I4I4 TTT Truth values under different interpretations F=false, T=true
22
hbh ← bh ← b I1I1 FFT I2I2 FTF I3I3 TFT I4I4 TTT PDC Semantics: Example 22 Truth values under different interpretations F=false, T=true h ← b is only false if b is true and h is false ha1a1 a2a2 h ← a1 ∧ a2h ← a1 ∧ a2 I1I1 FFF I2I2 FFT I3I3 FTF I4I4 FTT I5I5 TFF I6I6 TFT I7I7 TTF I8I8 TTT
23
hbh ← bh ← b I1I1 FFT I2I2 FTF I3I3 TFT I4I4 TTT PDC Semantics: Example for truth values Truth values under different interpretations F=false, T=true h ← a 1 ∧ a 2 Body of the clause: a 1 ∧ a 2 Body is only true if both a 1 and a 2 are true in I ha1a1 a2a2 h ← a1 ∧ a2h ← a1 ∧ a2 I1I1 FFFT I2I2 FFTT I3I3 FTFT I4I4 FTTF I5I5 TFFT I6I6 TFTT I7I7 TTFT I8I8 TTTT
24
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 b 1 ∧ b 2 is true in I if and only if b 1 is true in I and b 2 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.
25
Propositional Definite Clauses: Semantics 25 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 b 1 ∧ b 2 is true in I if and only if b 1 is true in I and b 2 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.
26
PDC Semantics: Knowledge Base (KB) pqrs I1I1 true false p r s ← q ∧ p p q s ← q p q ← r ∧ s KB 1 KB 2 KB 3 Which of the three KB above are True in I 1 A knowledge base KB is true in I if and only if every clause in KB is true in I.
27
Slide 27 PDC Semantics: Knowledge Base (KB) pqrs I1I1 true false p r s ← q ∧ p p q s ← q p q ← r ∧ s KB 1 KB 2 KB 3 Which of the three KB above are True in I 1 ?KB 3 A knowledge base KB is true in I if and only if every clause in KB is true in I.
28
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. pqrs I1I1 TTTT I2I2 FFFF I3I3 TTFF I4I4 TTTF I5I5 FTFT Which of the interpretations below are models of KB?
29
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. pqrs I1I1 TTTT I2I2 FFFF I3I3 TTFF I4I4 TTTF I5I5 FTFT Which of the interpretations below are models of KB? √ √ √
30
PDC Semantics: Example for models pqrs p ← q q r ← s KB I1I1 TTTTTTTT I2I2 FFFFTFTF I3I3 TTFFTTTT I4I4 TTTFTTTT I5I5 FTFTFTFF 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: I 1, I 3, and I 4
31
Slide 31 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
32
Slide 32 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?
33
Or, More Interestingly 1) Tell the system knowledge about a task domain. 2) Ask the system whether new statements about the domain are true or false live_w 4 ? lit_l 2 ?
34
Slide 34 To Obtain This We Need One More Definition Definition (logical consequence) If KB is a set of clauses and G is a conjunction of atoms, G is a logical consequence of KB, written KB ⊧ G, if G is true in every model of KB. we also say that G logically follows from KB, or that KB entails G. In other words, KB ⊧ G if there is no interpretation in which KB is true and G is false. when KB is TRUE, then G must be TRUE We want a reasoning procedure that can find all and only the logical consequences of a knowledge base
35
Example: Logical Consequences pqrs I1I1 true I2I2 false I3I3 true false I4I4 true falsetrue I5I5 falsetrue I6I6 falsetrue false I7I7 truefalse I8I8 truefalsetrue I9I9 falsetrue I 10 truefalsetruefalse I 11 truefalse I 12 truefalse …..………..…………. Which of the following is true? KB ⊧ q, KB ⊧ p, KB ⊧ s, KB ⊧ r
36
Example: Logical Consequences pqrs I1I1 true I2I2 false I3I3 true false I4I4 true falsetrue I5I5 falsetrue I6I6 falsetrue false I7I7 truefalse I8I8 truefalsetrue I9I9 falsetrue I 10 truefalsetruefalse I 11 truefalse I 12 truefalse …..………..…………. Which of the following is true? KB ⊧ q, KB ⊧ p, KB ⊧ s, KB ⊧ r T T F F
37
Proof Procedure We want a reasoning procedure (proof procedure) that can find all and only the logical consequences of a knowledge base Why?
38
User’s View of Semantics 1.Choose a task domain: intended interpretation. 2.Associate an atom with each proposition you want to represent. 3.Tell the system clauses that are true in the intended interpretation: axiomatizing the domain. 4.Ask questions about the intended interpretation. If KB ⊧ g, then g must be true in all models, so it is true in the intended interpretation (which is a model). The user can interpret the answer using their intended interpretation of the symbols.
39
Computer’s view of semantics The computer doesn’t have access to the intended interpretation. All it knows is the knowledge base. The computer can determine if a formula is a logical consequence of KB. If KB ⊧ g then g must be true in the intended interpretation. Otherwise, there is a model of KB in which g is false. This could be the intended interpretation. The computer wouldn't know!
40
Proof Procedures A proof procedure is a mechanically derivable demonstration that a formula logically follows from a knowledge base. Given a proof procedure P, KB ⊦ P g means g can be derived from knowledge base KB with the proof procedure. If I tell you I have a proof procedure for PDCL What do I need to show you in order for you to trust my procedure? That is sound and complete
41
Soundness and Completeness Completeness of proof procedure P: need to prove that If g is true in all models of KB (KB ⊧ g) then g is derived by the procedure (KB ⊦ P g) Definition (completeness) A proof procedure P is complete if KB ⊧ g implies KB ⊦ P g. complete: every atom that logically follows from KB is derived by P Soundness of proof procedure P: need to prove that Definition (soundness) A proof procedure P is sound if KB ⊦ P g implies KB ⊧ g. If g can be derived by the procedure (KB ⊦ P g) then g is true in all models of KB (KB ⊧ g) sound: every atom derived by P follows logically from KB (i.e. is true in every model)
42
Simple Proof Procedure problem with this approach? If there are n propositions in the KB, must check all the interpretations! Goal of proof theory find sound and complete proof procedures that allow us to prove that a logical formula follows from a KB avoiding to do the above Simple proof procedure S Enumerate all interpretations For each interpretation I, check whether it is a model of KB i.e., check whether all clauses in KB are true in I KB ⊦ S g if g holds in all such models
43
Lecture Overview Finish Planning Logics Propositional, Definite Clause Logic: Syntax and Semantics Two different proof Procedures Reasoning with individuals and relations 43
44
Bottom-up proof procedure One rule of derivation, a generalized form of modus ponens: If “h ← b 1 … b m " is a clause in the knowledge base, and each b i has been derived, then h can be derived. This rule also covers the case when m = 0.
45
Bottom-up proof procedure C :={}; repeat select clause “h ← b 1 ∧ … ∧ b m ” in KB such that b i ∈ C for all i, and h ∉ C; C := C ∪ { h } until no more clauses can be selected. KB ⊦ G if G ⊆ C at the end of this procedure
46
C := {}; repeat select clause h ← b 1 … b m in KB such that b i C for all i, and h C; C := C {h} until no more clauses can be selected. Bottom-up proof procedure: example a ← b c a ← e f b ← f k c ← e d ← k e. f ← j e f ← c j ← c {}
47
C := {}; repeat select clause h ← b 1 … b m in KB such that b i C for all i, and h C; C := C {h} until no more clauses can be selected. Bottom-up proof procedure: example a ← b c a ← e f b ← f k c ← e d ← k e. f ← j e f ← c j ← c {} {e} {c,e} {c,e,f} {c,e,f,j} {a,c,e,f,j} Done.
48
Lecture Overview Recap Lecture 24 Bottom-Up Proof Procedure Soundness Completeness Top-Down Proof Procedure (time permitting)
49
Soundness of bottom-up proof procedure BU What do we need to prove to show that BU is sound ? sound: every atom g that P derives follows logically from KB Definition (soundness) A proof procedure P is sound if KB ⊦ P g implies KB ⊧ g. C := {}; Repeat select clause h ← b 1 … b m in KB such that b i C for all i, and h C; C := C {h} until no more clauses can be selected.
50
Soundness of bottom-up proof procedure BU What do we need to prove to show that BU is sound ? If g C at the end of BU procedure, then g is true in all models of KB (KB ⊧ g) sound: every atom g that P derives follows logically from KB Definition (soundness) A proof procedure P is sound if KB ⊦ P g implies KB ⊧ g. C := {}; repeat select clause h ← b 1 … b m in KB such that b i C for all i, and h C; C := C {h} until no more clauses can be selected.
51
Soundness of bottom-up proof procedure BU By contradiction: Suppose there is a g such that KB ⊦ g but not KB ⊧ g. If g C at the end of BU procedure, then g is true in all models of KB (KB ⊧ g) What do we need to prove to show that BU is sound ? Let h be the first atom added to C that is not true in every model of KB. In particular, suppose I is a model of KB in which h isn’t true There must be a clause in KB of form h b 1 ... b n where each b i is true in I. Because h is false in I, this clause is false in I. Therefore I is not a model of KB => Contradiction
52
We define a specific model of our KB, in which every atom in C at the end of BU is true every other atom is false This is called minimal model Using this model, we’ll then show that, if KB ⊧ G, then G must be in C, that is Completeness of BU: general idea If g is true in all models of KB (KB ⊧ g) then g C at the end of BU procedure (KB ⊦ BU g)
53
Minimal Model The C at the end of BU procedure is a fixed point: Further applications of our rule of derivation will not change C! Definition (minimal model) The minimal model MM is the interpretation in which – -every element of BU’s fixed point C is true -every other atom is false. C := {}; repeat select clause h ← b 1 … b m in KB such that b i C for all i, and h C; C := C {h} until no more clauses can be selected.
54
Minimal model MM is a model of KB Proof by contradiction. Assume that MM is not a model of KB. Then there must exist some clause in KB which is false in MM Like every clause in KB, it is of the form h ← b 1 … b m (with m 0). h ← b 1 … b m can only be false in MM if each b i is true in MM and h is false in MM. Since each b i is true in MM, each b i must be in C as well. BU would add h to C, so h would be true in MM Contradiction! Thus, MM is a model of KB Definition (minimal model) The minimal model MM is the interpretation in which -every element of BU’s fixed point C is true -every other atom is false.
55
Completeness of bottom-up procedure Direct proof based on minimal model: Suppose KB ⊧ g. Then g is true in all models of KB. Thus g is true in the minimal model. Thus g C at the end of BU procedure. Thus KB ⊦ BU g. Done. KB ⊧ g implies KB ⊦ BU g If g is true in all models of KB (KB ⊧ g) then g C at the end of BU procedure (KB ⊦ BU g)
56
Summary for bottom-up proof procedure BU BU is sound: it derives only atoms that logically follow from KB BU is complete: it derives all atoms that logically follow from KB Together: it derives exactly the atoms that logically follow from KB And, it is efficient! Linear in the number of clauses in KB Each clause is used maximally once by BU
57
Bottom-up vs. Top-down KB g is proved if g C When does BU look at the query? g Bottom-up C
58
Bottom-up vs. Top-down Key Idea of top-down: search backward from a query g to determine if it can be derived from KB. KB C g is proven if g C When does BU look at the query g? Never It derives the same C regardless of the query Bottom-up Top-down TD performs a backward search starting at g KB answer Query G
59
Idea: search backward from a query to determine if it is a logical consequence of KB. An answer clause is of the form yes a 1 ... a i-1 a i a i+1 … a m We express a query q 1 ∧ q 2 … ∧ q m as an answer clause yes ← q 1 … q k Basic operation: SLD Resolution of an answer clause yes a 1 ... a i-1 a i a i+1 … a m on atom a i with the clause: a i b 1 ... b p yields the clause yes a 1 ... a i-1 b 1 ... b p a i+1... a m Top-down Proof Procedure for PDCL
60
Rule of derivation: the SLD Resolution of clause yes a 1 ... a i-1 a i a i+1 … a m on atom a i with the clause: a i b 1 ... b p is the answer clause yes a 1 ... a i-1 b 1 ... b p a i+1... a m Example yes ← b ∧ c. b ← k ∧ f. yes← yes ← e ∧ f. e. yes ← SLD resolution
61
Rule of derivation: the SLD Resolution of clause yes a 1 ... a i-1 a i a i+1 … a m on atom a i with the clause: a i b 1 ... b p is the answer clause yes a 1 ... a i-1 b 1 ... b p a i+1... a m Example yes ← b ∧ c. b ← k ∧ f. yes← k ∧ f ∧ c yes ← e ∧ f. e. yes ← f SLD resolution
62
Rules of derivation in top-down and bottom-up Top-down: SLD Resolution yes ← c 1 c i … c m c i ← b 1 … b p yes ← c 1 … c i-1 b 1 … b p c i+1 … c m Bottom-up: Generalized modus ponens h ← b 1 … b m b 1 … b m h
63
Derivations An answer is an answer clause with m = 0. yes . A successful derivation from KB of query ? q 1 ... q k is a sequence of answer clauses 0, 1,.., n such that 0 is the answer clause yes q 1 ... q k. i is obtained by resolving i-1 with a clause in KB, and n is an answer. yes . An unsuccessful derivation from KB of query ? q 1 ... q k We get to something like yes b 1 ... b k. There is no clause in KB with any of the b i as its head
64
To solve the query ? q 1 ... q k : ac:= yes body, where body is q 1 ... q k repeat select q i body; choose clause C KB, C is q i b c ; replace q i in body by b c until ac is an answer (fail if no clause with q i as head) select: any choice will work (“don’t care” non-determinism) choose: non-deterministic, have to pick the right one (“don’t know” non-determinism) Top-down Proof Procedure for PDCL
65
4 : yes e 3 : yes c 1 : yes e f 5 : yes Example: successful derivation 0 : yes a 2 : yes e c 1 2 4 3 5 a b c.a e f.b f k. c e.d k e. f j e. f c. j c. Query: ?a Done. The question was “Can we derive a?” The answer is “Yes, we can”
66
a b c.a e f.b f k. c e.d k e. f j e. f c. j c. Query: ?a Example: failing derivation 4 : yes e k c 3 : yes c k c 1 : yes b c 5 : yes k c 0 : yes a 2 : yes f k c 6 : yes k e 7 : yes k 1 2 3 4 5 There is no rule with k as its head, thus … fail 67
67
Sound and Complete? When you have derived an answer, you can read a bottom up proof in the opposite direction. Every top-down derivation corresponds to a bottom up proof and every bottom up proof has a top-down derivation. This equivalence can be used to prove the soundness and completeness of the derivation procedure. Do it as an exercise!
68
SLD resolution as search SLD resolution can be seen as a search from a query stated as an answer clause to an answer Through the space of all possible answer clauses
69
Constraint Satisfaction (Problems): State: assignments of values to a subset of the variables Successor function: assign values to a “free” variable Goal test: set of constraints Solution: possible world that satisfies the constraints Heuristic function: none (all solutions at the same distance from start) Planning : State: full assignment of values to features Successor function: states reachable by applying valid actions Goal test: partial assignment of values to features Solution: a sequence of actions Heuristic function: relaxed problem! E.g. “ignore delete lists” Query (Top-down/SLD resolution) State: answer clause of the form yes a 1 ... a k Successor function: all states resulting from substituting first atom a 1 with b 1 … b m if there is a clause a 1 ← b 1 … b m Goal test: is the answer clause empty (i.e. yes ) ? Solution: the proof, i.e. the sequence of SLD resolutions Heuristic function: ????? Inference as Standard Search
70
Search Graph Prove: ?← a ∧ d. a ← b ∧ c. a ← g. a ← h.b ← j. b ← k. d ← m. d ← p. f ← m. f ← p. g ← m. g ← f. k ← m. h ←m. p. KB Why is this a dead end in the search space? Because m cannot be resolved. The successor function is defined as resolving the first atom in the body of the answer clause
71
Search Graph Possible Heuristic? Admissible? Prove: ?← a ∧ d. a ← b ∧ c. a ← g. a ← h.b ← j. b ← k. d ← m. d ← p. f ← m. f ← p. g ← m. g ← f. k ← m. h ←m. p. KB
72
Search Graph Possible Heuristic? Number of atoms in the answer clause Admissible? Yes Prove: ?← a ∧ d. a ← b ∧ c. a ← g. a ← h.b ← j. b ← k. d ← m. d ← p. f ← m. f ← p. g ← m. g ← f. k ← m. h ←m. p. KB
73
Lecture Overview Finish Planning Logics Propositional, Definite Clause Logic: Syntax and Semantics Two different proof Procedures Reasoning with individuals and relations 73
74
Representation and Reasoning in complex domains Expressing knowledge with propositions can be quite limiting up_s 2 up_s 3 ok_cb 1 ok_cb 2 live_w 1 connected_w 1 _w 2 up( s 2 ) up( s 3 ) ok( cb 1 ) ok( cb 2 ) live( w 1 ) connected( w 1, w 2 ) What we need is a more natural way to consider individuals and their properties E.g. there is no notion that Now there is a notion that up_s 1 and up_s 1 are about the same property w 1 is the same in live_w 1 and in connected_w 1 _w 2 w 1 is the same in live(w 1 ) and in connected(w 1, w 2 ) up is the same in up(s 1 ) and up(s 3 )
75
Datalog An extension of propositional definite clause (PDC) logic We now have variables We now have relationships between variables We can express knowledge that holds for a set of individuals, writing more powerful clauses by introducing variables, such as: We can ask generic queries, E.g. “which wires are connected to w 1 ?“ live(W) wire(W) ∧ connected_to(W,W 1 ) ∧ wire(W 1 ) ∧ live(W 1 ). ? connected_to(W, w 1 )
76
Datalog: a relational rule language A variable is a symbol starting with an upper case letter A constant is a symbol starting with lower-case letter or a sequence of digits. A predicate symbol is a symbol starting with a lower-case letter. A term is either a variable or a constant. Datalog expands the syntax of PDCL…. Examples: X, Y Examples: alan, w1 Examples: live, connected, part-of, in Examples: X, Y, alan, w1
77
Datalog Syntax (cont’d) An atom is a symbol of the form p or p(t 1 …. t n ) where p is a predicate symbol and t i are terms A definite clause is either an atom (a fact) or of the form: h ← b 1 ∧ … ∧ b m where h and the b i are atoms (Read this as ``h if b.'') A knowledge base is a set of definite clauses Examples: sunny, in(alan,X) Example: in(X,Z) ← in(X,Y) ∧ part-of(Y,Z)
78
Summary of Datalog Syntax Definite Clause atomic p p(t 1,….t n ) a <- b 1 ^…^ b n where a and b 1.. b n are atoms Datalog Expression Term Query: ?body constantvariable
79
DataLog Sematics Role of semantics is still to connect symbols and sentences in the language with the target domain. Main difference: need to create correspondence both between terms and individuals, as well as between predicate symbols and relations We won’t cover the formal definition of Datalog semantics, but if you are interested see 12.3.1 and 12.3.2 in textbook
80
Datalog: Top Down Proof Procedure Extension of Top-Down procedure for PDCL. How do we deal with variables? Idea: -Find a clause with head that matches the query -Substitute variables in the clause with their matching constants Example: We will not cover the formal details of this process, called unification. See textbook Section 12.4.2, p. 511 for the details. in(alan, r123). part_of(r123,cs_building). in(X,Y) part_of(Z,Y) & in(X,Z). Query: yes in(alan, cs_building). yes part_of(Z,cs_building), in(alan, Z). in(X,Y) part_of(Z,Y) & in(X,Z). with Y = cs_building X = alan
81
Example proof of a Datalog query in(alan, r123). part_of(r123,cs_building). in(X,Y) part_of(Z,Y) & in(X,Z). Query: yes in(alan, cs_building). yes part_of(Z,cs_building), in(alan, Z). yes in(alan, r123). yes part_of(Z, r123), in(alan, Z). yes . Using clause: in(X,Y) part_of(Z,Y) & in(X,Z), with Y = cs_building X = alan Using clause: part_of(r123,cs_building) with Z = r123 Using clause: in(alan, r123). Using clause: in(X,Y) part_of(Z,Y) & in(X,Z). With X = alan Y = r123 fail No clause with matching head: part_of(Z,r123).
82
Tracing Datalog proofs in AIspace You can trace the example from the last slide in the AIspace Deduction Applet at http://aispace.org/deduction/ using file in-part-of available in course schedule http://aispace.org/deduction/
83
Datalog: queries with variables What would the answer(s) be? Query: in(alan, X1). in(alan, r123). part_of(r123,cs_building). in(X,Y) part_of(Z,Y) & in(X,Z). yes(X1) in(alan, X1).
84
Datalog: queries with variables What would the answer(s) be? yes(r123). yes(cs_building). Query: in(alan, X1). in(alan, r123). part_of(r123,cs_building). in(X,Y) part_of(Z,Y) & in(X,Z). yes(X1) in(alan, X1). Again, you can trace the SLD derivation for this query in the AIspace Deduction Applet, using file http://cs.ubc.ca/~mack/CS322/in-part-of.pl http://cs.ubc.ca/~mack/CS322/in-part-of.pl
85
Logics: Big picture We only covered rather simple logics There are much more powerful representation and reasoning systems based on logics e.g. full first order logic (with negation, disjunction and function symbols) second-order logics (predicates over predicates) non-monotonic logics, modal logics, … There are many important applications of logic For example, software agents roaming the web on our behalf Based on a more structured representation: the semantic web This is just one example for how logics are used
86
Slide 86 Logics: Big Picture Propositional Logics First-Order Logics Propositional Definite Clause Logics Semantics and Proof Theory Satisfiability Testing Satisfiability Testing (SAT) Description Logics Cognitive Architectures Video Games Hardware Verification Product Configuration Ontologies Semantic Web Information Extraction Summarization Production Systems Tutoring Systems
87
Learning Goals For Logic PDCL syntax & semantics - Verify whether a logical statement belongs to the language of propositional definite clauses - Verify whether an interpretation is a model of a PDCL KB. - Verify when a conjunction of atoms is a logical consequence of a KB Bottom-up proof procedure - Define/read/write/trace/debug the Bottom Up (BU) proof procedure - Prove that the BU proof procedure is sound and complete Top-down proof procedure - Define/read/write/trace/debug the Top-down (SLD) proof procedure - Define it as a search problem Datalog - Represent simple domains in Datalog - Apply the Top-down proof procedure in Datalog
88
Semantic Web: Extracting data Examples for typical queries How much is a typical flight to Mexico for a given date? What’s the cheapest vacation package to some place in the Caribbean in a given week? Plus, the hotel should have a white sandy beach and scuba diving If webpages are based on basic HTML Humans need to scout for the information and integrate it Computers are not reliable enough (yet?) Natural language processing (NLP) can be powerful (see Watson and Siri!) But some information may be in pictures (beach), or implicit in the text, so existing NLP techniques still don’t get all the info.
89
More structured representation: the Semantic Web Beyond HTML pages only made for humans Languages and formalisms based on description logics that allow websites to include rich, explicit information on relevant concepts, individual and their relationships \ Goal: software agents that can roam the web and carry out sophisticated tasks on our behalf, based on these richer representations Different than searching content for keywords and popularity. Infer meaning from content based on metadata and assertions that have already been made. Automatically classify and integrate information For further material, P&M text, Chapter 13. Also the Introduction to the Semantic Web tutorial given at 2011 Semantic TechnologyConference http://www.w3.org/People/Ivan/CorePresentations/SWTutorial/ http://www.w3.org/People/Ivan/CorePresentations/SWTutorial/ 89
90
Examples of ontologies for the Semantic Web “Ontology”: logic-based representation of the world eClassOwl: eBusiness ontology for products and services 75,000 classes (types of individuals) and 5,500 properties National Cancer Institute’s ontology: 58,000 classes Open Biomedical Ontologies Foundry: several ontologies including the Gene Ontology to describe gene and gene product attributes in any organism or protein sequence OpenCyc project: a 150,000-concept ontology including Top-level ontology describes general concepts such as numbers, time, space, etc Hierarchical composition: superclasses and subclasses Many specific concepts such as “OLED display”, “iPhone”
91
A different example of applications of logic Cognitive Tutors (http://pact.cs.cmu.edu/)http://pact.cs.cmu.edu/ computer tutors for a variety of domains (math, geometry, programming, etc.) Provide individualized support to problem solving exercises, as good human tutors do Rely on logic-based, detailed computational models of skills and misconceptions underlying a learning domain. CanergieLearning (http://www.carnegielearning.com/ ): a company that commercializes these tutors, sold to hundreds of thousands of high schools in the USA
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.