First-Order Logic PREDICATE LOGIC. Syntax. Terms

Similar documents
First Order Predicate Logic CIS 32

CITS2211 Discrete Structures Logic

CMPSCI 250: Introduction to Computation. Lecture #7: Quantifiers and Languages 6 February 2012

Quantification. Using the suggested notation, symbolize the statements expressed by the following sentences.

Automated Reasoning. Natural Deduction in First-Order Logic

Module 6. Knowledge Representation and Logic (First Order Logic) Version 2 CSE IIT, Kharagpur

Resolution (14A) Young W. Lim 6/14/14

SOFTWARE ENGINEERING DESIGN I

Overview. CS389L: Automated Logical Reasoning. Lecture 6: First Order Logic Syntax and Semantics. Constants in First-Order Logic.

Section 2.4: Arguments with Quantified Statements

AXIOMS FOR THE INTEGERS

This is already grossly inconvenient in present formalisms. Why do we want to make this convenient? GENERAL GOALS

Lecture 4: January 12, 2015

MITOCW watch?v=kz7jjltq9r4

CS 3512, Spring Instructor: Doug Dunham. Textbook: James L. Hein, Discrete Structures, Logic, and Computability, 3rd Ed. Jones and Barlett, 2010

Recursively Enumerable Languages, Turing Machines, and Decidability

CSC Discrete Math I, Spring Sets

Propositional Logic. Part I

LECTURE 4: DEDUCTIVE REASONING AGENTS. An Introduction to Multiagent Systems CIS 716.5, Spring 2006

Towards a Logical Reconstruction of Relational Database Theory

Chapter 1.3 Quantifiers, Predicates, and Validity. Reading: 1.3 Next Class: 1.4. Motivation

Chapter 3. Set Theory. 3.1 What is a Set?

Warm-Up Problem. Let L be the language consisting of as constant symbols, as a function symbol and as a predicate symbol. Give an interpretation where

ITCS 6150 Intelligent Systems. Lecture 13 First-Order Logic Chapter 8

Foundations of AI. 9. Predicate Logic. Syntax and Semantics, Normal Forms, Herbrand Expansion, Resolution

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Chapter p. 1/27

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages

CSE 311: Foundations of Computing. Lecture 8: Predicate Logic Proofs

Going beyond propositional logic

for all x, the assertion P(x) is false. there exists x, for which the assertion P(x) is true.

1 Elementary number theory

Computation Club: Gödel s theorem

Programming Languages Third Edition

CSE 20 DISCRETE MATH. Fall

CHAPTER 3: DEDUCTIVE REASONING AGENTS. An Introduction to Multiagent Systems. mjw/pubs/imas/

Fondamenti della Programmazione: Metodi Evoluti. Lezione 5: Invariants and Logic

15-819M: Data, Code, Decisions

Notes. Notes. Introduction. Notes. Propositional Functions. Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry.

Chapter 2 & 3: Representations & Reasoning Systems (2.2)

THE PREDICATE CALCULUS

STABILITY AND PARADOX IN ALGORITHMIC LOGIC

Lecture 5: Predicate Calculus. ffl Predicate Logic ffl The Language ffl Semantics: Structures

Lecture 7: January 15, 2014

Predicate Logic CHAPTER What This Chapter Is About

[Ch 6] Set Theory. 1. Basic Concepts and Definitions. 400 lecture note #4. 1) Basics

Practice Problems: All Computer Science majors are people. Some computer science majors are logical thinkers. Some people are logical thinkers.

Reasoning About Imperative Programs. COS 441 Slides 10

Lecture 1: Conjunctive Queries

Diagonalization. The cardinality of a finite set is easy to grasp: {1,3,4} = 3. But what about infinite sets?

Material from Recitation 1

9/19/12. Why Study Discrete Math? What is discrete? Sets (Rosen, Chapter 2) can be described by discrete math TOPICS

CSE 20 DISCRETE MATH. Winter

1.3 Primitive Recursive Predicates and Bounded Minimalization

CS 125 Section #4 RAMs and TMs 9/27/16

Today s Topics. What is a set?

Definition: A context-free grammar (CFG) is a 4- tuple. variables = nonterminals, terminals, rules = productions,,

Intro. Scheme Basics. scm> 5 5. scm>

Lecture 7: Primitive Recursion is Turing Computable. Michael Beeson

Propositional Logic Formal Syntax and Semantics. Computability and Logic

