University of Aberdeen, Computing Science CS2013 Predicate Logic 4 Kees van Deemter

Similar documents
ICS141: Discrete Mathematics for Computer Science I

Propositional Logic Not Enough

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

Introduction to Sets and Logic (MATH 1190)

Predicate Calculus lecture 1

Transparencies to accompany Rosen, Discrete Mathematics and Its Applications Section 1.3. Section 1.3 Predicates and Quantifiers

Discrete Mathematics and Its Applications

Bits and Bit Operations. Today s topics

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

Predicate Logic. CSE 191, Class Note 02: Predicate Logic Computer Sci & Eng Dept SUNY Buffalo

Topic #3 Predicate Logic. Predicate Logic

COMP9414: Artificial Intelligence First-Order Logic

Before you get started, make sure you ve read Chapter 1, which sets the tone for the work we will begin doing here.

First order Logic ( Predicate Logic) and Methods of Proof

Lecture Predicates and Quantifiers 1.5 Nested Quantifiers

Lecture Notes on DISCRETE MATHEMATICS. Eusebius Doedel

Examples: P: it is not the case that P. P Q: P or Q P Q: P implies Q (if P then Q) Typical formula:

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

Section Summary. Predicates Variables Quantifiers. Negating Quantifiers. Translating English to Logic Logic Programming (optional)

Automated Reasoning Lecture 5: First-Order Logic

Introduction to Predicate Logic Part 1. Professor Anita Wasilewska Lecture Notes (1)

Discrete Mathematics & Mathematical Reasoning Predicates, Quantifiers and Proof Techniques

Section Summary. Section 1.5 9/9/2014

Announcements CompSci 102 Discrete Math for Computer Science

Review. Propositional Logic. Propositions atomic and compound. Operators: negation, and, or, xor, implies, biconditional.

Foundations of Logic Programming

COMP 2600: Formal Methods for Software Engineeing

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

PREDICATE LOGIC. Schaum's outline chapter 4 Rosen chapter 1. September 11, ioc.pdf

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

Proposi'onal Logic Not Enough

Overview. CS389L: Automated Logical Reasoning. Lecture 7: Validity Proofs and Properties of FOL. Motivation for semantic argument method

Math Fundamentals of Higher Math

Discrete Structures for Computer Science

Predicates and Quantifiers. CS 231 Dianna Xu

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

ICS141: Discrete Mathematics for Computer Science I

1.3 Predicates and Quantifiers

COMP 182 Algorithmic Thinking. Proofs. Luay Nakhleh Computer Science Rice University

Logical Operators. Conjunction Disjunction Negation Exclusive Or Implication Biconditional

Discrete Mathematics and Probability Theory Spring 2014 Anant Sahai Note 1

Proving logical equivalencies (1.3)

Recall that the expression x > 3 is not a proposition. Why?

ICS141: Discrete Mathematics for Computer Science I

Predicate Calculus - Syntax

Why Learning Logic? Logic. Propositional Logic. Compound Propositions

Propositional logic (revision) & semantic entailment. p. 1/34

Predicates, Quantifiers and Nested Quantifiers

MAT2345 Discrete Math

Mathematical Logic Part Three

Philosophy 240 Symbolic Logic Russell Marcus Hamilton College Fall 2014

LECTURE NOTES DISCRETE MATHEMATICS. Eusebius Doedel

Lecture 3 : Predicates and Sets DRAFT

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

Statements, Implication, Equivalence

AAA615: Formal Methods. Lecture 2 First-Order Logic

Formal Logic: Quantifiers, Predicates, and Validity. CS 130 Discrete Structures

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

Solutions to Homework I (1.1)

Logic (3A) Young W. Lim 12/5/13

MATH 22 INFERENCE & QUANTIFICATION. Lecture F: 9/18/2003

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

Advanced Topics in LP and FP

First order logic. Example The deduction of statements: This reasoning is intuitively correct. Every man is mortal. Since Ade is a man, he is mortal.

