KR: First Order Logic - Intro

Similar documents
First Order Logic (FOL)

J Propositional logic is declarative J Propositional logic is compositional: q meaning of B 1,1 P 1,2 is derived from meaning of B 1,1 and of P 1,2

First Order Logic (FOL)

Artificial Intelligence. Propositional logic

Artificial Intelligence Knowledge Representation I

Logical Agents (I) Instructor: Tsung-Che Chiang

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

First-Order Logic. Propositional logic. First Order logic. First Order Logic. Logics in General. Syntax of FOL. Examples of things we can say:

First-order logic. First-order logic. Logics in general. Outline. Syntax of FOL: Basic elements. Pros and cons of propositional logic

Intelligent Agents. First Order Logic. Ute Schmid. Cognitive Systems, Applied Computer Science, Bamberg University. last change: 19.

Logical Agents. September 14, 2004

Propositional Logic Not Enough

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

First-Order Logic. Chapter 8

Syntax. Notation Throughout, and when not otherwise said, we assume a vocabulary V = C F P.

CS 380: ARTIFICIAL INTELLIGENCE FIRST ORDER LOGIC. Santiago Ontañón

Announcements. Today s Menu

Agents that reason logically

Propositional Logic: Review

AI Programming CS S-09 Knowledge Representation

First-Order Logic. Chapter 8

Logic. (Propositional Logic)

First-Order Logic. Chapter 8

COMP219: Artificial Intelligence. Lecture 19: Logic for KR

INF5390 Kunstig intelligens. Logical Agents. Roar Fjellheim

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

Knowledge Representation using First-Order Logic (Part III)

Propositions. c D. Poole and A. Mackworth 2010 Artificial Intelligence, Lecture 5.1, Page 1

Knowledge Representation and Reasoning

Propositional Logic Part 1

Knowledge Representation Logic and Inference Propositional Logic First-order logic Vumpus World

COMP219: Artificial Intelligence. Lecture 19: Logic for KR

First Order Logic: Syntax and Semantics

Přednáška 12. Důkazové kalkuly Kalkul Hilbertova typu. 11/29/2006 Hilbertův kalkul 1

First-Order Logic Chap8 1. Pros and Cons of Prop. Logic

Conjunction: p q is true if both p, q are true, and false if at least one of p, q is false. The truth table for conjunction is as follows.

Proseminar on Semantic Theory Fall 2013 Ling 720 First Order (Predicate) Logic: Syntax and Natural Deduction 1

THE LANGUAGE OF FIRST-ORDER LOGIC (FOL) Sec2 Sec1(1-16)

Discrete Mathematics and Its Applications

(Part II) Reading: R&N Chapters 8, 9

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

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

Predicate Logic: Sematics Part 1

CS 380: ARTIFICIAL INTELLIGENCE INFERENCE IN PROPOSITIONAL LOGIC

CS 380: ARTIFICIAL INTELLIGENCE

CS 4700: Artificial Intelligence

Knowledge based Agents

Propositional Logic: Logical Agents (Part I)

MAI0203 Lecture 7: Inference and Predicate Calculus

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

Reasoning. Inference. Knowledge Representation 4/6/2018. User

First Order Logic. Philipp Koehn. 8 October 2015

G52DOA - Derivation of Algorithms Predicate Logic

First-order logic. Chapter 8. Chapter 8 1

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

cse 311: foundations of computing Fall 2015 Lecture 6: Predicate Logic, Logical Inference

2/2/2018. CS 103 Discrete Structures. Chapter 1. Propositional Logic. Chapter 1.1. Propositional Logic

3. The Logic of Quantified Statements Summary. Aaron Tan August 2017

Logical Agents. Santa Clara University

Section Summary. Predicate logic Quantifiers. Negating Quantifiers. Translating English to Logic. Universal Quantifier Existential Quantifier

