Propositional Logic Part 1

Similar documents
Propositional Logic. Logic. Propositional Logic Syntax. Propositional Logic

A Short Introduction to Propositional Logic and First-Order Logic

Knowledge base (KB) = set of sentences in a formal language Declarative approach to building an agent (or other system):

Title: Logical Agents AIMA: Chapter 7 (Sections 7.4 and 7.5)

Inference in Propositional Logic

Logical Agents (I) Instructor: Tsung-Che Chiang

7 LOGICAL AGENTS. OHJ-2556 Artificial Intelligence, Spring OHJ-2556 Artificial Intelligence, Spring

Logical Agent & Propositional Logic

CS 380: ARTIFICIAL INTELLIGENCE

Propositional and First-Order Logic

CS 380: ARTIFICIAL INTELLIGENCE PREDICATE LOGICS. Santiago Ontañón

CSC242: Intro to AI. Lecture 11. Tuesday, February 26, 13

Logical Agent & Propositional Logic

Language of Propositional Logic

Propositional Logic: Review

Proof Methods for Propositional Logic

2. The Logic of Compound Statements Summary. Aaron Tan August 2017

Advanced Topics in LP and FP

Artificial Intelligence Knowledge Representation I

Logic and machine learning review. CS 540 Yingyu Liang

Knowledge based Agents

Intelligent Agents. Pınar Yolum Utrecht University

INF5390 Kunstig intelligens. Logical Agents. Roar Fjellheim

Artificial Intelligence. Propositional Logic. Copyright 2011 Dieter Fensel and Florian Fischer

Logical agents. Chapter 7. Chapter 7 1

Outline. Logical Agents. Logical Reasoning. Knowledge Representation. Logical reasoning Propositional Logic Wumpus World Inference

Artificial Intelligence

Chapter 7 R&N ICS 271 Fall 2017 Kalev Kask

Logic: Propositional Logic (Part I)

Inference Methods In Propositional Logic

Artificial Intelligence Chapter 7: Logical Agents