Tools for reasoning: Logic. Ch. 1: Introduction to Propositional Logic Truth values, truth tables Boolean logic: Implications:

Chapter 1, Part II: Predicate Logic

Discrete Mathematics and Probability Theory Fall 2012 Vazirani Note 1

Chapter 1 Elementary Logic

Marie Duží

Logic: The Big Picture


Bound and Free Variables. Theorems and Proofs. More valid formulas involving quantifiers:

Today. Proof using contrapositive. Compound Propositions. Manipulating Propositions. Tautology

Adam Blank Spring 2017 CSE 311. Foundations of Computing I

Chapter 16. Logic Programming. Topics. Logic Programming. Logic Programming Paradigm

LECTURE NOTES DISCRETE MATHEMATICS. Eusebius Doedel

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

Predicate Logic: Sematics Part 1

Interpretations of PL (Model Theory)

CA320 - Computability & Complexity

AMTH140 Lecture 8. Symbolic Logic

Exercises 1 - Solutions

Propositional Logic: Logical Agents (Part I)

Part I: Propositional Calculus

CSC384: Intro to Artificial Intelligence Knowledge Representation II. Required Readings: 9.1, 9.2, and 9.5 Announcements:

1.1 Language and Logic

Predicate Calculus - Semantics 1/4

Predicate Calculus. Lila Kari. University of Waterloo. Predicate Calculus CS245, Logic and Computation 1 / 59

Notes on Propositional and First-Order Logic (CPSC 229 Class Notes, January )

2. Use quantifiers to express the associative law for multiplication of real numbers.

Predicate Calculus. Formal Methods in Verification of Computer Systems Jeremy Johnson

Logical reasoning - Can we formalise our thought processes?

About the course. CSE 321 Discrete Structures. Why this material is important. Topic List. Propositional Logic. Administration. From the CSE catalog:

Final Exam (100 points)

CITS2211 Discrete Structures Proofs

G52DOA - Derivation of Algorithms Predicate Logic

COMP9414: Artificial Intelligence Propositional Logic: Automated Reasoning

1.1 Language and 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.

CSE 311: Foundations of Computing. Lecture 6: More Predicate Logic

Transcription:

University of Aberdeen, Computing Science CS2013 Predicate Logic 4 Kees van Deemter 01/11/16 Kees van Deemter 1

First-Order Predicate Logic (FOPL) Lecture 4 Making numerical statements: >0, <2, >1,>2,1,2 Prime numbers, Goldberg s conjecture Decidability and PROLOG 01/11/16 Kees van Deemter 2

Lecture IV The expressive power of FOPL (informal treatment) Making numerical statements Remarks about decidability Crash course in PROLOG 01/11/16 Kees van Deemter 3

Topic #3 Predicate Logic Some common shorthands Sometimes the universe of discourse is restricted within the quantification, e.g., x>0 P(x) is shorthand for For all x that are greater than zero, P(x). How would you write this in formal notation? 01/11/16 Kees van Deemter 4

Topic #3 Predicate Logic Some common shorthands Sometimes the universe of discourse is restricted within the quantification, e.g., x>0 P(x) is shorthand for For all x that are greater than zero, P(x). = x (x>0 P(x)) 01/11/16 Kees van Deemter 5

Topic #3 Predicate Logic Some common shorthands Sometimes the universe of discourse is restricted within the quantification, e.g., x>0 P(x) is shorthand for For all x that are greater than zero, P(x). = x (x>0 P(x)) x>0 P(x) is shorthand for There is an x greater than zero such that P(x). = x (x>0 P(x)) 01/11/16 Kees van Deemter 6

Topic #3 Predicate Logic Some common shorthands Consecutive quantifiers of the same type can be combined: xyz P(x,y,z) def x y z P(x,y,z) xyz P(x,y,z) def x y z P(x,y,z) 01/11/16 Kees van Deemter 7

Theorems about logic We are studying logical languages/calculi to allow you to use them (better) Logicians study logical languages/calculi to understand their limitations Meta-theorems can, e.g., say things like cannot be expressed in predicate logic 01/11/16 Kees van Deemter 8