Overview. Knowledge-Based Agents. Introduction. COMP219: Artificial Intelligence. Lecture 19: Logic for KR

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

Propositional and First-Order Logic

Logical Agents. Outline

n Empty Set:, or { }, subset of all sets n Cardinality: V = {a, e, i, o, u}, so V = 5 n Subset: A B, all elements in A are in B

Logic. Stephen G. Ware CSCI 4525 / 5525

Foundations of Artificial Intelligence

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

Foundations of Artificial Intelligence

Principles of Intelligent Systems: Situation Calculus

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

CS 771 Artificial Intelligence. Propositional Logic

First-Order Logic. Michael Rovatsos. University of Edinburgh R&N: February Informatics 2D

Automated Reasoning Lecture 5: First-Order Logic

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

Propositional Logic: Logical Agents (Part I)

7.5.2 Proof by Resolution

Lecture 8: (Predicate) First Order Logic

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

Predicate Calculus lecture 1

n logical not (negation) n logical or (disjunction) n logical and (conjunction) n logical exclusive or n logical implication (conditional)

Inference in Propositional Logic

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

Introduction to Sets and Logic (MATH 1190)

Logic Background (1A) Young W. Lim 12/14/15

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

First-order logic. Chapter 8. Chapter 8 1

Applied Logic. Lecture 1 - Propositional logic. Marcin Szczuka. Institute of Informatics, The University of Warsaw

Logic. Logic is a discipline that studies the principles and methods used in correct reasoning. It includes:

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

7. Propositional Logic. Wolfram Burgard and Bernhard Nebel

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

3. Only sequences that were formed by using finitely many applications of rules 1 and 2, are propositional formulas.

Computational Logic. Recall of First-Order Logic. Damiano Zanardini

Packet #2: Set Theory & Predicate Calculus. Applied Discrete Mathematics

RN, Chapter 8 Predicate Calculus 1

Guest Speaker. CS 416 Artificial Intelligence. First-order logic. Diagnostic Rules. Causal Rules. Causal Rules. Page 1

Introduction to Intelligent Systems

AI Principles, Semester 2, Week 2, Lecture 5 Propositional Logic and Predicate Logic

Transcription:

KR: First Order Logic - Intro First order logic (first order predicate calculus, predicate calculus) is a higherlevel logic than propositional logic The basic components of FOL are 1. Objects 2. Relations among the objects 3. Functions FOL allows for the representation of general rules about the objects that make up the world FOL does not make ontological commitments to time, categories, events,... It is a general language, similar to SQL in databases It can be used to represent any domain in a manner suitable to the agent/user It is the most studied and best understood KR language devised 1

KR: First Order Logic - Syntax The syntax of FOL is specified by the following BNF diagram: Sentence AtomicSentence ComplexSentence AtomicSentence P redicatesymbol P redicatesymbol(t erm,...) T erm = T erm ComplexSentence (Sentence) [Sentence] Sentence Sentence Sentence Sentence Sentence Sentence Sentence Sentence Sentence Quantif ier V ariable,... Sentence T erm F unctionsymbol(t erm,...) ConstantSymbol V ariable Quantif ier ConstantSymbol Symbol P redicatesymbol T rue F alse Symbol F unctionsymbol Symbol Symbol U pperletter LetterOrDigit... V ariable LowerLetter LetterOrDigit... LetterOrDigit Letter Digit Letter U pperletter LowerLetter U pperletter A B C... Z LowerLetter a b c... z Digit 0 1 2... 9 Precedence: () 2

Alternate representations KR: First Order Logic - Syntax N ot, Sentence And Sentence Sentence, Sentence&Sentence Or Sentence + Sentence, Sentence Sentence Implication Sentence Sentence, Sentence Sentence Biconditional Sentence Sentence, Sentence Sentence Quantif ication Quantif ier V ariable, Quantif ier V ariable,... Sentence Quantif ier (V ariable,...) Sentence (Quantif ier V ariable), (Quantif ier V ariable),... Sentence (Quantif ier V ariable... )Sentence 3

