Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 20

Slides:



Advertisements
Similar presentations
UIUC CS 497: Section EA Lecture #2 Reasoning in Artificial Intelligence Professor: Eyal Amir Spring Semester 2004.
Advertisements

Methods of Proof Chapter 7, second half.. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound)
Logic Use mathematical deduction to derive new knowledge.
Methods of Proof Chapter 7, Part II. Proof methods Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound) generation.
Logic.
CPSC 422, Lecture 21Slide 1 Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 21 Mar, 4, 2015 Slide credit: some slides adapted from Stuart.
CPSC 322, Lecture 23Slide 1 Logic: TD as search, Datalog (variables) Computer Science cpsc322, Lecture 23 (Textbook Chpt 5.2 & some basic concepts from.
CPSC 322, Lecture 19Slide 1 Propositional Logic Intro, Syntax Computer Science cpsc322, Lecture 19 (Textbook Chpt ) February, 23, 2009.
Outline Recap Knowledge Representation I Textbook: Chapters 6, 7, 9 and 10.
Proof methods Proof methods divide into (roughly) two kinds: –Application of inference rules Legitimate (sound) generation of new sentences from old Proof.
Logic in general Logics are formal languages for representing information such that conclusions can be drawn Syntax defines the sentences in the language.
CPSC 322, Lecture 20Slide 1 Propositional Definite Clause Logic: Syntax, Semantics and Bottom-up Proofs Computer Science cpsc322, Lecture 20 (Textbook.
CPSC 322, Lecture 23Slide 1 Logic: TD as search, Datalog (variables) Computer Science cpsc322, Lecture 23 (Textbook Chpt 5.2 & some basic concepts from.
Knowledge Representation I (Propositional Logic) CSE 473.
Logical Agents Chapter 7.
Methods of Proof Chapter 7, second half.
Knoweldge Representation & Reasoning
CPSC 422, Lecture 14Slide 1 Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 14 Feb, 4, 2015 Slide credit: some slides adapted from Stuart.
Logical Agents Chapter 7 (based on slides from Stuart Russell and Hwee Tou Ng)
Logical Agents. Knowledge bases Knowledge base = set of sentences in a formal language Declarative approach to building an agent (or other system): 
Proof Systems KB |- Q iff there is a sequence of wffs D1,..., Dn such that Dn is Q and for each Di in the sequence: a) either Di is in KB or b) Di can.
Propositional Logic: Methods of Proof (Part II)
CS 4100 Artificial Intelligence Prof. C. Hafner Class Notes Jan 19, 2012.
CHAPTERS 7, 8 Oliver Schulte Logical Inference: Through Proof to Truth.
Logical Agents Logic Propositional Logic Summary
1 Knowledge Representation. 2 Definitions Knowledge Base Knowledge Base A set of representations of facts about the world. A set of representations of.
Logical Agents Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
Logical Agents Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
Propositional Logic: Methods of Proof (Part II) This lecture topic: Propositional Logic (two lectures) Chapter (previous lecture, Part I) Chapter.
An Introduction to Artificial Intelligence – CE Chapter 7- Logical Agents Ramin Halavati
S P Vimal, Department of CSIS, BITS, Pilani
CPSC 322, Lecture 23Slide 1 Logic: TD as search, Datalog (variables) Computer Science cpsc322, Lecture 23 (Textbook Chpt 5.2 & some basic concepts from.
Logical Agents Chapter 7. Knowledge bases Knowledge base (KB): set of sentences in a formal language Inference: deriving new sentences from the KB. E.g.:
1 Logical Agents Chapter 7. 2 A simple knowledge-based agent The agent must be able to: –Represent states, actions, etc. –Incorporate new percepts –Update.
Logical Agents Chapter 7. Outline Knowledge-based agents Logic in general Propositional (Boolean) logic Equivalence, validity, satisfiability.
1 Logical Inference Algorithms CS 171/271 (Chapter 7, continued) Some text and images in these slides were drawn from Russel & Norvig’s published material.
1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start  Breeze.
CPSC 322, Lecture 19Slide 1 (finish Planning) Propositional Logic Intro, Syntax Computer Science cpsc322, Lecture 19 (Textbook Chpt – 5.2) Oct,
CPSC 422, Lecture 21Slide 1 Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 21 Oct, 30, 2015 Slide credit: some slides adapted from Stuart.
© Copyright 2008 STI INNSBRUCK Intelligent Systems Propositional Logic.
Dr. Shazzad Hosain Department of EECS North South Universtiy Lecture 04 – Part B Propositional Logic.
1 Propositional Logic Limits The expressive power of propositional logic is limited. The assumption is that everything can be expressed by simple facts.
Logical Agents Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
Logical Agents Chapter 7. Outline Knowledge-based agents Propositional (Boolean) logic Equivalence, validity, satisfiability Inference rules and theorem.
Logical Agents Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
UBC Department of Computer Science Undergraduate Events More
Logical Agents Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
Logical Agents Chapter 7 Part I. 2 Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic.
Proof Methods for Propositional Logic CIS 391 – Intro to Artificial Intelligence.
Knowledge Repn. & Reasoning Lecture #9: Propositional Logic UIUC CS 498: Section EA Professor: Eyal Amir Fall Semester 2005.
Logical Agents Chapter 7. Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence,
Logical Agents. Inference : Example 1 How many variables? 3 variables A,B,C How many models? 2 3 = 8 models.
CS666 AI P. T. Chung Logic Logical Agents Chapter 7.
Logical Agents. Outline Knowledge-based agents Logic in general - models and entailment Propositional (Boolean) logic Equivalence, validity, satisfiability.
Computer Science cpsc322, Lecture 20
EA C461 – Artificial Intelligence Logical Agent
Propositional Definite Clause Logic: Syntax, Semantics, R&R and Proofs
Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 21
Logical Inference: Through Proof to Truth
Logical Agents Chapter 7 Selected and slightly modified slides from
Logical Agents Reading: Russell’s Chapter 7
Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 20
Logic Use mathematical deduction to derive new knowledge.
Artificial Intelligence: Agents and Propositional Logic.
Assignment-2 due now Enterprise Architecture Conference Sat. Oct 27
Back to “Serious” Topics…
Computer Science cpsc322, Lecture 20
Methods of Proof Chapter 7, second half.
Propositional Logic: Methods of Proof (Part II)
Presentation transcript:

Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 20 Mar, 2, 2015 Lecture 20 Slide credit: some slides adapted from Stuart Russell (Berkeley), some from Padhraic Smyth (UCIrvine) CPSC 322, Lecture 19

PhD thesis I was reviewing over the weekend…  University of Alberta EXTRACTING INFORMATION NETWORKS FROM TEXT We model predicate detection as a sequence labeling problem — …. We adopt the BIO encoding, a widely-used technique in NLP. Our method, called Meta-CRF, is based on Conditional Random Fields (CRF) . CRF is a graphical model that estimates a conditional probability distribution, denoted p(yjx), over label sequence y given the token sequence x. We model predicate detection as a sequence labeling problem — given a input sequence of tokens x = x1; : : : ; xn, produce an output sequence of labels y = y1; : : : ; yn from a set of labels. In particular, we consider tokens in between two arguments and labels indicating whether a token belongs to a predicate or not. We adopt the BIO encoding, a widely-used technique in natural language processing [47]. This encoding marks the Beginning, Inside and Outside of a phrase; therefore, each token is labeled as B-REL, I-REL or O-REL. Figure 4.2 illustrates the tokens appearing in between “U.S.” and “Moscow” and their respective labels. Tokens that should be labelled as B-REL or I-REL are called relational tokens. Our method, called Meta-CRF, is based on Conditional Random Fields (CRF) [51]. CRF is a graphical model that estimates a conditional probability distribution, denoted p(yjx), over label sequence y given the token sequence x. CPSC 322, Lecture 19

Applications of AI 422 big picture: Where are we? Query Planning Deterministic Stochastic Value Iteration Approx. Inference Full Resolution SAT Logics Belief Nets Markov Decision Processes and Partially Observable MDP Markov Chains and HMMs First Order Logics Ontologies Temporal rep. Applications of AI Approx. : Gibbs Undirected Graphical Models Markov Networks Conditional Random Fields Reinforcement Learning Representation Reasoning Technique Prob CFG Prob Relational Models Markov Logics Hybrid: Det +Sto Forward, Viterbi…. Approx. : Particle Filtering First Order Logics (will build a little on Prolog and 312) Temporal reasoning from NLP 503 lectures Reinforcement Learning (not done in 340, at least in the latest offering) Markov decision process Set of states S, set of actions A Transition probabilities to next states P(s’| s, a′) Reward functions R(s, s’, a) RL is based on MDPs, but Transition model is not known Reward model is not known While for MDPs we can compute an optimal policy RL learns an optimal policy CPSC 322, Lecture 34

Logics in AI: Similar slide to the one for planning Propositional Definite Clause Logics Semantics and Proof Theory Satisfiability Testing (SAT) Propositional Logics First-Order Logics Description Logics Hardware Verification Production Systems Product Configuration Ontologies Cognitive Architectures Semantic Web Video Games Summarization Tutoring Systems Information Extraction CPSC 322, Lecture 19

Relationships between different Logics (better with colors) CPSC 322, Lecture 19

Lecture Overview Basics Recap: Interpretation / Model /.. Propositional Logics Satisfiability, Validity Resolution in Propositional logics CPSC 322, Lecture 19

Basic definitions from 322 (Semantics) Definition (interpretation) An interpretation I assigns a truth value to each atom. Definition (truth values of statements cont’): A knowledge base KB is true in I if and only if every clause in KB is true in I. We can use the interpretation to determine the truth value of clauses and knowledge bases: CPSC 322, Lecture 19

PDC Semantics: Knowledge Base (KB) A knowledge base KB is true in I if and only if every clause in KB is true in I. p q r s I1 true false Which of the three KB below is True in I1 ? C A B p r s ← q ∧ p p q s ← q p q ← r ∧ s

PDC Semantics: Knowledge Base (KB) A knowledge base KB is true in I if and only if every clause in KB is true in I. p q r s I1 true false KB3 KB1 KB2 p r s ← q ∧ p p q s ← q p q ← r ∧ s Which of the three KB above is True in I1 ? KB3

PDC Semantics: Knowledge Base Definition (truth values of statements cont’): A knowledge base KB is true in I if and only if every clause in KB is true in I. CPSC 322, Lecture 20

Basic definitions from 322 (Semantics) Definition (interpretation) An interpretation I assigns a truth value to each atom. Definition (truth values of statements cont’): A knowledge base KB is true in I if and only if every clause in KB is true in I. Definition (model) A model of a set of clauses (a KB) is an interpretation in which all the clauses are true. We can use the interpretation to determine the truth value of clauses and knowledge bases: CPSC 322, Lecture 19

Example: Models p q r s I1 true I2 false I3 I4 I5 Which interpretations are models? is a model of KB not a model of KB CPSC 322, Lecture 20

Basic definitions from 322 (Semantics) Definition (interpretation) An interpretation I assigns a truth value to each atom. Definition (truth values of statements cont’): A knowledge base KB is true in I if and only if every clause in KB is true in I. Definition (model) A model of a set of clauses (a KB) is an interpretation in which all the clauses are true. We can use the interpretation to determine the truth value of clauses and knowledge bases: 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. CPSC 322, Lecture 19

Is it true that if CPSC 322, Lecture 19

Basic definitions from 322 (Proof Theory) Definition (soundness) A proof procedure is sound if KB ⊦ G implies KB ⊧ G. Definition (completeness) A proof procedure is complete if KB ⊧ G implies KB ⊦ G. CPSC 322, Lecture 19

(Propositional) Logic: Key ideas Given a domain that can be represented with n propositions you have …… interpretations (possible worlds) If you do not know anything you can be in any of those If you know that some logical formulas are true (your …….). You know that you can be only in ……… It would be nice to know what else is true in all those… CPSC 322, Lecture 19

Lecture Overview Basics Recap: Interpretation / Model / Propositional Logics Satisfiability, Validity Resolution in Propositional logics CPSC 322, Lecture 19

Relationships between different Logics (better with colors) CPSC 322, Lecture 19

Propositional logic: Syntax Atomic sentences = single proposition symbols E.g., P, Q, R Special cases: True = always true, False = always false Complex 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) CPSC 322, Lecture 19

Propositional logic: Semantics Each interpretation specifies true or false for each proposition symbol E.g. p q r false true false Rules for evaluating truth with respect to an interpretation I : 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 and S2S1 is true Simple recursive process evaluates an arbitrary sentence, e.g., (p  (q  r ))  p = With these symbols, 8 possible models, can be enumerated automatically. is true iff S1 is false or S2 is true p  (q  r ) = true  (true  false) = true  true = true CPSC 322, Lecture 19

Truth tables for connectives CPSC 322, Lecture 19

Truth tables for connectives Implication is always true when the premise is false Why? P=>Q means “if P is true then I am claiming that Q is true, otherwise no claim” Only way for this to be false is if P is true and Q is false CPSC 322, Lecture 19

interpretations CPSC 322, Lecture 19 To manipulate logical sentences we need some rewrite rules. CPSC 322, Lecture 19

Can be used to rewrite formulas…. CPSC 322, Lecture 19

Can be used to rewrite formulas…. CPSC 322, Lecture 19

interpretations interpretation interpretations CPSC 322, Lecture 19

Validity and Satisfiability CPSC 322, Lecture 19

Validity and Satisfiability CPSC 322, Lecture 19

Lecture Overview Basics Recap: Interpretation / Model / Propositional Logics Satisfiability, Validity Resolution in Propositional logics CPSC 322, Lecture 19

Proof by resolution Key ideas Simple Representation for Simple Rule of Derivation CPSC 322, Lecture 19

Conjunctive Normal Form (CNF) Rewrite into conjunction of disjunctions literals (A  B)  (B  C  D) Clause Clause In fact, any KB can be converted into CNF-3 using clauses with at most 3 literals. Any KB can be converted into CNF ! CPSC 322, Lecture 19

Example: Conversion to CNF A  (B  C) Eliminate , replacing α  β with (α  β)(β  α). (A  (B  C))  ((B  C)  A) 2. Eliminate , replacing α  β with α β. (A  B  C)  ((B  C)  A) 3. Using de Morgan's rule replace (α β) with (α   β) : (A  B  C)  ( ( B   C)  A) 4. Apply distributive law ( over ) and flatten: (A  B  C)  (B  A)  (C  A) CPSC 322, Lecture 19

Example: Conversion to CNF A  (B  C) 5. KB is the conjunction of all of its sentences (all are true), so write each clause (disjunct) as a sentence in KB: … (A  B  C) (B  A) (C  A) CPSC 322, Lecture 19

Resolution Deduction step Resolution: inference rule for CNF: sound and complete! * “If A or B or C is true, but not A, then B or C must be true.” “If A is false then B or C must be true, or if A is true then D or E must be true, hence since A is either true or false, B or C or D or E must be true.” * Resolution is “refutation complete” in that it can prove the truth of any entailed sentence by refutation. Simplification CPSC 322, Lecture 19

Resolution Algorithm The resolution algorithm tries to prove: is converted in CNF Resolution is applied to each pair of clauses with complementary literals Resulting clauses are added to the set (if not already there) Process continues until one of two things can happen: We find which is unsatisfiable. i.e. query is entailed We find no contradiction: there is a model that satisfies the sentence and hence we cannot entail the query. We find no contradiction: there is a model that satisfies the sentence (non-trivial) and hence we cannot entail the query. CPSC 322, Lecture 19

Resolution example KB = (A  (B C))  A α = B True! False in Any clause in which two complementary literals appear can be discarded True! False in all worlds CPSC 322, Lecture 19

CPSC 322, Lecture 19

Learning Goals for today’s class You can: Describe relationships between different logics Apply the definitions of Interpretation, model, logical entailment, soundness and completeness Define and apply satisfiability and validity Specify, Trace and Debug the resolution proof procedure for propositional logics CPSC 322, Lecture 19

Next class Wed Finish Resolution Another proof method for Prop. Logic Model checking - Searching through truth assignments. Walksat. First Order Logics CPSC 322, Lecture 19

CPSC 322, Lecture 19

Try it Yourselves 7.9 page 238: (Adapted from Barwise and Etchemendy (1993).) If the unicorn is mythical, then it is immortal, but if it is not mythical, then it is a mortal mammal. If the unicorn is either immortal or a mammal, then it is horned. The unicorn is magical if it is horned. Derive the KB in normal form. Prove: Horned, Prove: Magical. CPSC 322, Lecture 19

Exposes useful constraints “You can’t learn what you can’t represent.” --- G. Sussman In logic: If the unicorn is mythical, then it is immortal, but if it is not mythical, then it is a mortal mammal. If the unicorn is either immortal or a mammal, then it is horned. The unicorn is magical if it is horned. Prove that the unicorn is both magical and horned. A good representation makes this problem easy: ( ¬ Y ˅ ¬ R ) ^ ( Y ˅ R ) ^ ( Y ˅ M ) ^ ( R ˅ H ) ^ ( ¬ M ˅ H ) ^ ( ¬ H ˅ G ) 1010 1111 0001 0101 CPSC 322, Lecture 19 42

CPSC 322, Lecture 19

CPSC 322, Lecture 19

CPSC 322, Lecture 19

CPSC 322, Lecture 19

Logical equivalence To manipulate logical sentences we need some rewrite rules. Two sentences are logically equivalent iff they are true in same models: α ≡ ß iff α╞ β and β╞ α CPSC 322, Lecture 19

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 (tautologies) 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 (determining satisfiability of sentences is NP-complete) 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 a is false) (aka proof by contradiction: assume a to be false and this leads to contraditions in KB) CPSC 322, Lecture 19