Theorems about logic About propositional logic, we asked What types of things can we express? How many connectives do we need? About predicate logic, logicians ask similar questions. For example, are these two quantifiers enough to be able to say everything? This is a question about the expressive power of predicate logic 01/11/16 Kees van Deemter 9

Example: one As per their name, quantifiers can be used to express that a predicate is true of a given quantity (number) of objects. Example: Can predicate logic say there exists at most one object with property P? 01/11/16 Kees van Deemter 10

Example: at most one Example: Can predicate logic say there exists at most one object with property P? 01/11/16 Kees van Deemter 11

Example: at most one Example: Can predicate logic say there exists at most one object with property P? Yes (provided we have equality): x y ((P(x) P(y)) x= y) 01/11/16 Kees van Deemter 12

Example: one Can predicate logic say there exists exactly one object with property P? 01/11/16 Kees van Deemter 13

Example: one Can predicate logic say there exists exactly one object with property P? xp(x) x y((p(x) P(y)) x= y) There exist x such that P(x) and There exists at most one x such that P(x) Abbreviation:!x P(x) ( there exists exactly one x such that P(x) ) 01/11/16 Kees van Deemter 14

Example: one Another way to write this: x (P(x) y (P(y) y x)) There is an x such that P(x), such that there is no y such that P(y) and y x. x binds x throughout the conjunction: x (P(x) y (P(y) y x)) 01/11/16 Kees van Deemter 15

At least two Can predicate logic say there exist at least two objects with property P? 01/11/16 Kees van Deemter 16

At least two Can predicate logic say there exist at least two objects with property P? Yes: x y ((P(x) P(y)) x y) Incorrect would be xp(x) y(p(y) x y), (where x occurs free, and which therefore does not express a proposition) 01/11/16 Kees van Deemter 17

Exactly two Can predicate logic say there exist exactly two objects with property P? 01/11/16 Kees van Deemter 18

Exactly wo Can predicate logic say there exist exactly two objects with property P? Yes: x y (P(x) P(y) x y z (P(z) (z= x z= y) )) 01/11/16 Kees van Deemter 19

What s wrong with x y (P(x) P(y) x y) z (P(z) (z= x z= y )) as a formalisation of exactly two? 01/11/16 Kees van Deemter 20

What s wrong with x y (P(x) P(y) x y) z (P(z) (z= x z= y )) as a formalisation of exactly two? This is a conjunction of two separate propositions. As a result, x and y are not bound, so this is not even a proposition 01/11/16 Kees van Deemter 21

infinitely many Can predicate logic say there exist finitely many objects with property P? No! [This follows from the so-called Compactness Theorem: An infinite set S of formulas has a model iff every finite subset of S has a model ] (Proof in the next Lecture) 01/11/16 Kees van Deemter 22

finitely many How about infinitely many? 01/11/16 Kees van Deemter 23

finitely many How about infinitely many? Suppose there existed a formula ϕ = there exist only finitely many x such that so and so Then ϕ = there exist infinitely many x such that so and so We know that such a formula does not exist So, also ϕ does not exist 01/11/16 Kees van Deemter 24

(Of course if we allow infinite conjunctions then all this can be expressed:!x P(x) 2!x P(x) 3!x P(x) ) 01/11/16 Kees van Deemter 25

Can predicate logic say most objects have property P? No! [This follows from the Compactness Theorem as well. Again, this is unless we allow infinitely long disjunctions.] Can predicate logic say many objects have property P? No, only precisely defined quantities 01/11/16 Kees van Deemter 26

Topic #3 Predicate Logic Number Theory Examples Let u.d. = the natural numbers 0, 1, 2, What do the following mean? x (E(x) ( y x=2y)) x (P(x) (x>1 yz x=yz y 1 z 1)) 01/11/16 Kees van Deemter 27

