Logic. Stephen G. Ware CSCI 4525 / 5525

Similar documents
Logical Agents. Knowledge based agents. Knowledge based agents. Knowledge based agents. The Wumpus World. Knowledge Bases 10/20/14

Intelligent Agents. Pınar Yolum Utrecht University

Logical Agents. Chapter 7

Proof Methods for Propositional Logic

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

Introduction to Artificial Intelligence. Logical Agents

Logical Agent & Propositional Logic

Class Assignment Strategies

Artificial Intelligence. Propositional logic

Logical Agents. Outline

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

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

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

Logical Agent & Propositional Logic

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

Inf2D 06: Logical Agents: Knowledge Bases and the Wumpus World

Kecerdasan Buatan M. Ali Fauzi

AI Programming CS S-09 Knowledge Representation

Logical Agents (I) Instructor: Tsung-Che Chiang

Artificial Intelligence Chapter 7: Logical Agents

Logical agents. Chapter 7. Chapter 7 1

Propositional Logic: Logical Agents (Part I)

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

CS 730/730W/830: Intro AI

Chapter 7 R&N ICS 271 Fall 2017 Kalev Kask

Logical Agents. Santa Clara University

TDT4136 Logic and Reasoning Systems

INF5390 Kunstig intelligens. Logical Agents. Roar Fjellheim

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

CS 771 Artificial Intelligence. Propositional Logic

Artificial Intelligence

CS 188: Artificial Intelligence Spring 2007

Logical Agents. Chapter 7

Logic Programming (PLP 11) Predicate Calculus Clocksin-Mellish Procedure Horn Clauses

Logic Programming (PLP 11) Predicate Calculus, Horn Clauses, Clocksin-Mellish Procedure

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

Artificial Intelligence

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

Introduction to Intelligent Systems

Propositional Logic: Logical Agents (Part I)

Propositional Calculus: Formula Simplification, Essential Laws, Normal Forms

Logical Agents: Propositional Logic. Chapter 7

Foundations of Artificial Intelligence

Logic: Propositional Logic (Part I)

Foundations of Artificial Intelligence

7.5.2 Proof by Resolution

Logic. proof and truth syntacs and semantics. Peter Antal

7. Propositional Logic. Wolfram Burgard and Bernhard Nebel

Introduction to Intelligent Systems

Logical Agents. Outline

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

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

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

CS 380: ARTIFICIAL INTELLIGENCE

Lecture Overview [ ] Introduction to Artificial Intelligence COMP 3501 / COMP Lecture 6. Motivation. Logical Agents

CSCI 5582 Artificial Intelligence. Today 9/28. Knowledge Representation. Lecture 9

CS 730/830: Intro AI. 3 handouts: slides, asst 6, asst 7. Wheeler Ruml (UNH) Lecture 12, CS / 16. Reasoning.

Propositional Logic Basics Propositional Equivalences Normal forms Boolean functions and digital circuits. Propositional Logic.

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

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

Last update: March 4, Logical agents. CMSC 421: Chapter 7. CMSC 421: Chapter 7 1

CS 4700: Artificial Intelligence

Chương 3 Tri th ức và lập luận

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

Propositional Logic: Models and Proofs

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

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

Lecture 7: Logical Agents and Propositional Logic

Comp487/587 - Boolean Formulas

Logical Agents. CITS3001 Algorithms, Agents and Artificial Intelligence. 2018, Semester 2

Lecture 6: Knowledge 1

Foundations of Artificial Intelligence

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

Artificial Intelligence Knowledge Representation I

CS 7180: Behavioral Modeling and Decision- making in AI

Logic & Logic Agents Chapter 7 (& background)

Lecture 7: Logic and Planning

Compound Propositions

Inference Methods In Propositional Logic


CS1021. Why logic? Logic about inference or argument. Start from assumptions or axioms. Make deductions according to rules of reasoning.

Topic 1: Propositional logic

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

Quantifiers Here is a (true) statement about real numbers: Every real number is either rational or irrational.

A statement is a sentence that is definitely either true or false but not both.

