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

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

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

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

What is a Logic Program. Introduction to Logic Programming. Introductory Examples. Introductory Examples. Foundations, First-Order Language

Introduction to Logic Programming

Logic as a framework for NL semantics. Outline. Syntax of FOL [1] Semantic Theory Type Theory

Introductory logic and sets for Computer scientists

Going beyond propositional logic

Review Material: First Order Logic (FOL)

15-819M: Data, Code, Decisions

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

SOFTWARE ENGINEERING DESIGN I

Note that in this definition, n + m denotes the syntactic expression with three symbols n, +, and m, not to the number that is the sum of n and m.

Programming Languages Third Edition

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

Part I Logic programming paradigm

CSE 20 DISCRETE MATH. Fall

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

CSE20: Discrete Mathematics

CSC Discrete Math I, Spring Sets

CMPS 277 Principles of Database Systems. Lecture #3

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

Towards a Logical Reconstruction of Relational Database Theory

Automated Reasoning. Natural Deduction in First-Order Logic

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

Lecture 1: Conjunctive Queries

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

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

Lecture 4: January 12, 2015

LTCS Report. Concept Descriptions with Set Constraints and Cardinality Constraints. Franz Baader. LTCS-Report 17-02

CDM First-Order Logic

CDM First-Order Logic

CMPS 277 Principles of Database Systems. Lecture #4

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

Semantics and Pragmatics of NLP Propositional Logic, Predicates and Functions

First Order Predicate Logic CIS 32

CSC 501 Semantics of Programming Languages

Predicate Logic CHAPTER What This Chapter Is About

CSE 20 DISCRETE MATH. Winter

Lecture 4. First order logic is a formal notation for mathematics which involves:

Motivation. CS389L: Automated Logical Reasoning. Lecture 5: Binary Decision Diagrams. Historical Context. Binary Decision Trees

Lecture 9: Predicate Logic. First: Finish Propositional Logic in Haskell. Semantics in Haskell. Syntax In Haskell. CS 181O Spring 2016 Kim Bruce

LECTURE 8: SETS. Software Engineering Mike Wooldridge

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

First-Order Logic PREDICATE LOGIC. Syntax. Terms

THE PREDICATE CALCULUS

Complete Instantiation of Quantified Formulas in Satisfiability Modulo Theories. ACSys Seminar

Discrete Mathematics Lecture 4. Harper Langston New York University

Propositional Logic Formal Syntax and Semantics. Computability and Logic

Formal Methods in Software Engineering 1

Introduction to Denotational Semantics. Class Likes/Dislikes Survey. Dueling Semantics. Denotational Semantics Learning Goals. You re On Jeopardy!

Schema Mappings and Data Exchange

Range Restriction for General Formulas

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

A First-Order Logic with First-Class Types

Chapter 3: Propositional Languages

Lecture 5 - Axiomatic semantics

Proving the Correctness of Distributed Algorithms using TLA

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

Automatic Reasoning (Section 8.3)

CS 512, Spring 2017: Take-Home End-of-Term Examination

A set with only one member is called a SINGLETON. A set with no members is called the EMPTY SET or 2 N

Database Theory VU , SS Introduction: Relational Query Languages. Reinhard Pichler

Th(N, +) is decidable

Lecture 6,

From OCL to Propositional and First-order Logic: Part I

CSE 473 Lecture 12 Chapter 8. First-Order Logic. CSE AI faculty

CITS2211 Discrete Structures Logic

Semantics and Pragmatics of NLP

Logic Programming and Resolution Lecture notes for INF3170/4171

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

Formal Specification: Z Notation. CITS5501 Software Testing and Quality Assurance

Safe Stratified Datalog With Integer Order Does not Have Syntax

Introduction to Denotational Semantics. Brutus Is An Honorable Man. Class Likes/Dislikes Survey. Dueling Semantics

Contents. Chapter 1 SPECIFYING SYNTAX 1

Announcements. The current topic: Scheme. Review: BST functions. Review: Representing trees in Scheme. Reminder: Lab 2 is due on Monday at 10:30 am.

Proseminar on Semantic Theory Fall 2013 Ling 720 An Algebraic Perspective on the Syntax of First Order Logic (Without Quantification) 1