Proof methods Application of inference rules: Model checking Proof methods divide into (roughly) two kinds: Application of inference rules: Legitimate (sound) generation of new sentences from old. Resolution Forward & Backward chaining Model checking Searching through truth assignments. Improved backtracking: Davis--Putnam-Logemann-Loveland (DPLL) Heuristic search in model space: Walksat. CPSC 322, Lecture 19

Normal Form We want to prove: We first rewrite into conjunctive normal form (CNF). literals A “conjunction of disjunctions” (A  B)  (B  C  D) Clause Clause Any KB can be converted into CNF k-CNF: exactly k literals per clause

Example: Conversion to CNF B1,1  (P1,2  P2,1) Eliminate , replacing α  β with (α  β)(β  α). (B1,1  (P1,2  P2,1))  ((P1,2  P2,1)  B1,1) 2. Eliminate , replacing α  β with α β. (B1,1  P1,2  P2,1)  ((P1,2  P2,1)  B1,1) 3. Move  inwards using de Morgan's rules and double-negation: (B1,1  P1,2  P2,1)  ((P1,2  P2,1)  B1,1) 4. Apply distributive law ( over ) and flatten: (B1,1  P1,2  P2,1)  (P1,2  B1,1)  (P2,1  B1,1)

Resolution Inference Rule for CNF “If A or B or C is true, but not A, then B or C must be true.” “If A is false then B or C must be true, or if A is true then D or E must be true, hence since A is either true or false, B or C or D or E must be true.” Simplification