Knowledge representation DATA INFORMATION KNOWLEDGE WISDOM. Figure Relation ship between data, information knowledge and wisdom.

Logic and Reasoning. Foundations of Computing Science. Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

Inference Methods In Propositional Logic

1.1 Language and Logic

Propositional Logic: Methods of Proof (Part II)

A simple knowledge-based agent. Logical agents. Outline. Wumpus World PEAS description. Wumpus world characterization. Knowledge bases.

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

CSC Discrete Math I, Spring Propositional Logic

Propositional Logic: Methods of Proof (Part II)

AMTH140 Lecture 8. Symbolic Logic

Math.3336: Discrete Mathematics. Nested Quantifiers

CS 4700: Foundations of Artificial Intelligence

A Little Deductive Logic

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

CS:4420 Artificial Intelligence

Transcription:

Logic Stephen G. Ware CSCI 4525 / 5525

Logic How can we represent knowledge about the world in a general, reusable way? How can we use existing knowledge to gain new knowledge?

Problem Solving Approaches Procedural: For each new problem, write a domainspecific algorithm to solve it. Fast Not reusable Requires domain expertise Declarative: Describe the problem in a common syntax and solve it using general techniques. Slow Reusable Less expertise required

Syntax & Semantics The rules of syntax for a logic define which expressions are legal to write. The semantics of a logic define what an expression means and when it is true or false. Logical algorithms only manipulate syntax, but it is up to the user or the agent to interpret meaning.

Wumpus World 4 3 2 1 A B C D The player, who can navigate the grid world The wumpus, who will eat the player if the player blunders into its square Bottomless pits A chest of gold

Wumpus World 4 3 2 1 A B C D When adjacent to the wumpus, the player detects a stench. When adjacent to a pit, the player detects a breeze. When in the square with the gold, the player detects a glimmer.

Wumpus World 4 3 2 1 A B C D Actions: Move forward Turn left Turn right Grab gold Fire arrow (kills the wumpus if it lies along the trajectory)

Logics How statements are made: Propositional Logic Predicate Logic First Order Logic How statements are combined: Boolean Logic

Propositional Logic Every statement about the world which can be true or false is represented as a unique symbol. Syntax: Semantics: Syntax: Semantics: R It is raining outside. PA1 There is a pit at square A1.

Boolean Logic Boolean operators provide a way to combine individual statements (which can each be true or false) into larger expressions which, as a whole, are true or false.

Negation A NOT expression (or negation) has the opposite truth value as its term. x T F x F T

Conjunction An AND expression (or conjunction) is true just when all of its individual conjuncts are true. x y x y T T T T F F F T F F F F

Disjunction A OR expression (or disjunction) is true when at least one of its individual disjuncts is true. x y x y T T T T F T F T T F F F

Implication A IF expression (or implication) has an antecedent followed by a consequent. It is true when its consequent is true or when both the antecedent and consequent are false. x y x y T T T T F F F T T F F T

Biconditional An IFF (if an only if) expression (or biconditional) is true just when both sides have the same truth value. x y x y T T T T F F F T F F F T The two sides are said to be logically equivalent.

Statements vs. Things The problem with making every statement its own symbol is that we can t say anything about its parts. We want to distinguish between statements (which have a truth value) and the things those statements are about (which do not have a truth value).

Statements vs. Things It is raining outside. is a statement. It is true or false. rain and outside are things. Statements are made about things. They are not true or false.

Predicate Logic The official word for a thing is a term. There are three types of terms: 1. A constant represents a specific thing. 2. A function is a parameterized thing. 3. A variable stands for any term. Statements are made by applying a predicate (relationship) to 0 or more terms.

Predicate Logic Example Predicates: Things: at = a thing is at a location P = player breeze = breeze at W = wumpus stench = stench at P1 = pit 1 Examples: A1 = square A1 at(p1, B3) = Pit 1 is at square B3. at(p, B2) = The player is at square B2. breeze(b2) = The player detects a breeze at B2.

