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

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

Propositional Logic Formal Syntax and Semantics. Computability and Logic

Going beyond propositional logic

Automated Reasoning. Natural Deduction in First-Order Logic

CDM First-Order Logic

CDM First-Order Logic

CMPS 277 Principles of Database Systems. Lecture #3

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

1.3 Primitive Recursive Predicates and Bounded Minimalization

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

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

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.

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

Introduction to Logic Programming

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

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

Part I Logic programming paradigm

SOFTWARE ENGINEERING DESIGN I

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

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):

CMPS 277 Principles of Database Systems. Lecture #4

CSC Discrete Math I, Spring Sets

Semantics. A. Demers Jan This material is primarily from Ch. 2 of the text. We present an imperative

Safe Stratified Datalog With Integer Order Does not Have Syntax

Programming Languages Third Edition

Computation Club: Gödel s theorem

Database Theory VU , SS Codd s Theorem. Reinhard Pichler

CMSC 330: Organization of Programming Languages. Formal Semantics of a Prog. Lang. Specifying Syntax, Semantics

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

Model Checking I Binary Decision Diagrams

CS112 Friday, September 12, 2008

Propositional Logic. Part I

Lecture 5 - Axiomatic semantics

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):

Software Engineering Lecture Notes

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

Lecture 1: Conjunctive Queries

Schema Mappings and Data Exchange

Semantics and Pragmatics of NLP Propositional Logic, Predicates and Functions

CSE 20 DISCRETE MATH. Fall

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

CSC 501 Semantics of Programming Languages

Comp 411 Principles of Programming Languages Lecture 7 Meta-interpreters. Corky Cartwright January 26, 2018

15-819M: Data, Code, Decisions

Z Notation. June 21, 2018

Functional programming with Common Lisp

Introductory logic and sets for Computer scientists

CSE20: Discrete Mathematics

Lecture 6: Arithmetic and Threshold Circuits

Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 6 Outline. Unary Relational Operations: SELECT and

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.

Warmup Problem. Translate the following sentence from English into Propositional Logic. I want to eat ice cream even though I am on a diet.

Recursive definition of sets and structural induction

Review Material: First Order Logic (FOL)

Fundamentals of Software Engineering

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

Formal Semantics of Programming Languages

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

First Order Predicate Logic CIS 32

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

CS357 Lecture: BDD basics. David Dill

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

Formal Semantics of Programming Languages

ACLT: Algebra, Categories, Logic in Topology - Grothendieck's generalized topological spaces (toposes)

Computer Science and Mathematics. Part I: Fundamental Mathematical Concepts Winfried Kurth

First-Order Logic PREDICATE LOGIC. Syntax. Terms

Introduction to Programming, Aug-Dec 2008

Back to the knights and knaves island

Th(N, +) is decidable

CITS2211 Discrete Structures Logic

1.3. Conditional expressions To express case distinctions like

Foundations of Databases

Introduction to Automata Theory. BİL405 - Automata Theory and Formal Languages 1

Introduction to Scheme

Connecting Statements. Today. First there was logic jumping forward.. ..and then proofs and then induction...

Formal Systems and their Applications

1 / 43. Today. Finish Euclid. Bijection/CRT/Isomorphism. Fermat s Little Theorem. Review for Midterm.

Pure Lambda Calculus. Lecture 17

CSE 20 DISCRETE MATH. Winter

The Relational Model

Software Paradigms (Lesson 6) Logic Programming

An Evolution of Mathematical Tools

Chapter 3: Propositional Languages

1 The language χ. Models of Computation

Semantics via Syntax. f (4) = if define f (x) =2 x + 55.

Declarative programming. Logic programming is a declarative style of programming.

(Refer Slide Time: 4:00)

LECTURE 17. Expressions and Assignment

Section 2.2: Introduction to the Logic of Quantified Statements

Logic and Databases. Phokion G. Kolaitis. UC Santa Cruz & IBM Research - Almaden

Introduction to Axiomatic Semantics

Formal Methods in Software Engineering 1

6.001 Notes: Section 6.1

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

SC/MATH Boolean Formulae. Ref: G. Tourlakis, Mathematical Logic, John Wiley & Sons, York University

Relational Calculus. Lecture 4B Kathleen Durant Northeastern University

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

Lectures 20, 21: Axiomatic Semantics

Today s Topics. What is a set?

LECTURE 8: SETS. Software Engineering Mike Wooldridge

Transcription:

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

Why Predicate Logic? Propositional logic is not powerful enough to express statements such as ffl For every number there is a prime larger than that number. ffl The limit of sin(x)=x as x approaches 0 is 1. ffl The function x 7! x 3 is a bijection. ffl The set of all real numbers is larger than the set of all natural numbers. In order to express such statements we need to enlarge the language of logic a bit. E.g., the first statement has the following structure: for x all there exists y a and x < y y is prime universal quantifier existential quantifier binary relation logical connective unary relation Note that we assume we are dealing with natural numbers. 2