Models and interpretations KR: First Order Logic - Semantics A model in the FOL represents a possible world A model consists of a set of objects The domain of the model is the set of objects that the model contains These objects are called the domain elements domain 1 An interpretation I over domain D is a mapping of the constant, predicate, and function symbols to objects of D, relations that exist among those objects, and functions on those objects The mappings are the denotations of the symbols Models differ in terms of how many objects they contain, and the mappings of symbols Given a model with m constant symbols and n objects, there are m n interpretations for the model In FOL, the number of models is infinite Hence, model checking cannot be used for entailment Constant symbols Represent entities/objects in the domain of a model Some objects in the domain may not have symbols mapped to them, other objects may have several symbols mapped to them 4

KR: First Order Logic - Semantics (2) Function symbols Represent an anonymous/generic object from domain D Map D n D Syntactically, represented like function calls in most programming languages Object from D returned by the mapped function based on the values of its arguments assigned under I The arity of a function is the number of arguments it takes Function of arity n represented by n + 1 tuples: < t 1, t 2,..., t n, t n+1 > t i, 1 i n are arguments: objects (terms - see below) from D t n+1 is value of the function Functions in FOL are total functions They must return an object for all sets of arguments For sets that do not map to objects in the domain, there is a special object returned that represents the object for which this set of objects does not have a mapping Under normal usage, this issue can be ignored Variable symbols Mapped to objects in D Unlike other symbols, the mapping of these symbols are not fixed They are free to represent any and all domain elements Variable symbols may only appear in quantified expressions (see below) Terms These are expressions that refer to domain elements (e.g., constant symbols, variable symbols, or function expressions) Ground term has no variables in it 5

KR: First Order Logic - Semantics (3) Sentences, or Well Formed Formuli (wff) Sentences represent truth values 1. Atomic sentences (a) Predicate symbols Represent relations among objects Each predicate symbol of arity n is mapped to a relation with n arguments from D Predicate of arity n represented by n-tuples: < t 1, t 2,..., t n > A predicate expression predicate symbol(t 1, t 2,..., t n ) is true in a model if the relation to which the predicate symbol is mapped holds among the objects represented by its arguments D n T, F (b) Equality: t 1 = t 2 = is a special predicate More properly written as = (t 1, t 2 ) Is true if arguments represent the same object Represents the set of all 2-tuples in the domain whose values are the same: {< o 1, o 1 >, < o 2, o 2 >,...} 2. Complex sentences Semantics (same as for propositional logic): P Q P P Q P Q P Q P Q T T F T T T T T F F F T F F F T T F T T F F F T F F T T 6

KR: First Order Logic - Semantics (4) 3. Quantified sentences: Quantifiers are statements regarding collections of objects In the sentence Quantifier V ariable,... Sentence V ariable is quantified over Sentence is in the scope of the quantifier If all variables in the sentence are quantified over, the sentence is a closed sentence V ariable is mapped to any or all objects in the domain Universal quantification ( ) x P (x) is true in a given model D if P is true for all values of x D under all possible entended interpretations constructed from the interpretations given in the model, where each extended interpretation specifies a domain element to which x refers i.e., P (o 1 ) P (o 2 )... P (o n ) for all objects o i D under I Existential quantification ( ) x P (x) is true in a given model D if P is true for at least one value of x D under all possible entended interpretations constructed from the interpretations given in the model i.e., P (o 1 ) P (o 2 )... P (o n ) for all objects o i D under I De Morgan s laws for quantifiers: x P (x) x P (x) x P (x) x P (x) x P (x) x P (x) x P (x) x P (x) 7