SCHEME 7. 1 Introduction. 2 Primitives COMPUTER SCIENCE 61A. October 29, 2015

(a) (4 pts) Prove that if a and b are rational, then ab is rational. Since a and b are rational they can be written as the ratio of integers a 1

Automata Theory for Reasoning about Actions

COMP310 MultiAgent Systems. Chapter 3 - Deductive Reasoning Agents

Formal Methods of Software Design, Eric Hehner, segment 1 page 1 out of 5

Theorem proving. PVS theorem prover. Hoare style verification PVS. More on embeddings. What if. Abhik Roychoudhury CS 6214

Formal Predicate Calculus. Michael Meyling

CITS5501 Software Testing and Quality Assurance Formal methods

Z Notation. June 21, 2018

Outline. Introduction. 2 Proof of Correctness. 3 Final Notes. Precondition P 1 : Inputs include

1 Introduction CHAPTER ONE: SETS

Lecture 1 Contracts. 1 A Mysterious Program : Principles of Imperative Computation (Spring 2018) Frank Pfenning

For next Tuesday. Read chapter 8 No written homework Initial posts due Thursday 1pm and responses due by class time Tuesday

Lecture 1 Contracts : Principles of Imperative Computation (Fall 2018) Frank Pfenning

Homework 1. Due Date: Wednesday 11/26/07 - at the beginning of the lecture

Safe Stratified Datalog With Integer Order Does not Have Syntax

Combinatorics Prof. Dr. L. Sunil Chandran Department of Computer Science and Automation Indian Institute of Science, Bangalore

Introductory logic and sets for Computer scientists

p x i 1 i n x, y, z = 2 x 3 y 5 z

Lecture 6: Arithmetic and Threshold Circuits

Lecture 5: The Halting Problem. Michael Beeson

PHIL 240, Introduction to Logic, Sections Fall 2011 FINAL EXAM 14 December Name (5 points): Section (5 points):

Foundations, Reasoning About Algorithms, and Design By Contract CMPSC 122

Lecture 5 - Axiomatic semantics

Lecture 4: examples of topological spaces, coarser and finer topologies, bases and closed sets

Definition MATH Benjamin V.C. Collins, James A. Swenson MATH 2730

THE FOUNDATIONS OF MATHEMATICS

6.080 / Great Ideas in Theoretical Computer Science Spring 2008

CS Bootcamp Boolean Logic Autumn 2015 A B A B T T T T F F F T F F F F T T T T F T F T T F F F

Lecture 3: Recursion; Structural Induction

Knowledge Representation. CS 486/686: Introduction to Artificial Intelligence

Knowledge Representation

Solutions to Selected Exercises

Math 126 Number Theory

MATH 22 MORE ABOUT FUNCTIONS. Lecture M: 10/14/2003. Form follows function. Louis Henri Sullivan

Cardinality of Sets MAT231. Fall Transition to Higher Mathematics. MAT231 (Transition to Higher Math) Cardinality of Sets Fall / 15

Bootcamp. Christoph Thiele. Summer An example of a primitive universe

Lecture Transcript While and Do While Statements in C++

CPSC 121: Models of Computation. Module 5: Predicate Logic

Prolog. Reading: Sethi, Chapter 11. Overview. Predicate Calculus. Substitution and Unication. Introduction to Prolog. Prolog Inference Rules

COMPUTABILITY THEORY AND RECURSIVELY ENUMERABLE SETS

Transcription:

First-Order Logic PREDICATE LOGIC Aim of this lecture: to introduce first-order predicate logic. More expressive than propositional logic. Consider the following argument: all monitors are ready; X12 is a monitor; therefore X12 is ready. Sense of this argument cannot be captured in propositional logic. Propositional logic is too coarse grained to allow us to represent and reason about this kind of statement. cis716-spring2006-parsons-lect14 2 Syntax We shall now introduce a generalisation of propositional logic called first-order logic (FOL). This new logic affords us much greater expressive power. Definition: The alphabet of FOPL contains: 1. a set of constants; 2. a set of variables; 3. a set of function symbols; 4. a set of predicates symbols; 5. the connectives, ; 6. the quantifiers,, 1 ; 7. the punctuation symbols ), (. Terms The basic components of FOL are called terms. Essentially, a term is an object that denotes some object other than or. The simplest kind of term is a constant. A value such as 8 is a constant. The denotation of this term is the number 8. Note that a constant and the number it denotes are different! Aliens don t write 8 for the number 8, and nor did the Romans. cis716-spring2006-parsons-lect14 3 cis716-spring2006-parsons-lect14 4

The second simplest kind of term is a variable. A variable can stand for anything in the domain of discourse. The domain of discourse (usually abbreviated to domain) is the set of all objects under consideration. Sometimes, we assume the set contains everything. Sometimes, we explicitly give the set, and state what variables/constants can stand for. Functions We can now introduce a more complex class of terms functions. The idea of functional terms in logic is similar to the idea of a function in programming. Recall that in programming, a function is a procedure that takes some arguments, and returns a value. In C: T f(t1 a1,..., Tn an) this function takes n arguments; the first is of type T1, the second is of type T2, and so on. The function returns a value of type T. In FOL, we have a set of function symbols; each symbol corresponds to a particular function. (It denotes some function.) cis716-spring2006-parsons-lect14 5 cis716-spring2006-parsons-lect14 6 Each function symbol is associated with a number called its arity. This is just the number of arguments it takes. A functional term is built up by applying a function symbol to the appropriate number of terms. Formally... Definition: Let f be an arbitrary function symbol of arity n. Also, let τ 1,...,τ n be terms. Then is a functional term. f(τ 1,...,τ n ) All this sounds complicated, but isn t. Consider a function plus, which takes just two arguments, each of which is a number, and returns the first number added to the second. Then: plus(2, 3) is an acceptable functional term; plus(0, 1) is acceptable; plus(plus(1, 2), 4) is acceptable; plus(plus(plus(0, 1), 2), 4) is acceptable; cis716-spring2006-parsons-lect14 7 cis716-spring2006-parsons-lect14 8

In maths, we have many functions; the obvious ones are The fact that we write instead of something like + / sin cos... 2 + 3 plus(2, 3) is just convention, and is not relevant from the point of view of logic; all these are functions in exactly the way we have defined. Using functions, constants, and variables, we can build up expressions, e.g.: (x + 3) sin 90 (which might just as well be written for all it matters.) times(plus(x, 3), sin(90)) cis716-spring2006-parsons-lect14 9 cis716-spring2006-parsons-lect14 10 Predicates In addition to having terms, FOL has relational operators, which capture relationships between objects. The language of FOL contains predicate symbols. These symbols stand for relationships between objects. Each predicate symbol has an associated arity (number of arguments). Definition: Let P be a predicate symbol of arity n, and τ 1,...,τ n are terms. Then P(τ 1,...,τ n ) is a predicate, which will either be or under some interpretation. EXAMPLE. Let gt be a predicate symbol with the intended interpretation greater than. It takes two arguments, each of which is a natural number. Then: gt(4, 3) is a predicate, which evaluates to ; gt(3, 4) is a predicate, which evaluates to. The following are standard mathematical predicate symbols: > < =... The fact that we are normally write x > y instead of gt(x, y) is just convention. cis716-spring2006-parsons-lect14 11 cis716-spring2006-parsons-lect14 12

We can build up more complex predicates using the connectives of propositional logic: (2 > 3) (6 = 7) ( 4 = 2) So a predicate just expresses a relationship between some values. What happens if a predicate contains variables: can we tell if it is true or false? Not usually; we need to know an interpretation for the variables. A predicate that contains no variables is a proposition. Predicates of arity 1 are called properties. EXAMPLE. The following are properties: Woman(x) Clever(x) Powerful(x). We interpret P(x) as saying x is in the set P. Predicate that have arity 0 (i.e., take no arguments) are called primitive propositions. These are identical to the primitive propositions we saw in propositional logic. cis716-spring2006-parsons-lect14 13 cis716-spring2006-parsons-lect14 14 Quantifiers We now come to the central part of first order logic: quantification. Consider trying to represent the following statements: all people have a mother; every positive integer has a prime factor. We can t represent these using the apparatus we ve got so far; we need quantifiers. We use three quantifers: the universal quantifier; is read for all... the existential quantifier; is read there exists... 1 the unique quantifier; is read there exists a unique... cis716-spring2006-parsons-lect14 15 cis716-spring2006-parsons-lect14 16

The simplest form of quantified formula is as follows: where quantifier is one of,, 1 ; variable is a variable; and predicate is a predicate. quantifier variable predicate Examples x Person(x) Mortal(x) For all x, if x is a person, then x is mortal. (i.e. all people are mortal) x Person(x) 1 y Woman(y) MotherOf(x, y) For all x, if x is a person, then there exists exactly one y such that y is a woman and the mother of x is y. (i.e., every person has exactly one mother). cis716-spring2006-parsons-lect14 17 cis716-spring2006-parsons-lect14 18 m Monitor(m) MonitorState(m, ready) There exists a monitor that is in a ready state. r Reactor(r) 1 t (100 t 1000) temp(r) = t Every reactor will have a temperature in the range 100 to 1000. n posint(n) n = (n n) Some positive integer is equal to its own square. c ECCountry(c) Borders(c, Albania) Some EC country borders Albania. m, n Person(m) Person(n) Superior(m, n) No person is superior to another. m Person(m) n Person(n) Superior(m, n) Ditto. cis716-spring2006-parsons-lect14 19 cis716-spring2006-parsons-lect14 20

Domains & Interpretations Suppose we have a formula x P(x). What does x range over? Physical objects, numbers, people, times,...? Depends on the domain that we intend. Often, we name a domain to make our intended interpretation clear. Suppose our intended interpretation is the +ve integers. Suppose >, +,,... have the usual mathematical interpretation. Is this formula satisfiable under this interpretation? n n = (n n) Now suppose that our domain is all living people, and that means is the child of. Is the formula satisfiable under this interpretation? cis716-spring2006-parsons-lect14 21 cis716-spring2006-parsons-lect14 22 Comments Note that universal quantification is similar to conjunction. Suppose the domain is the numbers {2, 4, 6}. Then is the same as n Even(n) Even(2) Even(4) Even(6). Existential quantification is similar to disjunction. Thus with the same domain, is the same as n Even(n) The universal and existential quantifiers are in fact duals of each other: x P(x) x P(x) Saying that everything has some property is the same as saying that there is nothing that does not have the property. x P(x) x P(x) Saying that there is something that has the property is the same as saying that its not the case that everything doesn t have the property. Even(2) Even(4) Even(6). cis716-spring2006-parsons-lect14 23 cis716-spring2006-parsons-lect14 24

Decidability In propositional logic, we saw that some formulae were tautologies they had the property of being true under all interpretations. We also saw that there was a procedure which could be used to tell whether any formula was a tautology this procedure was the truth-table method. A formula of FOL that is true under all interpretations is said to be valid. So in theory we could check for validity by writing down all the possible interpretations and looking to see whether the formula is true or not. Unfortuately in general we can t use this method. Consider the formula: n Even(n) Odd(n) There are an infinite number of interpretations. Is there any other procedure that we can use, that will be guaranteed to tell us, in a finite amount of time, whether a FOL formula is, or is not, valid? The answer is no. FOL is for this reason said to be undecidable. cis716-spring2006-parsons-lect14 25 cis716-spring2006-parsons-lect14 26 Proof in FOL Proof in FOL is similar to PL; we just need an extra set of rules, to deal with the quantifiers. FOL inherits all the rules of PL. To understand FOL proof rules, need to understand substitution. The most obvious rule, for -E. Tells us that if everything in the domain has some property, then we can infer that any particular individual has the property. x φ(x); φ(a) -E for any a in the domain Example 1. Let s use -E to get the Socrates example out of the way. Person(s); x Person(x) Mortal(x) Mortal(s) 1. Person(s) Given 2. x Person(x) Mortal(x) Given 3. Person(s) Mortal(s) 2, -E 4. Mortal(s) 1, 3, -E Going from general to specific. cis716-spring2006-parsons-lect14 27 cis716-spring2006-parsons-lect14 28

We can also go from the general to the slightly less specific! x φ(x); x φ(x) -I(1) if domain not empty Note the side condition. The quantifier asserts the existence of at least one object. The quantifier does not. We can also go from the very specific to less specific. φ(a); x φ(x) -I(2) In other words once we have a concrete example, we can infer there exists something with the property of that example. cis716-spring2006-parsons-lect14 29 cis716-spring2006-parsons-lect14 30 We often informally make use of arguments along the lines... 1. We know somebody is the murderer. 2. Call this person a. 3.... (Here, a is called a Skolem constant.) We have a rule which allows this, but we have to be careful how we use it! x φ(x); φ(a) -E a doesn t occur elsewhere Here is an invalid use of this rule: 1. x Boring(x) Given 2. Lecture(AI) Given 3. Boring(AI) 1, -E (The conclusion may be true, the argument isn t sound.) cis716-spring2006-parsons-lect14 31 cis716-spring2006-parsons-lect14 32

Another kind of reasoning: Let a be arbitrary object.... (some reasoning)... Therefore a has property φ Since a was arbitrary, it must be that every object has property φ. Common in mathematics: Consider a positive integer n... so n is either a prime number or divisible by a smaller prime number... so every positive integer is either a prime number or divisible by a smaller prime number. If we are careful, we can also use this kind of reasoning: Invalid use of this rule: φ(a); x φ(x) -I a is arbitrary 1. Boring(AI) Given 2. x Boring(x) 1, -I cis716-spring2006-parsons-lect14 33 cis716-spring2006-parsons-lect14 34 Example 2: 1. Everybody is either happy or rich. 2. Simon is not rich. 3. Therefore, Simon is happy. Predicates: H(x) means x is happy; R(x) means x is rich. Formalisation: x.h(x) R(x); R(Simon) H(Simon) 1. x.h(x) R(x) Given 2. R(Simon) Given 3. H(Simon) R(Simon) 1, -E 4. H(Simon) R(Simon) 3, defn 5. H(Simon) As. 6. R(Simon) 4, 5, -E 7. R(Simon) R(Simon) 2, 6, -I 8. H(Simon) 5, 7, -I 9. H(Simon) H(Simon) PL axiom 10. (H(Simon) H(Simon)) ( H(Simon) H(Simon)) 9, defn 11. H(Simon) H(Simon) 10, -E 12. H(Simon) 8, 11, -E cis716-spring2006-parsons-lect14 35 cis716-spring2006-parsons-lect14 36

Logic-Based Agents When we started talking about logic, it was as a means of representing knowledge. We wanted to represent knowledge in order to be able to build agents. We now know enough about logic to do that. We will now see how a logic-based agent can be designed to perform simple tasks. Assume each agent has a database, i.e., set of FOL-formulae. These represent information the agent has about environment. We ll write for this database. Also assume agent has set of rules. We ll write R for this set of rules. We write R φ if the formula φ can be proved from the database using only the rules R. How to program an agent: Write the agent s rules R so that it should do action a whenever R Do(a). Here, Do is a predicate. Also assume A is set of actions agent can perform. cis716-spring2006-parsons-lect14 37 cis716-spring2006-parsons-lect14 38 The agent s operation: 1. for each a in A do 2. if R Do(a) then 3. return a 4. end-if 5. end-for 6. for each a in A do 7. if R Do(a) then 8. return a 9. end-if 10. end-for 11. return null An example: We have a small robot that will clean up a house. The robot has sensor to tell it whether it is over any dirt, and a vacuum that can be used to suck up dirt. Robot always has an orientation (one of n, s, e, or w). Robot can move forward one step or turn right 90. The agent moves around a room, which is divided grid-like into a number of equally sized squares. Assume that the room is a 3 3 grid, and agent starts in square (0, 0) facing north. cis716-spring2006-parsons-lect14 39 cis716-spring2006-parsons-lect14 40

Illustrated: dirt (0,2) dirt (1,2)... (0,1)..... (2,2) (1,1) (2,1) Three domain predicates in this exercise: In(x, y) agent is at (x, y) Dirt(x, y) there is dirt at (x, y) Facing(d) the agent is facing direction d For convenience, we write rules as: φ(...) ψ(...) First rule deals with the basic cleaning action of the agent (0,0) (1,0) (2,0).. In(x, y) Dirt(x, y) Do(suck) (1) Hardwire the basic navigation algorithm, so that the robot will always move from (0, 0) to (0, 1) to (0, 2) then to (1, 2), (1, 1) and so on. cis716-spring2006-parsons-lect14 41 cis716-spring2006-parsons-lect14 42 Once agent reaches (2, 2), it must head back to (0, 0). In(0, 0) Facing(north) Dirt(0, 0) Do(forward) (2) In(0, 1) Facing(north) Dirt(0, 1) Do(forward) (3) In(0, 2) Facing(north) Dirt(0, 2) Do(turn) (4) In(0, 2) Facing(east) Do(forward) (5) Other considerations: adding new information after each move/action; removing old information. Suppose we scale up to 10 10 grid? Summary This lecture looked at predicate (or first order) logic. Predicate logic is a generalisation of propositional logic. The generalisation requires the use of quantifiers, and these need special rules for handling them when doing inference. We looked at how the proof rules for propositional logic need to be extended to handle quantifiers. Finally, we looked at how logic might be used to control an agent. cis716-spring2006-parsons-lect14 43 cis716-spring2006-parsons-lect14 44