Predicate Logic Example (alt) Predicates: Things: breeze = breeze at A1 = square A1 pit = pit at A2 = square A2 stench = stench at wumpus = wumpus at Examples: breeze(b2) = The player detects a breeze at B2 pit(b3) = There is a pit at B3.

Functions A function is a term which can be treated like a constant, but which is parameterized with other terms. e.g. above(x) means the square above square x. e.g. above(b1) means the square above B1.

Functions A function is a term which can be treated like a constant, but which is parameterized with other terms. Do not confuse functions with predicates! They look the same, but Functions are things. They have no truth value. Predicates are statements about relationships. They do have truth value.

Ground Expressions We say that a predicate logic expression is ground when it contains no variables. e.g. pit(x) is not ground e.g. pit C1 is ground

First Order Logic Specifies not only relationships between objects but also over quantities of objects. The universal quantifier means for all. e.g. x animal x loves(john, x) = John loves all animals. The existential quantifier means there exists. e.g. x loves(x, John) = Someone loves John.

Scope of Quantified Variables Consider two facts about the Wumpus world: x(breeze x y (adjacent x, y pit y )) x(stench x y (adjacent x, y wumpus y )) x only exists here

Scope of Quantified Variables Consider two facts about the Wumpus world: x(breeze x y (adjacent x, y pit y )) x(stench x y (adjacent x, y wumpus y )) y only exists here

Standardizing Apart Consider two facts about the Wumpus world: x(breeze x y (adjacent x, y pit y )) x(stench x y (adjacent x, y wumpus y )) The reuse of x and y in these two facts can get confusing, so we standardize apart the variable names to avoid any confusion.

Standardizing Apart Consider two facts about the Wumpus world: w(breeze w x (adjacent w, x pit x )) y(stench y z (adjacent y, z wumpus z )) The reuse of x and y in these two facts can get confusing, so we standardize apart the variable names to avoid any confusion.

Conventions for Quantifiers When using first order logic, we assume that all variables are universally quantified. This means we can leave off universal quantifiers. x loves(john, x) can simply be written as: loves(john, x)

Skolemization We can replace existentially quantified variables with a single Skolem constant representing the object in question. x loves(x, Mosquitoes) can simply be written as: loves P, Mosquitoes P is a person who loves mosquitoes.

Logics (Review) Propositional logic is simple, so we will often use it in examples, but it is not very expressive. Predicate logic is more expressive, especially when combined with First order logic adds universal and existential quantifiers. Boolean logic can be used with any logic above.

Important Equivalencies Negated Quantifiers Implications and Disjunctions De Morgan s Laws Distribution of OR over AND

Negated Quantifiers The universal and existential quantifiers are related; each is the negation of the other. x loves(john, x) means It is not true that John loves everything. Its negation would be: x loves(john, x), which means There exists something that John does not love.

Negated Quantifiers The universal and existential quantifiers are related; each is the negation of the other. x loves(x, Mosquitoes) means There does not exist anyone who loves mosquitoes. Its negation would be: x loves(x, Mosquitoes), which means Everyone does not loves mosquitoes.

Implications and Disjunction Notice the similarity: x y x y T T T T F F F T T F F T x y x y T T T F F T F F

Implications and Disjunction Notice the similarity: x y x y T T T T F F F T T F F T x y x y T T T T F F F T T F F T The expressions x y and x y are equivalent.

De Morgan s Laws x y x y x y x y Exercise: Write the truth tables to prove these laws.

Distribution of OR over AND x y z x y x z Exercise: Write truth tables to prove this.

Distribution of OR over AND This can be generalized to situations like this: w x y z w x y w x z y w x z w x (y w) y x z w z x y w y x z w z x (w y) w z (x y) x z

Database Semantics Unique Names Assumption Each constant refers to a different object. (Note: This means two constants cannot be equal.) Domain Closure Assumption Only those objects we name exist. Closed World Assumption Facts not explicitly stated to be true are false.

Skolemization (cont.) Consider this statement: x y breeze x adjacent x, y pit y By convention, we drop the universal variable: y breeze x adjacent x, y pit y Can we replace y with a Skolem constant?