Consider the following: KR: First Order Logic - Database Semantics P arent(f red, P ebbles) P arent(w ilma, P ebbles) This does not sufficiently represent the fact that P ebbles parents are F red and W ilma Must specify that W ilma and F red do not represent the same object: F red W ilma Must specify that W ilma and F red are the ONLY parents: x P arent(x, P ebbles) (x = F red x = W ilma) While the above is precise, it is getting a bit complex to represent something that is relatively simple Database semantics is an alternative semantics intended to simplify representation It involves the following: 1. Unique names assumption Every constant symbol represents a unique object This would preclude the need for stating F red W ilma above 2. Closed world assumption Atomic sentences whose truth values are not known are assumed to be false 3. Domain closure The only objects in the domain are those named by constants This and the closed world assumption would preclude the need for stating x P arent(x, P ebbles) (x = F red x = W ilma) Given database semantics, the original sentence above specifies a world in which only three objects exist: F red, W ilma and P ebbles Since there are nine possible two-element tuples (corresponding to the P arent relation), there are 2 9 models 8

KR: First Order Logic - Writing FOL Sentences To represent knowledge in FOL, must id 1. Constants 2. Functions 3. Predicates Predicates represent the rules that allow inferences to be made An axiom is a basic fact A definition specifies equivalence between 2 facts Specified in terms of biconditionals/logical equivalence Definitions are a subset of axioms Not all axioms represent definitions Simple facts are often expressed by atomic sentences Characteristics or properties about classes of objects are expressed using quantifiers A theorem is anything inferred from KB Adding theorems to the KB does not add new info They can always be inferred from the axioms/theorems from which they were derived What they do is decrease the amount of inference required to perform additional inferencing An independent axiom is one that cannot be derived from others 9

KR: First Order Logic - Writing FOL Sentences (2) Quantification - Writing facts about groups of objects 1. Universal These sentences used to represent general facts of the form If something is a P, then that something is Q e.g., All P are Q Written as x P (x) Q(x) The above is true if it is true for every object in the domain: P (o 1 ) Q(o 1 ) P (o 2 ) Q(o 2 )... P (o n ) Q(o n ) where o i represent all objects in the domain The above can be rewritten as P (o 1 ) Q(o 1 ) P (o 2 ) Q(o 2 )... P (o n ) Q(o n ) Remember, if P (o i ) is true, we can infer Q(q i ) using modus ponens, and P (o i ) Q(o i ) is true for x = o i If P (o j ) is false, P (o j ) Q(o j ) is still true Hence the above conjunction is true for all objects in the universe Common error: using instead of : Represents (x) (P (x) Q(x)) P (o 1 ) Q(o 1 ) P (o 2 ) Q(o 2 )... P (o n ) Q(o n ) If one object does not satisfy P (x), the above conjunction is false 10

2. Existential KR: First Order Logic - Writing FOL Sentences (3) Represent facts of the form There is a P that is Q Written as x P (x) Q(x)) Represents P (o 1 ) Q(o 1 ) P (o 2 ) Q(o 2 )... P (o n ) Q(o n ) True as long as one object satisfies one of the disjuncts Common error: using instead of Represents True for all objects in KB 3. Nesting quantifiers If x is P, and y is Q, then x R y Parentheses emphasize scope: x P (x) Q(x)) P (o 1 ) Q(o 1 ) P (o 2 ) Q(o 2 )... P (o n ) Q(o n ) x y P (x) Q(y) R(x, y) x( y (P (x) P (y) R(x, y))) Mixing universal and existential is tricky Order makes a difference x y s y x s Cannot collapse quantifiers for mixed quantification; e.g., x y s x, y s x y s x, y s Strongly recommended that use unique variable for each quantifier when nesting Note that variables cannot appear in a wff unless quantified 11