The Language We keep all logical connectives. But we add ffl constants that denote individual objects, ffl variables that range over individual objects, ffl quantifiers that express for all and there exists, ffl function symbols that denote functions, ffl relation symbols that denote relations. Notation: ffl a, b, c, ::: for constants, and x, y, z, ::: for variables, ffl 8 for the universal quantifier, and 9 for the existential quantifier, ffl f, g, h, ::: for function symbols, and R, P, Q, ::: for relation symbols. ffl Always allow = for equality. Last example: 8x9y(R(x; y) ^ P (y)) 3

Example: Arithmetic To express statements in arithmetic, we use the language L(p; t; c 0 ;c 1 ;L)of type (2; 2; 0; 0; 2). ffl binary function symbols p and t (for addition and multiplication) ffl constants c 0 and c 1 (for 0 and 1) a binary relation symbol L (for the less-than relation) ffl Think p of t and as functions taking 2 c inputs, 0 c and 1 as taking no inputs; they all return an element of the domain as output. L takes two inputs, but returns a Boolean value as output. I We always assume that equality = can be used in our language. Now consider formulae such as 8x9y(L(x; y)) 9x8y(x = y _ L(x; y)) How do we make sense out of these? 8x(p(x; c 0 ) = x) 4

Example: Arithmetic (Cont.) We interpret x; y range over natural numbers p; t ordinary addition +, multiplication c 0 ;c 1 the natural numbers 0, 1 L the ordinary less-than relation < Then all these formulae are true. I Induction. Another true formula: 0 ) ^8x(R(x)!R(p(x; c 1 )))! 8xR(x) R(c Here we have added another unary relation R symbol to our language. I A false formula: 8x8y9z(p(x; z) = y) But if we change the variables to range over integers (or rationals, or reals), the last formula would be true! 5

L(p(c 1 ;c 1 );u)^l(c 0 ;x)^l(c 0 ;y)^l(c 0 ;z)! 8x8y8z8u :(p(e(x; u);e(y; u)) = e(z; u)) Example: Arithmetic (Cont.) I Primality. In the next formula, x is a free variable (not quantified over). 1 ;x)^8y; z(x = t(y; z)! x = y _ x = z) L(c If we x replace p(c by ;p(c 1 ;c 1 )) 1 we get a true statement. But if we x replace p(c by ;p(c 1 ;p(c 1 ;c 1 ))) 1 we get a false statement. I An impossibly hard formula. Let s add another binary function to our language: e for exponentiation. True or false? This is Fermat s Last Theorem. 6

Syntax and Semantics Predicate logic is very expressive, but we need to clarify several important items. I First give a precise definition of what a formula in predicate logic is. Same as with programming languages: we have to pin down the syntax exactly. I Then associate a clear definition of truth (usually called validity) with these formulae. Somewhat like the semantics of a programming language. To define validity, we have to define structures, domains over which a formula in predicate logic I can be interpreted. 7

Syntax: Terms and Formulae Every function symbol and relation symbol has a fixed number of arguments, its arity. Terms are defined inductively by Every constant and variable is a term. ffl If f is an n-ary function symbol, and t 1 ;::: ;t n are terms, then f (t 1 ;::: ;t n )is also a term. ffl An atomic formula is an expression of the form 1 ;::: ;t n ) R(t R where is an n-ary relation symbol, t and ;::: ;t n 1 are terms. Lastly, formulae are defined inductively by ffl Every atomic formula is a is a formula. ffl If ' and ψ are formulae, so are (:'), (' ^ ψ), (' _ ψ), and ('! ψ). ffl If ' is a formula and x a variable, then (9x') and (8x') are also formulae. 8

Notation As usual, we omit uneccesary parentheses and write 8x(R(x)! 9y S(x; y)) The intended meaning is: For x,ifx any has property R, then there exists y a such x that y and are related by S. Binary relation and function symbols are often written in infix notation, using standard mathematical symbols. E.g., instead p(x; z) of we might x + write z. One often contracts quantifiers of the same kind into one block. sloppy style 8x8y9z(p(x; z) = y) 8x; y9z(x + z = y) 9

Free Variables A variable that is not in the range of a quantifier is free (as opposed to bound). One often indicates free variables like so: 9x'(x; y) 8y9x'(x; y) only y is free nothing free '(x; y) x and y are free A formula without free variables is closed,orasentence. Let us always avoid clashes between free and bound variables. better: rename bound variable R(x) ^9x8yS(x; y) R(x) ^9z8yS(z; y) Same as in programming languages (global and local variables). 10

Semantics: Structures We need to describe the domain of discourse in predicate logic. I A structure is a set together with a collection of functions and relations on that set. = ha; f 1 ;f 2 ;::: ;R 1 ;R 2 ;:::i A Each function and relation has a fixed arity. A nullary function is just an element of A. A unary function maps element of A to elements of A. A binary function maps pairs of elements of A to elements of A. And so on. Likewise for the relations: A unary relation describes a property of elements of A. A binary relation describes a relationship between pairs of elements of A. I In some sense, mathematics is nothing but the study of various structures. 11

Structures (Cont.) We associate the function and relation symbols in formulae with real functions and relations in a structure (of the same arity). f function symbol ; f A a function in A R function symbol ; R A a relation in A Example: Consider arithmetic: Language L(p; t; c 0 ;c 1 ;L)of type (2; 2; 0; 0; 2). Can interpret I over any structure of (2; 2; 0; 0; type 2). The most important structure for arithmetic is = N ;+; ;0;1;<i N h the set of natural numbers together with the standard operations. So = +, t N =, c N N = 0 p 0, N = c 1 1, =<. L Variables range N over N. 12

Structures (Cont.) Hence, intuitively, N over, the L(c formula ;c 1 0 )is true. As 8x9y(L(x; is y)). But how about the primality formula '(x) L(c 1 ;x)^8y; z(x = t(y; z)! x = y _ x = z) The free variable x does not stand for any particular number, so we can not directly make sense out of this. Could also interpret our formulae over the structure of the real numbers (has same type I 2; 0; 0; 2)): (2; R = h ;+; ;0;1;<i Here, + refers to addition of reals, 0 is the real number zero, and so on. Note that y(l(x; y)! 9z(L(x; z) ^ L(z; y)) 8x; is true over the reals, but not over the natural numbers. On the other '(x) hand, is not interesting over R: there is x no that makes it true (think square root). 13

ffl t = c: then ff(t) = c A The Link: Assignments In propositional logic, we assign a truth value to each propositional variable, and extend the definition of truth value to all formulae. I An assignment (over A) associates variables with elements in A. Given an assignment ff, we can associate an element ff(t) in A with each term t. ffl t = x: then ff(t) = ff(x) ffl t = f (r 1 ;::: ;r n ): then ff(t) = f A (ff(r 1 );::: ;ff(r n )) Example: N,ifff(x) = Over 3, ff(t(x; p(c then ;c 1 ))) = 1 6. But ff(x) = 0 for we ff(t(x; p(c get ;c 1 ))) = 1 0. 14

Definition of Truth Finally, the definition of a truth value ff(') for every formula '. First without quantifiers. ' R(t ;::: ;t n 1 )is an atomic formula: ff(') then is true R iff holds on ff(t A );::: ;ff(t n ) ffl = 1 ψ^χ: then ff(') is true iff both ff(ψ) and ff(χ) are true. = ' ffl ffl ' = ψ _ χ: then ff(') is true iff at least one of ff(ψ) and ff(χ) is true. ffl ' = :ψ: then ff(') is true iff ff(ψ) is false. So far, this is essentially the same as in propositional logic except that we now have atomic formulae instead of propositional variables. Also note that this is a recursive definition, we are really using induction on the size of the formula. 15