Skolemization (cont.) Original statement: x y breeze x adjacent x, y pit y Replaced with Skolem constant: breeze x adjacent x, S pit S This does not have the same meaning! It says that all breezy squares are adjacent to the same pit square.

Skolemization (cont.) Original statement: x y breeze x adjacent x, y pit y Replaced with Skolem function: breeze x adjacent x, S(x) pit S(x) This has the same meaning, because the function can stand for more than just one square.

Skolemization (cont.) When an existential quantifier appears within the scope of one or more universal quantifiers, we replace the existentially quantified variable with a Skolem function whose parameters are all the universally quantified variables. Skolem functions can be seen as a generalization of Skolem constants, because a constant can be thought of as a function with 0 parameters.

Conjunctive Normal Form Literals Disjunctive Clauses Conjunctive Normal Form (CNF) Converting to CNF

Literals A literal is an individual statement or its negation. Propositional logic example: x is a literal x is a literal Predicate logic example: pit(a1) is a literal pit A1 is a literal

Clauses A disjunctive clause is a disjunction whose disjuncts are all literals. (This includes a disjunction of 1 disjunct, i.e. a literal by itself.) animal(x) is a disjunctive clause animal x loves John, x is a disjunctive clause

Conjunctive Normal Form An expression is in conjunctive normal form (CNF) if it is a conjunction of disjunctive clauses. (This includes a conjunction of 1 literal, i.e. a literal by itself.) disjunctive clause disjunctive clause animal x animal x loves John, x is in conjunctive normal form

Disjunctive Normal Form An expression is in conjunctive normal form (CNF) if it is a conjunction of disjunctive clauses. (This includes a conjunction of 1 literal, i.e. a literal by itself.) CNF expression animal x animal x loves John, x is in conjunctive normal form

Conjunctive Normal Form All logical expressions can be converted to conjunctive normal form. This allows us to standardize the input to logical algorithms and simplify the code.

Converting to CNF 1. Eliminate implications. 2. Move inwards. 3. Standardize variable names apart. 4. Skolemize. 5. Drop universal quantifiers. 6. Apply De Morgan s laws.

Converting to CNF Convert the following to CNF: x y animal y loves x, y y loves(y, x) Everyone who loves all animals is loved by someone.

Converting to CNF 1. Eliminate implications. Remember: x y ( x y) x y animal y loves x, y y loves y, x becomes:

Converting to CNF 1. Eliminate implications. Remember: x y ( x y) x y animal y loves x, y y loves y, x becomes:

Converting to CNF 1. Eliminate implications. Remember: x y ( x y) x y animal y loves x, y y loves y, x becomes: x y animal y loves x, y y loves y, x

Converting to CNF 1. Eliminate implications. Remember: x y ( x y) x y animal y loves x, y y loves y, x becomes: x y animal y loves x, y y loves y, x

Converting to CNF 1. Eliminate implications. Remember: x y ( x y) x y animal y loves x, y y loves y, x becomes: x y animal y loves x, y y loves y, x

Converting to CNF 1. Eliminate implications. Remember: x y ( x y) x y animal y loves x, y y loves y, x becomes: x y animal y loves x, y y loves y, x

Converting to CNF 2. Move inwards. Remember: Negated quantifiers & De Morgan s laws. x ( y animal y loves x, y ) ( y loves y, x ) becomes: x y animal y loves x, y ( y loves y, x ) Either there is some animal that x does not love, or someone loves x.

Converting to CNF 3. Standardize variable names apart. x y animal y loves x, y ( y loves y, x ) becomes: x y animal y loves x, y ( z loves z, x )

Converting to CNF 4. Skolemize. x y animal y loves x, y ( z loves z, x ) becomes: x animal F(x) loves x, F(x) loves G(x), x

Converting to CNF 5. Drop universal quantifiers. x animal F(x) loves x, F(x) loves G(x), x becomes: animal F(x) loves x, F(x) loves G(x), x

Converting to CNF 6. Distribute AND over OR. animal F(x) loves x, F(x) loves G(x), x becomes: animal F(x) loves(g x, x) loves x, F(x) loves(g x, x)