Representing percepts KR: First Order Logic - Writing FOL Sentences (4) P ercept(percept list, time); e.g., Actions P ercept([sunny, 65], 7) Action, or Action(Arg 1, Arg 2,...); e.g., P utdown, P ickup(r) Deriving facts from percepts This representation specifies that we can infer a fact when a particular stimulus is sensed t, s 1, s 2,... P ercept([s 1, s 2,..., StimulusOfConcern,...], t) P redicate(t); e.g., t, s 1, b 1, g, b 2, s 2 P ercept([s 1, Breeze, g, b 2, s 2 ], t) Breezy(t) Reflex behavior t P redicate(t) BestAction(Action, t); e.g., t Glitter(t) BestAction(Grab, t) The BestAction(Action, t) predicate represents the action that should be taken at time t Locations Use an array-like representation for grid-based environments; e.g., [x, y] Representing adjacency: x, y, a, b Adjacent([x, y], [a, b]) (x = a (y = b 1 y = b + 1)) (y = b (x = a 1 x = a + 1)) Representing the agent s location: At(Agent, [x, y], t) Representing the fact that something cannot be at two locations at once: x, s 1, s 2, t At(x, s 1, t) At(x, s 2, t) (s 1 = s 2 ) Associating a predicate with a location: s, t At(Agent, s, t) SensoryP redicate(t) SensoryDescriptionP redicate(s); e.g., s, t At(Agent, s, t) Breeze(t) Breezy(s) 12

Syntactic sugar KR: First Order Logic - Writing FOL Sentences (5) This refers to extensions to the basic syntax of FOL in order to make it easier to write or understand sentences For example, 1. Using x = y instead of = (x, y) or Equals(x, y) 2. Using x + 1 instead of Successor(x) Such extensions are acceptable as long as the semantics are unaffected The proper syntax can always be substituted back in the sentences for the sugar The KB Want KB to be as small as possisble to make inference efficient Minimal KB contains only independent axioms Adding some superfluous axioms may enhance inference as discussed above re theorems 13

KR: First Order Logic - Interacting with the KB To install facts into the KB, use T ELL: T ELL(KB, sentence); e.g., T ELL(KB, ( x Holding(x) HandEmpty)) These are called assertions To ask a question, use ASK: ASK(KB, sentence); e.g., ASK(KB, On(R, G, 5)), or ASK(KB, ( x Holding(x, 5)) Such queries will return true or false (yes/no) This is OK for the first query, but not the second, where the user most likely would want to know the value of x that satisfies the query The ASKV ARS function is used for this purpose: ASKV ARS(KB, sentence); e.g., ASKV ARS(KB, ( x Holding(x, 5)) ASKV ARS returns a binding list, or substitution of the form {var/binding}; e.g., {x/r} This signifies that object R when substituted for x makes the query sentence true 14

KR: First Order Logic - Knowledge Engineering KE is the process of constructing the KB A knowledge engineer determines the concepts in the domain that need to be represented Basic steps: 1. Id the task Determine the kinds of queries that will be posed Determine the kinds of knowledge that support the queries 2. Assemble the relevant knowledge This stage is known as knowledge acquisition The engineer must understand how the domain works and the knowledge relevant to the problem If the engineer is not an expert in the domain, an expert is usually consulted 3. Decide on a vocabulary of predicates, functions, and constants Decide on a set of symbols to be used Determine the mappings from the domain to the symbols This defines the ontology of the domain: The kinds of things that exist in the modeled domain 4. Encode general knowledge about the domain Specify the axioms 5. Encode a description of a problem instance 6. Pose queries 7. Debug the KB Most likely there will need to be additional axioms, inference rules (implications) will need to be added or rewritten, etc., in order to be able to make proper inferences 15

KR: First Order Logic and Higher Logics Predicate logic called first order because can quantify over first order entities (objects) Higher-order logics allow quantification over higher order entities (e.g., functions and predicates) For example: (x, y) (x = y) (p) (p(x) p(y))) (2 objects are equivalent if all of their properties are equivalent) Higher-order logics can represent more information than those of lower orders Inference mechanisms for higher-order logics not well understood 16