Finite Model Generation for Isabelle/HOL Using a SAT Solver

Set 7: Predicate logic Chapter 8 R&N. ICS 271 Fall 2015

Appendix 1. Description Logic Terminology

LOGIC AND DISCRETE MATHEMATICS

Typed First-order Logic

CMPSCI 250: Introduction to Computation. Lecture #1: Things, Sets and Strings David Mix Barrington 22 January 2014

Appendix 1. Description Logic Terminology

Formal Predicate Calculus. Michael Meyling

axiomatic semantics involving logical rules for deriving relations between preconditions and postconditions.

Lecture 6: Arithmetic and Threshold Circuits

We ve studied the main models and concepts of the theory of computation:

Recap Datalog Datalog Syntax Datalog Semantics. Logic: Datalog. CPSC 322 Logic 6. Textbook Logic: Datalog CPSC 322 Logic 6, Slide 1

Introduction to Scheme

Typed Lambda Calculus for Syntacticians

Dynamic Logic David Harel, The Weizmann Institute Dexter Kozen, Cornell University Jerzy Tiuryn, University of Warsaw The MIT Press, Cambridge, Massac

Natural Numbers. We will use natural numbers to illustrate several ideas that will apply to Haskell data types in general.

Today s Topics. What is a set?

Announcements. CS243: Discrete Structures. Strong Induction and Recursively Defined Structures. Review. Example (review) Example (review), cont.

EXTENSIONS OF FIRST ORDER LOGIC

Relational Database: The Relational Data Model; Operations on Database Relations

Propositional Calculus: Boolean Functions and Expressions. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

3.4 Deduction and Evaluation: Tools Conditional-Equational Logic

Foundations of Databases

Transcription:

Overview CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics Işıl Dillig So far: Automated reasoning in propositional logic. Propositional logic is simple and easy to automate, but not very expressive Today: First order logic, also known as relational logic, predicate logic, or first-order predicate calculus Much richer and more expressive, but does not admit completely automated reasoning (more on this later) Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 1/37 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 2/37 The Plan Constants in First-Order Logic Syntax and informal semantics (review, today s lecture) Formal semantics, model theory (today s lecture) Semantic argument method for FOL and properties (next lecture) Unification, clausal form (third lecture) Resolution and first-order theorem proving (fourth lecture) In propositional logic, we had two constants and In first order logic, three kinds of constants: 1. object constants 2. function constants 3. relation constants Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 3/37 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 4/37 Object Constants Function Constants Object constants refer to objects in a universe of discourse. Example: If our universe of discourse is people, object constants can be jack, jane, joe,... As a convention, we will use letters starting with a t or digits to denote object constants. Example: a, art, beth, 1 etc. refer to object constants. Function constants refer to functions Examples: motherof, ageof, plus, times,... Each function constant has an associated arity indicating its number of arguments Example: mother has arity 1 (unary), times has arity 2 (binary) etc. An object constant is really a special case of a function constant with arity 0 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 5/37 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 6/37 1

Relation Constants Terms A set of object, function, and relation constants C, F, R specifies a first-order language, written L(C, F, R) Relation constants refer to relations between or properties of objects Example: loves, betterthan, ishappy,... Each relation constant also has an associated arity Example: loves has arity 2, ishappy has arity 1 etc. C, F, R form the signature of the language. Terms t for a first order language are generated using C, F Basic terms: Any object constant in C and variables, denoted x, y, z,... Composite terms: f (t 1,..., t k ) where f F is function of arity k, and t 1,... t k are terms Examples: mary, x, sister(mary), price(x, macys), age(mother(y)),... Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 7/37 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 8/37 Formulas Formulas of L(C, F, R) are formed using the terms of this language, relation constants R, logical connectives,,,..., and quantifiers,. Atomic formula (predicate): Expression p(t 1,..., t n ) where p R (of arity n), and t 1,..., t n are terms of L(C, F, R) If F 1 and F 2 are formulas, then so is F 1 F 2 where is any binary connective If F is a formula, then so is F If F is a formula and x a variable, so are x.f (asserts facts about all objects) and x.f (asserts facts about some object) Important Reminder Predicates (e.g., p(x)) and function terms (e.g., f (x)) look similar, but they are very different! Function terms can be nested within each other and inside relation constants: f (f (x)), p(f (x)),... Predicates such as p(x) cannot be nested within function terms or other predicates! f (p(x)), p(p(x)) etc. not valid in FOL! Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 9/37 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 10/37 Quantifiers and Scoping Free vs. Bound Variable Example The subformula embedded inside a quantifier is called the scope of that quantifier. Example: y.(( x.p(x)) q(x, y)) An occurrence of a variable is bound if it is in the scope of some quantifier. An occurrence of a variable is free if it is not in the scope of any quantifiers. Consider the formula: y.(( x.p(x)) q(x, y)) Is variable y bound or free? Is first occurrence of x bound or free? What about second occurrence of x? Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 11/37 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 12/37 2