Generate all new sentences from KB and the query. Resolution Algorithm The resolution algorithm tries to prove: Generate all new sentences from KB and the query. One of two things can happen: We find which is unsatisfiable, i.e. we can entail the query. 2. We find no contradiction: there is a model that satisfies the Sentence (non-trivial) and hence we cannot entail the query.

Resolution example KB = (B1,1  (P1,2 P2,1))  B1,1 α = P1,2 True False in all worlds

Horn Clauses Resolution in general can be exponential in space and time. If we can reduce all clauses to “Horn clauses” resolution is linear in space and time A clause with at most 1 positive literal. e.g. Every Horn clause can be rewritten as an implication with a conjunction of positive literals in the premises and a single positive literal as a conclusion. 1 positive literal: definite clause 0 positive literals: Fact or integrity constraint:

Normal Form We want to prove: We first rewrite into conjunctive normal form (CNF). literals A “conjunction of disjunctions” (A  B)  (B  C  D) Clause Clause Any KB can be converted into CNF k-CNF: exactly k literals per clause CPSC 322, Lecture 19

Example: Conversion to CNF B1,1  (P1,2  P2,1) Eliminate , replacing α  β with (α  β)(β  α). (B1,1  (P1,2  P2,1))  ((P1,2  P2,1)  B1,1) 2. Eliminate , replacing α  β with α β. (B1,1  P1,2  P2,1)  ((P1,2  P2,1)  B1,1) 3. Move  inwards using de Morgan's rules and double-negation: (B1,1  P1,2  P2,1)  ((P1,2  P2,1)  B1,1) 4. Apply distributive law ( over ) and flatten: (B1,1  P1,2  P2,1)  (P1,2  B1,1)  (P2,1  B1,1) CPSC 322, Lecture 19

Resolution Inference Rule for CNF “If A or B or C is true, but not A, then B or C must be true.” “If A is false then B or C must be true, or if A is true then D or E must be true, hence since A is either true or false, B or C or D or E must be true.” Simplification CPSC 322, Lecture 19

Resolution Algorithm The resolution algorithm tries to prove: Generate all new sentences from KB and the query. One of two things can happen: We find which is unsatisfiable, i.e. we can entail the query. 2. We find no contradiction: there is a model that satisfies the Sentence (non-trivial) and hence we cannot entail the query. CPSC 322, Lecture 19

Resolution example KB = (B1,1  (P1,2 P2,1))  B1,1 α = P1,2 True False in all worlds CPSC 322, Lecture 19

Horn Clauses Resolution in general can be exponential in space and time. If we can reduce all clauses to “Horn clauses” resolution is linear in space and time A clause with at most 1 positive literal. e.g. Every Horn clause can be rewritten as an implication with a conjunction of positive literals in the premises and a single positive literal as a conclusion. 1 positive literal: definite clause 0 positive literals: Fact or integrity constraint: CPSC 322, Lecture 19