Definition of Truth Quantifiers For an assignment ff, let us write ff[x=a] for the assignment that is the same as ff everywhere, except that ff[x=a](x) = a. ' = 9xψ: ffl ff(') Then is true iff there is a an A in such that for the ff assignment = ff[x=a] we have: ff 0 (ψ) is true. 0 ' = 8xψ: ffl ff(') Then is true iff for a all in A, ff assignments = ff[x=a] we have: ff 0 (ψ) is true. 0 Note that ff only needs to be defined on the free variables of ' to produce a value ff('), the values anywhere else do not matter. If ' is a sentence, ff can be totally undefined. 16

Models A formula ' is valid in A under assignment ff, in symbols ff(') iff is true. A ' formula is valid over A, in symbols A j= ff ' iff A j= ff ' for any assignment ff. A is said to be a model for '. A sentence is valid A j= ' iff it is valid over any structure. j= ' A formula is satisfiable iff there is some A structure and some ff assignment such A j= that ff '. In other words, 1 ;::: ;x n '(x 1 ;::: ;x n ) 9x has a model, x where ;::: ;x n 1 are the free variables of '. 17

Isn t this all circular? It looks like we are using for all to define what a universal quantifier means, and there is for existential quantifiers. True, but we are talking about syntactic objects, and define their meaning in terms of structures, which are not syntactic, they are real (in the world of mathematics). Think of this as a program: you can compute the truth value of a formula, as long as you can perform certain operations in the structure (evaluate f A, search over all elements, ::: ) IIf the structure in particular is finite, then we can actually carry out the computations. But over, say, N we cannot in general deal with quantifiers. Consider again the Fermat formula I (in sloppy notation) 8x; y; z; n(n > 2 ^ x; y; z > 0! x n + y n 6= z n ) 18

Valid Sentences Since validity means: holds over all structures one might wonder if there are any interesting valid sentences. Here are some important ones involving quantifiers: 8x8y'(x; y) () 8y8x'(x; y) 9x9y'(x; y) () 9y9x'(x; y) 9x8y'(x; y)! 8y9x'(x; y) Here are some important ones involving equality: 8x(x = x) 8x8y(x = y! y = x) 8x8y8z(x = y ^ y = z! x = z) 8x8y(x = y! (R(x), R(y))) 8x8y(x = y! f (x) = f (y)) 19