Closed, Open, and Ground Formulas A formula with no free variables is called a closed formula. A closed formula is also called a sentence. A formula containing free variables is said to be open. Example: Is the formula y.(( x.p(x)) q(x, y) closed or open? Is the formula y.(( x.p(x)) ( x.q(x, y))) a sentence? FOL example #1 Fermat s Last Theorem: No three positive integers a, b, c satisfy the equation a n + b n = c n for any integer n greater than 2. Assuming universe is integers, how do we express this theorem in FOL using function constant ˆ and relation constants >, =? A formula is said to be ground if it contains no variables. Example: p(a, f (b)) q(c) is ground. Is x.p(x) ground? Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 13/37 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 14/37 FOL example #2 FOL Example #3 Consider the axiom schema of unrestricted comprehension in naive set theory: There exists a set whose members are precisely those objects that satisfy predicate P Using predicates IsSet,, P, express this in FOL Consider the statement CS389L is taken only by those students who do not take CS388L Express thise sentence in FOL using binary relation constant takes, and unary relation constant student Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 15/37 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 16/37 One Last Example Semantics of First Order Logic Given binary relation friend, how do we say this in FOL? Every pair of friends has something in common In propositional logic, the concepts of interpretation, satisfiability, validity were all straightforward. In FOL, these concepts are a bit more involved... To give semantics to FOL, we need to talk about a universe of discourse (also sometimes called just universe or domain ) Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 17/37 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 18/37 3

Universe of Discourse A universe of discourse is a non-empty set of objects about which we want to say something Universe of discourse can be finite, countably infinite, or uncountably infinite, but not empty Example universes: First-Order Interpretations An interpretation for a first order language L(C, F, R) is a mapping I from C, F, R to objects in universe U I maps every c C to some member of U : I (c) U I maps every n-ary function constant f F to an n-ary function f I : U n U Set of non-negative integers Set of real numbers The set of suits in playing cards Students in this class I maps every n-ary relation constant p R to an n-ary relation p I such that p I U n Observe: A first-order interpretation does not talk about variables (only constants) Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 19/37 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 20/37 An Example Consider the first order language containing object constants {a, b, c}, binary function constant f, and ternary relation constant r. Universe of discourse: U = {1, 2, 3} Possible interpretation I : I (a) = 1, I (b) = 2, I (c) = 2 I (f ) = {1 2, 2 3, 3 3} I (r) = { 1, 2, 1, 2, 2, 1 } Another Example Consider the universe of discourse U = {, } For an object constant a, what are the possible interpretations? For a unary function constant f, what are the possible interpretations? For a unary relation constant r, what are all the possible interpretations? Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 21/37 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 22/37 First-Order Structures and Variable Assignments Evaluation of Terms A structure S = U, I for a first order language consists of a universe of discourse of U and an interpretation I. This is sometimes also called an algebra. A variable assignment σ (or assignment) to a FOL formula φ in a structure S = U, I is a mapping from variables in φ to an element of U. Example: Given U = {, }, a possible variable assignment for x: σ(x) = We define how to evaluate a term t under interpretation I and assignment σ, written I, σ (t) Object constants: I, σ (a) = I (a) Variable terms: I, σ (v) = σ(v) Function terms: I, σ (f (t 1,..., t k )) = I (f )( I, σ (t 1 ),..., I, σ (t k )) Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 23/37 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 24/37 4

Example: Evaluation of Terms Evaluation of Formulas, Notation Consider a first-order language containing object constants a, b and binary function f Consider universe {1, 2} and interpretation I : I (a) = 1 I (b) = 2 I (f ) = { 1, 1 2, 1, 2 2, 2, 1 1, 2, 2 1} Consider variable assignment σ : {x 2, y 1} Under I and σ, what do these terms evaluate to? We define evaluation of formula F under structure S = U, I and variable assignment σ. If F evaluates to true under U, I, σ, we write U, I, σ = F If F evaluates to false under U, I, σ, we write U, I, σ = F We define the semantics of = inductively. f (a, y) = f (x, b) = f (f (x, b), f (a, y)) = Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 25/37 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 26/37 Evaluation of Formulas, Bases Cases Example I: Evaluation of Formulas Consider a first-order language containing object constants a, b and unary function f, and binary relation constant p Base case I: Base case II: U, I, σ = U, I, σ = Consider universe {, } and interpretation I : I (a) = I (b) = I (f ) = {, } I (p) = {,,, } U, I, σ = p(t 1,..., t k ) iff I, σ (t 1 ),..., I, σ (t k ) I (p) Consider variable assignment σ : {x } Under U, I and σ, what do these formulas evaluate to? p(f (b), f (x)) = p(f (x), f (b)) = p(a, f (x)) = Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 27/37 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 28/37 Evaluation of Formulas II Variant of Variable Assignment Inductive semantics for boolean connectives: U, I, σ = F iff U, I, σ = F U, I, σ = F 1 F 2 iff U, I, σ = F 1 and U, I, σ = F 2 U, I, σ = F 1 F 2 iff I, σ = F 1 or U, I, σ = F 2 U, I, σ = F 1 F 2 iff, U, I, σ = F 1 or U, I, σ = F 2 U, I, σ = F 1 F 2 iff, U, I, σ = F 1 and U, I, σ = F 2, or U, I, σ = F 1 and I, σ = F 2 We still need to evaluate formulas containing quantifiers! But to do that, we first define an x-variant of a variable assignment. An x-variant of assignment σ, written σ[x c], is the assignment that agrees with σ for assignments to all variables except x and assigns x to c. Example: If σ : {x 1, y 2}, what is σ[x 3]? Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 29/37 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 30/37 5

Evaluation of Formulas II We can now give semantics to quantifiers: Universal quantifier: U, I, σ = x.f iff for all o U, U, I, σ[x o] = F Existential quantifier: U, I, σ = x.f iff there exists o U s.t U, I, σ[x o] = F Example III: Evaluation of Formulas Consider universe {, }, variable assignment σ : {x }, and interpretation I : I (a) = I (b) = I (f ) = {, } I (p) = {,,, } Under U, I and σ, what do these formulas evaluate to? x.p(x, a) = x.p(b, x) = x.p(a, x) = x. (p(a, x) p(b, x)) = x. (p(f (x), f (x)) p(x, x)) = Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 31/37 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 32/37 Satisfiability and Validity of First-Order Formulas Satisfiability and Validity Examples A first-order formula F is satisfiable iff there exists a structure S and variable assignment σ such that Otherwise, F is unsatisfiable. S, σ = F A structure S is a model of F, written S = F, if for all variable assignments σ X U, S, σ = F. A first-order formula F is valid, written = F if for all structures S, S, σ = F Is the formula x. y.p(x, y) satisfiable? Satisfying interpretation: Is this formula valid? Falsifying interpretation: Is the formula x.(p(x, x) y.p(x, y)) valid? Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 33/37 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 34/37 More Satisfiability and Validity Examples Understanding Models Is the formula ( x.p(x)) p(x) sat, unsat, or valid? Satisfying U, I, σ: Falsifying interpretation: Is the formula ( x.p(x)) p(x) sat, unsat, or valid? What about ( x.(p(x) q(x))) ( x.(p(x) q(x)))? Satisfying interpretation: Recall: A structure S is a model of a formula if for all σ, S, σ = F Consider a formula F such that S, σ = F. Is S a model F? Consider a sentence F such that S, σ = F. Is S a model F? Consider a ground formula F such that S, σ = F. Is S a model of F? Falsifying interpretation: Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 35/37 Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 36/37 6

Summary Today: Syntax and formal semantics of FOL Next lecture: Semantic argument method for FOL Properties of first-order logic: decidability results, compactness Işıl Dillig, CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics 37/37 7