Topic #3 Predicate Logic more Number Theory Examples Let u.d. = the natural numbers 0, 1, 2, A number x has the property E if and only if it is equal to 2 times some other number. (even!) x (E(x) ( y x=2y)) A number has P, iff it s greater than 1 and it isn t the product of any non-unity numbers. (prime!) x (P(x) (x>1 yz x=yz y 1 z 1)) 01/11/16 Kees van Deemter 28

Topic #3 Predicate Logic Goldbach s Conjecture (unproven) Using E(x) and P(x) from previous slide, x( [x>2 E(x)] p q P(p) P(q) p+q = x). 01/11/16 Kees van Deemter 29

Topic #3 Predicate Logic Goldbach s Conjecture (unproven) Using E(x) and P(x) from previous slide, x( [x>2 E(x)] p q P(p) P(q) p+q = x). Every even number greater than 2 is the sum of two primes. 01/11/16 Kees van Deemter 30

Decidability We ve shown you two ways of checking propositional-logic equivalencies: 1. Checking truth tables 2. Using equivalence laws You ve seen how (1) can be done algorithmically. This shows that checking propositional logic equivalence is decidable 01/11/16 Kees van Deemter 31

Decidability Checking proplog equivalence is decidable Checking predlog equivalence is not decidable Therefore, theorem proving will always remain an art (for both computers and humans) Some fragments of predlog are decidable. Example 1: Monadic FOPL (i.e., limited to 1- place predicates. No relations). See CS3518. Example 2: PROLOG. 01/11/16 Kees van Deemter 32

Bonus Topic: Logic Programming Some programming languages are based entirely on (a part of) predicate logic The most famous one is called Prolog. A Prolog program is a set of propositions ( facts ) and ( rules ) in predicate logic. The input to the program is a query proposition. Want to know if it is true or false. The Prolog interpreter does some automated deduction to determine whether the query follows from the facts. 01/11/16 Kees van Deemter 33

Facts in Prolog A fact in Prolog represents a simple, noncompound proposition in predicate logic. E.g., likes(john,mary) Lowercase symbols are used for constants and predicates, uppercase is used for variables. 01/11/16 Kees van Deemter 34

Rules in Prolog A rule in Prolog represents a universally quantified proposition of the general form x y (P(x,y) Q(x)), where x and y are variables, P a possibly compound predicate, and Q an atomic proposition. In Prolog: q(x) :- p(x,y). i.e., the, quantifiers are implicit. Example: likable(x) :- likes(y,x). 01/11/16 Kees van Deemter 35

Rules in Prolog Note that x y (P(x,y) Q(x)) is equivalent to x(( y P(x,y) Q(x)) In other words, Q(x) holds if you can find a y such that P(x,y) 01/11/16 Kees van Deemter 36

Conjunction and Disjunction Logical conjunction is encoded using multiple comma-separated terms in a rule. Logical disjunction is encoded using multiple rules. E.g., x ((P(x) Q(x)) R(x)) S(x) can be rendered in Prolog as: s(x) :- p(x),q(x) s(x) :- r(x) 01/11/16 Kees van Deemter 37

Deduction in Prolog When a query is input to the Prolog interpreter, it searches its database to determine if the query can be proven true from the available facts. if so, it returns yes, if not, no (!) If the query contains any variables, all values that make the query true are printed. 01/11/16 Kees van Deemter 38

Simple Prolog Example An example input program: likes(john,mary). likes(mary,fred). likes(fred,mary). likable(x) :- likes(y,x). An example query:? likable(z) returns:... 01/11/16 Kees van Deemter 39

Simple Prolog Example An example input program: likes(john,mary). likes(mary,fred). likes(fred,mary). likable(x) :- likes(y,x). An example query:? likable(z) returns: mary fred 01/11/16 Kees van Deemter 40

Relation between PROLOG and Predicate Logic PROLOG cannot use all predicate logic formulas. (It covers a decidable fragment of predicate logic.) It uses negation as failure Based on these limitations, PROLOG-based deduction is decidable. PROLOG is more than just logic (I/O, cut!), but logic is its hard core. 01/11/16 Kees van Deemter 41

01/11/16 Kees van Deemter 42