A brief introduction to Logic. (slides from

Propositional Logic: Models and Proofs

Propositional Logic: Methods of Proof (Part II)

Introduction to Artificial Intelligence. Logical Agents

COMP219: Artificial Intelligence. Lecture 20: Propositional Reasoning

Natural Deduction for Propositional Logic

Propositional logic (revision) & semantic entailment. p. 1/34

Description Logics. Foundations of Propositional Logic. franconi. Enrico Franconi

Comp487/587 - Boolean Formulas

Logical agents. Chapter 7. Chapter 7 1

Logical Agents. Chapter 7

Outline. Logical Agents. Logical Reasoning. Knowledge Representation. Logical reasoning Propositional Logic Wumpus World Inference

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

Knowledge-based Agents. CS 331: Artificial Intelligence Propositional Logic I. Knowledge-based Agents. Outline. Knowledge-based Agents

CS 331: Artificial Intelligence Propositional Logic I. Knowledge-based Agents

Learning Goals of CS245 Logic and Computation

15414/614 Optional Lecture 1: Propositional Logic

Foundations of Artificial Intelligence

Intelligent Systems. Propositional Logic. Dieter Fensel and Dumitru Roman. Copyright 2008 STI INNSBRUCK

Revised by Hankui Zhuo, March 21, Logical agents. Chapter 7. Chapter 7 1

Foundations of Artificial Intelligence

COMP9414: Artificial Intelligence Propositional Logic: Automated Reasoning

TDT4136 Logic and Reasoning Systems

Inference Methods In Propositional Logic

Propositional Logic: Part II - Syntax & Proofs 0-0

Logical Agents. Outline

Part 1: Propositional Logic

Logical Agents: Propositional Logic. Chapter 7

7. Propositional Logic. Wolfram Burgard and Bernhard Nebel

Lecture 7: Logical Agents and Propositional Logic

Price: $25 (incl. T-Shirt, morning tea and lunch) Visit:

Propositional Resolution

AI Programming CS S-09 Knowledge Representation

Kecerdasan Buatan M. Ali Fauzi

Propositional Calculus: Formula Simplification, Essential Laws, Normal Forms

Foundations of Artificial Intelligence

Propositional Logic: Methods of Proof (Part II)

Propositional Logic: Methods of Proof. Chapter 7, Part II

Propositional logic II.

The Importance of Being Formal. Martin Henz. February 5, Propositional Logic

Propositional Logic Language

Artificial Intelligence

Tecniche di Verifica. Introduction to Propositional Logic

Propositional Logic: Methods of Proof (Part II)

Logical Agents. Administrative. Thursday: Midterm 1, 7p-9p. Next Tuesday: DOW1013: Last name A-M DOW1017: Last name N-Z

Class Assignment Strategies

The Wumpus Game. Stench Gold. Start. Cao Hoang Tru CSE Faculty - HCMUT

Artificial Intelligence. Propositional logic

Agents that reason logically

CS 7180: Behavioral Modeling and Decision- making in AI

CS 4700: Artificial Intelligence

Logic. Definition [1] A logic is a formal language that comes with rules for deducing the truth of one proposition from the truth of another.

COMP3702/7702 Artificial Intelligence Week 5: Search in Continuous Space with an Application in Motion Planning " Hanna Kurniawati"

Logic. (Propositional Logic)

Deliberative Agents Knowledge Representation I. Deliberative Agents

Logic. Introduction to Artificial Intelligence CS/ECE 348 Lecture 11 September 27, 2001

Agenda. Artificial Intelligence. Reasoning in the Wumpus World. The Wumpus World

CS 771 Artificial Intelligence. Propositional Logic

COMP219: Artificial Intelligence. Lecture 19: Logic for KR

COMP219: Artificial Intelligence. Lecture 19: Logic for KR

03 Propositional Logic II

Propositional Resolution Introduction

Deductive Systems. Lecture - 3

How to determine if a statement is true or false. Fuzzy logic deal with statements that are somewhat vague, such as: this paint is grey.

The Calculus of Computation: Decision Procedures with Applications to Verification. Part I: FOUNDATIONS. by Aaron Bradley Zohar Manna

Lecture 2. Logic Compound Statements Conditional Statements Valid & Invalid Arguments Digital Logic Circuits. Reading (Epp s textbook)

Natural Deduction. Formal Methods in Verification of Computer Systems Jeremy Johnson

CSC Discrete Math I, Spring Propositional Logic

7. Logical Agents. COMP9414/ 9814/ 3411: Artificial Intelligence. Outline. Knowledge base. Models and Planning. Russell & Norvig, Chapter 7.

Transcription:

Propositional Logic Part 1 Yingyu Liang yliang@cs.wisc.edu Computer Sciences Department University of Wisconsin, Madison [Based on slides from Louis Oliphant, Andrew Moore, Jerry Zhu] slide 1

5 is even implies 6 is odd. Is this sentence logical? True or false? slide 2

Logic If the rules of the world are presented formally, then a decision maker can use logical reasoning to make rational decisions. Several types of logic: propositional logic (Boolean logic first order logic (first order predicate calculus A logic includes: syntax: what is a correctly formed sentence semantics: what is the meaning of a sentence Inference procedure (reasoning, entailment: what sentence logically follows given knowledge slide 3

Propositional logic syntax Sentence AtomicSentence ComplexSentence AtomicSentence True False Symbol Symbol P Q R... ComplexSentence Sentence ( Sentence Sentence ( Sentence Sentence ( Sentence Sentence ( Sentence Sentence BNF (Backus-Naur Form grammar in propositional logic P ((True R Q S well formed P Q S not well formed slide 4

Propositional logic syntax Means True ( control the order of operations P ((True R Q S Means Not Means Or -- disjunction Means And -- conjunction Means if-then implication Propositional symbols must be specified Means iff -- biconditional slide 5

Propositional logic syntax Precedence (from highest to lowest: If the order is clear, you can leave off parenthesis. P True R Q S ok P Q S not ok slide 6

Semantics An interpretation is a complete True / False assignment to propositional symbols Example symbols: P means It is hot, Q means It is humid, R means It is raining There are 8 interpretations (TTT,..., FFF The semantics (meaning of a sentence is the set of interpretations in which the sentence evaluates to True. Example: the semantics of the sentence P Q is the set of 6 interpretations P=True, Q=True, R=True or False P=True, Q=False, R=True or False P=False, Q=True, R=True or False A model of a set of sentences is an interpretation in which all the sentences are true. slide 7

Evaluating a sentence under an interpretation Calculated using the meaning of connectives, recursively. Pay attention to 5 is even implies 6 is odd is True! If P is False, regardless of Q, P Q is True No causality needed: 5 is odd implies the Sun is a star is True. slide 8

Semantics example P Q R Q slide 9

Semantics example P Q R Q P Q R ~P Q^R ~PvQ^R ~PvQ^R->Q 0 0 0 1 0 1 0 0 0 1 1 0 1 0 0 1 0 1 0 1 1 0 1 1 1 1 1 1 1 0 0 0 0 0 1 1 0 1 0 0 0 1 1 1 0 0 0 0 1 1 1 1 0 1 1 1 Satisfiable: the sentence is true under some interpretations Deciding satisfiability of a sentence is NP-complete slide 10

Semantics example (P R Q P R Q slide 11

Semantics example (P R Q P R Q P Q R ~Q R^~Q P^R^~Q P^R P^R->Q final 0 0 0 1 0 0 0 1 0 0 0 1 1 1 0 0 1 0 0 1 0 0 0 0 0 1 0 0 1 1 0 0 0 0 1 0 1 0 0 1 0 0 0 1 0 1 0 1 1 1 1 1 0 0 1 1 0 0 0 0 0 1 0 1 1 1 0 0 0 1 1 0 Unsatisfiable: the sentence is false under all interpretations. slide 12

Semantics example (P Q P Q slide 13

Semantics example (P Q P Q P Q R ~Q P->Q P^~Q (P->QvP^~Q 0 0 0 1 1 0 1 0 0 1 1 1 0 1 0 1 0 0 1 0 1 0 1 1 0 1 0 1 1 0 0 1 0 1 1 1 0 1 1 0 1 1 1 1 0 0 1 0 1 1 1 1 0 1 0 1 Valid: the sentence is true under all interpretations Also called tautology. slide 14

Knowledge base A knowledge base KB is a set of sentences. Example KB: TomGivingLecture (TodayIsTuesday TodayIsThursday TomGivingLecture It is equivalent to a single long sentence: the conjunction of all sentences ( TomGivingLecture (TodayIsTuesday TodayIsThursday TomGivingLecture The model of a KB is the interpretations in which all sentences in the KB are true. slide 15

All interpretations Entailment Entailment is the relation of a sentence logically follows from other sentences (i.e. the KB. = = if and only if, in every interpretation in which is true, is also true is true is true slide 16

Method 1: model checking We can enumerate all interpretations and check this. This is called model checking or truth table enumeration. Equivalently Deduction theorem: = if and only if is valid (always true Proof by contradiction (refutation, reductio ad absurdum: = if and only if is unsatisfiable There are 2 n interpretations to check, if the KB has n symbols slide 17

Inference Let s say you write an algorithm which, according to you, proves whether a sentence is entailed by, without the lengthy enumeration The thing your algorithm does is called inference We don t trust your inference algorithm (yet, so we write things your algorithm finds as - It reads is derived from by your algorithm What properties should your algorithm have? Soundness: the inference algorithm only derives entailed sentences. If - then = Completeness: all entailment can be inferred. If = then - slide 18

Method 2: Sound inference rules All the logical equivalences Modus Ponens (Latin: mode that affirms And-elimination slide 19

Logical equivalences You can use these equivalences to modify sentences. slide 20

Proof Series of inference steps that leads from (or KB to This is exactly a search problem KB: 1. TomGivingLecture (TodayIsTuesday TodayIsThursday 2. TomGivingLecture : TodayIsTuesday slide 21

Proof KB: 1. TomGivingLecture (TodayIsTuesday TodayIsThursday 2. TomGivingLecture 3. TomGivingLecture (TodayIsTuesday TodayIsThursday (TodayIsTuesday TodayIsThursday TomGivingLecture biconditional-elimination to 1. 4. (TodayIsTuesday TodayIsThursday TomGivingLecture and-elimination to 3. 5. TomGivingLecture (TodayIsTuesday TodayIsThursday contraposition to 4. 6. (TodayIsTuesday TodayIsThursday Modus Ponens 2,5. 7. TodayIsTuesday TodayIsThursday de Morgan to 6. 8. TodayIsTuesday and-elimination to 7. slide 22

Method 3: Resolution Your algorithm can use all the logical equivalences, Modus Ponens, and-elimination to derive new sentences. Resolution: a single inference rule Sound: only derives entailed sentences Complete: can derive any entailed sentence Resolution is only refutation complete: if KB =, then KB - empty. It cannot derive empty - (P P But the sentences need to be preprocessed into a special form But all sentences can be converted into this form slide 23

Conjunctive Normal Form (CNF B 1,1 P 1,2 P 2,1 ( P 1,2 B 1,1 P 2,1 B 1,1 Replace all using biconditional elimination Replace all using implication elimination Move all negations inward using -double-negation elimination -de Morgan's rule Apply distributivity of over slide 24

Convert example sentence into CNF B 1,1 (P 1,2 P 2,1 (B 1,1 (P 1,2 P 2,1 ((P 1,2 P 2,1 B 1,1 biconditional elimination B 1,1 P 1,2 P 2,1 ( (P 1,2 P 2,1 B 1,1 implication elimination starting sentence B 1,1 P 1,2 P 2,1 (( P 1,2 P 2,1 B 1,1 move negations inward B 1,1 P 1,2 P 2,1 ( P 1,2 B 1,1 P 2,1 B 1,1 distribute over slide 25

Resolution steps Given KB and (query Add to KB, show this leads to empty (False. Proof by contradiction Everything needs to be in CNF Example KB: B 1,1 (P 1,2 P 2,1 B 1,1 Example query: P 1,2 slide 26

Resolution preprocessing Add to KB, convert to CNF: a1: B 1,1 P 1,2 P 2,1 a2: ( P 1,2 B 1,1 a3: P 2,1 B 1,1 b: B 1,1 c: P 1,2 Want to reach goal: empty slide 27

Resolution Take any two clauses where one contains some symbol, and the other contains its complement (negative P Q R Q S T Merge (resolve them, throw away the symbol and its complement P R S T If two clauses resolve and there s no symbol left, you have reached empty (False. KB = If no new clauses can be added, KB does not entail slide 28

a1: B 1,1 P 1,2 P 2,1 a2: ( P 1,2 B 1,1 a3: P 2,1 B 1,1 b: B 1,1 c: P 1,2 Resolution example slide 29

a1: B 1,1 P 1,2 P 2,1 a2: ( P 1,2 B 1,1 a3: P 2,1 B 1,1 b: B 1,1 c: P 1,2 Resolution example Step 1: resolve a2, c: B 1,1 Step 2: resolve above and b: empty slide 30

Efficiency of the resolution algorithm Run time can be exponential in the worst case Often much faster Factoring: if a new clause contains duplicates of the same symbol, delete the duplicates P R P T P R T If a clause contains a symbol and its complement, the clause is a tautology and useless, it can be thrown away a1: B 1,1 P 1,2 P 2,1 a2: ( P 1,2 B 1,1 P 1,2 P 2,1 P 1,2 (valid, throw away slide 31