Mathematics for Computing Science

Slides:



Advertisements
Similar presentations
Artificial Intelligence
Advertisements

Predicate Logic Colin Campbell. A Formal Language Predicate Logic provides a way to formalize natural language so that ambiguity is removed. Mathematical.
Completeness and Expressiveness
First-Order Logic.
Computer Science CPSC 322 Lecture 25 Top Down Proof Procedure (Ch 5.2.2)
Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen CS2013 Mathematics.
University of Aberdeen, Computing Science CS2013 Mathematics for Computing Science Adam Wyner Slides adapted from Michael P. Frank ’ s course based on.
Possible World Semantics for Modal Logic
Lecture 11: Datalog Tuesday, February 6, Outline Datalog syntax Examples Semantics: –Minimal model –Least fixpoint –They are equivalent Naive evaluation.
1 A formula in predicate logic An atom is a formula. If F is a formula then (~F) is a formula. If F and G are Formulae then (F /\ G), (F \/ G), (F → G),
CS 285- Discrete Mathematics
Inference and Reasoning. Basic Idea Given a set of statements, does a new statement logically follow from this. For example If an animal has wings and.
Propositional Logic CMSC 471 Chapter , 7.7 and Chuck Dyer
CS2013 Mathematics for Computing Science Adam Wyner University of Aberdeen Computing Science Slides adapted from Michael P. Frank ' s course based on the.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 1: (Part 2): The Foundations: Logic and Proofs.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
L41 Lecture 2: Predicates and Quantifiers.. L42 Agenda Predicates and Quantifiers –Existential Quantifier  –Universal Quantifier 
RMIT University; Taylor's College This is a story about four people named Everybody, Somebody, Anybody and Nobody. There was an important job to be done.
CSE 425: Logic Programming I Logic and Programs Most programs use Boolean expressions over data Logic statements can express program semantics –I.e., axiomatic.
From Chapter 4 Formal Specification using Z David Lightfoot
Proof by Deduction. Deductions and Formal Proofs A deduction is a sequence of logic statements, each of which is known or assumed to be true A formal.
EE1J2 - Slide 1 EE1J2 – Discrete Maths Lecture 6 Limitations of propositional logic Introduction to predicate logic Symbols, terms and formulae, Parse.
CSE115/ENGR160 Discrete Mathematics 01/20/11 Ming-Hsuan Yang UC Merced 1.
Discrete Mathematics and its Applications
1 First order theories. 2 Satisfiability The classic SAT problem: given a propositional formula , is  satisfiable ? Example:  Let x 1,x 2 be propositional.
Adapted from Discrete Math
First Order Logic. This Lecture Last time we talked about propositional logic, a logic on simple statements. This time we will talk about first order.
Predicates and Quantifiers
CS2013 Maths for Computing Science Proof (part b) Adam Wyner University of Aberdeen Computing Science.
Module #1 - Logic 8/28/2015Michael Frank / Kees van Deemter1 Remember: I. Construct a model where 1 and 4 are true, while 2 and 3 are false Let the u.d.
Logical Equivalence & Predicate Logic
Discrete Mathematics and Its Applications
MATH 224 – Discrete Mathematics
 Predicate: A sentence that contains a finite number of variables and becomes a statement when values are substituted for the variables. ◦ Domain: the.
Declarative vs Procedural Programming  Procedural programming requires that – the programmer tell the computer what to do. That is, how to get the output.
Chapter 1, Part II: Predicate Logic With Question/Answer Animations.
CMPF144 FUNDAMENTALS OF COMPUTING THEORY Module 5: Classical Logic.
Advanced Topics in Propositional Logic Chapter 17 Language, Proof and Logic.
First Order Logic Lecture 2: Sep 9. This Lecture Last time we talked about propositional logic, a logic on simple statements. This time we will talk about.
Slides adapted from Michael P. Frank ' s course based on the text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen University.
Course Overview and Road Map Computability and Logic.
Chapter 1, Part II: Predicate Logic With Question/Answer Animations.
Copyright © Curt Hill Quantifiers. Copyright © Curt Hill Introduction What we have seen is called propositional logic It includes.
Propositional Calculus CS 270: Mathematical Foundations of Computer Science Jeremy Johnson.
CompSci 102 Discrete Math for Computer Science
Lecture 4: Predicates and Quantifiers; Sets.
Automated Reasoning Early AI explored how to automated several reasoning tasks – these were solved by what we might call weak problem solving methods as.
For Wednesday Read chapter 9, sections 1-3 Homework: –Chapter 7, exercises 8 and 9.
CS 285- Discrete Mathematics Lecture 4. Section 1.3 Predicate logic Predicate logic is an extension of propositional logic that permits concisely reasoning.
For Friday Read chapter 8 Homework: –Chapter 7, exercises 2 and 10 Program 1, Milestone 2 due.
CS2013 Mathematics for Computing Science Adam Wyner University of Aberdeen Computing Science Slides adapted from Michael P. Frank ' s course based on the.
Predicate Logic One step stronger than propositional logic Copyright © Curt Hill.
Albert Gatt LIN3021 Formal Semantics Lecture 3. Aims This lecture is divided into two parts: 1. We make our first attempts at formalising the notion of.
1 First Order Logic CS 171/271 (Chapter 8) Some text and images in these slides were drawn from Russel & Norvig’s published material.
Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View Basic Concepts and Background.
PREDICATES AND QUANTIFIERS COSC-1321 Discrete Structures 1.
Mathematics for Comter I Lecture 3: Logic (2) Propositional Equivalences Predicates and Quantifiers.
1 Section 7.1 First-Order Predicate Calculus Predicate calculus studies the internal structure of sentences where subjects are applied to predicates existentially.
6/11/2016 Linear Resolution and Introduction to First Order Logic Michael Leuschel Softwaretechnik und Programmiersprachen Lecture 5.
Chapter 2 1. Chapter Summary Sets (This Slide) The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions.
Chapter 1 Logic and proofs
CENG 424-Logic for CS Introduction Based on the Lecture Notes of Konstantin Korovin, Valentin Goranko, Russel and Norvig, and Michael Genesereth.
Chapter 7. Propositional and Predicate Logic
Discrete Math - Module #1 - Logic
Computer Security: Art and Science, 2nd Edition
Chapter 7. Propositional and Predicate Logic
Predicates and Quantifiers
This Lecture Substitution model
Propositional Logic CMSC 471 Chapter , 7.7 and Chuck Dyer
Copyright © Cengage Learning. All rights reserved.
Presentation transcript:

Mathematics for Computing Science Fall 2013 University of Aberdeen, Computing Science CS2013 Mathematics for Computing Science Adam Wyner Slides adapted from Michael P. Frank's course based on the text Discrete Mathematics & Its Applications (5th Edition) by Kenneth H. Rosen (c)2001-2002, Frank, van Deemter, and Wyner

Mathematics for Computing Science Fall 2013 Predicate Logic III (c)2001-2002, Frank, van Deemter, and Wyner

Frank / van Deemter / Wyner Agenda Formal Evaluation Nested Quantifiers Quantifier equivalences Defining (or not) other quantifiers Fall 2013 Frank / van Deemter / Wyner

Formal Evaluation - B(bill') Suppose M1 = (D,I) where D={bill, jill, mary} I(jill') = jill, I(mary') = mary, I(bill') = bill, I(B)={bill, jill} I(G)={jill}, I(A)={(bill, jill), (mary,bill), (jill, jill)} B(bill') is T in M1 iff I(bill')  I(B) is T in M1 iff bill  {bill, jill} is T in M1. Work from bottom to top. Fall 2013 Frank / van Deemter / Wyner

Formal Evaluation - x B(x) Suppose M1 = (D,I) where D={bill, jill, mary} I(jill') = jill, I(mary') = mary, I(bill') = bill, I(B)={bill, jill} I(G)={jill}, I(A)={(bill, jill), (mary,bill), (jill, jill)} x B(x) is T in M1 iff there is an a where I(a)  D such that B(x)(x := a) is T in M1 where (x := bill'), B(x) is B(bill'). B(bill') is T in M1 iff.... where (x := jill'), B(x) is B(jill'). B(jill') is T in M1 iff.... where (x := mary'), B(x) is B(mary'). B(mary') is T in M1 iff.... Look in the 'where' clauses. Is there some a that makes B(x)(x := a) is T in M1? Work from bottom to top. Fall 2013 Frank / van Deemter / Wyner

Formal Evaluation - x B(x) Suppose M1 = (D,I) where D={bill, jill, mary} I(jill') = jill, I(mary') = mary, I(bill') = bill, I(B)={bill, jill} I(G)={jill}, I(A)={(bill, jill), (mary,bill), (jill, jill)} x B(x) is T in M1 iff for every a where I(a)  D, B(x)(x := a) is T in M1 where (x := bill'), B(x) is B(bill'). B(bill') is T in M1 iff.... where (x := jill'), B(x) is B(jill'). B(jill') is T in M1 iff.... where (x := mary'), B(x) is B(mary'). B(mary') is T in M1 iff.... Look in the 'where' clauses. Is it so that for every a, B(x)(x := a) is T in M1? Work from bottom to top. Fall 2013 Frank / van Deemter / Wyner

Formal Evaluation - x (G(x)  B(x)) Suppose M1 = (D,I) where D={bill, jill, mary} I(jill') = jill, I(mary') = mary, I(bill') = bill, I(B)={bill, jill} I(G)={jill}, I(A)={(bill, jill), (mary,bill), (jill, jill)} x (G(x)  B(x)) is T in M1 iff for every a where I(a)  D, (G(x)  B(x))(x := a) is T in M1 where (x:=bill'), (G(x)  B(x)) is (G(bill')  B(bill')); (G(bill')  B(bill')) is T in M1 iff G(bill') is F in M1 or B(bill') is T in M1. where (x:=jill'), (G(x)  B(x)) is (G(jill')  B(jill')); (G(jill')  B(jill')) is T in M1 iff G(jill') is F in M1 or B(jill') is T in M1. where (x:=mary'), (G(x)  B(x)) is (G(jill')  B(jill')); (G(jill')  B(jill')) is T in M1 iff G(jill') is F in M1 or B(jill') is T in M1. Are all true? Fall 2013 Frank / van Deemter / Wyner

Mathematics for Computing Science Fall 2013 Nested Quantifiers Example: Let D for x and y be people. Let L(x,y) = x likes y (a predicate with 2 free variables) y L(x,y) = "There is someone whom x likes" = "x likes someone". (A predicate with 1 free variable, x) x (y L(x,y)) = "Everyone has someone whom they like" = "everyone likes someone". (A real proposition; no free variables left) Fall 2013 Frank / van Deemter / Wyner (c)2001-2002, Frank, van Deemter, and Wyner

Frank / van Deemter / Wyner Nested Quantifiers Assume S(x,y) means “x sees y” D = {bill, phil, jill, mell} What does xS(x,bill') mean? "For every x, x sees bill'" In other words, "Everyone sees Bill." Fall 2013 Frank / van Deemter / Wyner

Formal Evaluation - x y A(x,y) Suppose M1 = (D,I) where D={bill, jill, mary} I(jill') = jill, I(mary') = mary, I(bill') = bill, I(B)={bill, jill} I(G)={jill}, I(A)={(bill, jill), (mary,bill), (jill, jill)} x y A(x,y) is T in M1 iff for every a where I(a)  D, y A(x,y)) (x:=a) is T in M1; y A(x,y)) (x:=a) is T in M1 iff there is some b where I(b)  D such that A(x,y)) (x:=a) (x:=b) is T in M1. Fall 2013 Frank / van Deemter / Wyner

Formal Evaluation - x y A(x,y) Suppose M1 = (D,I) where D={bill, jill, mary} I(jill') = jill, I(mary') = mary, I(bill') = bill, I(B)={bill, jill} I(G)={jill}, I(A)={(bill, jill), (mary,bill), (jill, jill)} A(x,y) is true where (x:=bill') and y is some constant? where (x:=bill') (y:=bill'), A(x,y) is A(bill',bill'); A(bill',bill') is T in M1 iff (bill, bill)  I(A). where (x:=bill') (y:=jill'), A(x,y) is A(bill',jill'); A(bill',jill') is T in M1 iff (bill, jill)  I(A). where (x:=bill') (y:=mary'), A(x,y) is A(bill',mary'); A(bill',mary') is T in M1 iff (bill, mary)  I(A). Is one of these true? Fall 2013 Frank / van Deemter / Wyner

Formal Evaluation - x y A(x,y) Suppose M1 = (D,I) where D={bill, jill, mary} I(jill') = jill, I(mary') = mary, I(bill') = bill, I(B)={bill, jill} I(G)={jill}, I(A)={(bill, jill), (mary,bill), (jill, jill)} A(x,y) is true where (x:=jill') and y is some constant? where (x:=jill') (y:=bill'), A(x,y) is A(jill',bill'); A(jill',bill') is T in M1 iff (jill, bill)  I(A). where (x:=jill') (y:=jill'), A(x,y) is A(jill',jill'); A(jill',jill') is T in M1 iff (jill, jill)  I(A). where (x:=jill') (y:=mary'), A(x,y) is A(jill',mary'); A(jill',mary') is T in M1 iff (jill, mary)  I(A). Is one of these true? Fall 2013 Frank / van Deemter / Wyner

Formal Evaluation - x y A(x,y) Suppose M1 = (D,I) where D={bill, jill, mary} I(jill') = jill, I(mary') = mary, I(bill') = bill, I(B)={bill, jill} I(G)={jill}, I(A)={(bill, jill), (mary,bill), (jill, jill)} A(x,y) is true where (x:=mary') and y is some constant? where (x:=mary') (y:=bill'), A(x,y) is A(mary',bill'); A(mary',bill') is T in M1 iff (mary, bill)  I(A). where (x:=mary') (y:=jill'), A(x,y) is A(mary',jill'); A(mary',jill') is T in M1 iff (mary, jill)  I(A). where (x:=mary') (y:=mary'), A(x,y) is A(mary',mary'); A(mary',mary') is T in M1 iff (mary, mary)  I(A). Is one of these true? Fall 2013 Frank / van Deemter / Wyner

Formal Evaluation - x y A(x,y) Suppose M1 = (D,I) where D={bill, jill, mary} I(jill') = jill, I(mary') = mary, I(bill') = bill, I(B)={bill, jill} I(G)={jill}, I(A)={(bill, jill), (mary,bill), (jill, jill)} x y A(x,y) is true in M1 so long as we can answer T to each of the preceding questions "Is one of these true?" Fall 2013 Frank / van Deemter / Wyner

Mathematics for Computing Science Fall 2013 Quantifier Exercise If R(x,y)="x relies on y" express the following: x(y R(x,y)) = Everyone has someone to rely on. y(x R(x,y)) = There is someone whom everyone relies on. x(y R(x,y)) = There is someone who relies on everyone. y(x R(x,y)) = Everyone has someone who relies on them. x(y R(x,y)) = Everyone relies on everyone. Fall 2013 Frank / van Deemter / Wyner (c)2001-2002, Frank, van Deemter, and Wyner

Mathematics for Computing Science Fall 2013 Quantifier Exercise R(x,y) = "x relies on y" where D is not empty. x(y R(x,y)) y(x R(x,y)) x(y R(x,y)) Which of them is most informative? Which of them is least informative? Fall 2013 Frank / van Deemter / Wyner (c)2001-2002, Frank, van Deemter, and Wyner

Mathematics for Computing Science Fall 2013 Quantifier Exercise x(y R(x,y)) Least informative y(x R(x,y)) x(y R(x,y)) Most informative If 3 is true then 2 must also be true. If 2 is true then 1 must also be true. We say: 3 is logically stronger than 2 than 1 Fall 2013 Frank / van Deemter / Wyner (c)2001-2002, Frank, van Deemter, and Wyner

Natural language is ambiguous Mathematics for Computing Science Fall 2013 Natural language is ambiguous "Everybody likes somebody." Can mean: For everybody, there is somebody they like, x y Likes(x,y) Each to a different person There is somebody whom everyone likes? y x Likes(x,y) Each to the same person Fall 2013 Frank / van Deemter / Wyner (c)2001-2002, Frank, van Deemter, and Wyner

Quantifier Equivalences Mathematics for Computing Science Fall 2013 Quantifier Equivalences Expanding quantifiers: If D = {a,b,c,…} x P(x)  P(a)  P(b)  P(c)  … x P(x)  P(a)  P(b)  P(c)  … From those, we can “prove” the laws: x P(x)  x P(x) x P(x)  x P(x) Which propositional equivalence laws can be used to prove this? (Chalkboard.) Another way to see why the order of quantifiers matters is to expand out the definitions of FORALL and EXISTS in terms of AND and OR. For example, suppose the universe of discourse just consists of two objects a and b. Now, consider some predicate P(x,y). Then, FORALL x EXISTS y P(x,y)  (EXISTS y P(a,y)) /\ (EXISTS y P(b,y))  (P(a,a) \/ P(a,b)) /\ (P(b,a) \/ P(b,b)). In contrast, EXISTS y FORALL x P(x,y)  (FORALL x P(x,a)) \/ (FORALL x P(x,b))  (P(a,a) /\ P(b,a)) \/ (P(a,b) /\ P(b,b)). To see that these two are inequivalent, suppose only P(a,a) and P(b,b) are true. Then, the first proposition (with the FORALL first) is true, but, the second proposition (with the EXISTS first) is true. Students can come up with this counterexample in-class as an exercise. Fall 2013 Frank / van Deemter / Wyner (c)2001-2002, Frank, van Deemter, and Wyner

Mathematics for Computing Science Fall 2013 More Equivalences x y P(x,y)  y x P(x,y) x y P(x,y)  y x P(x,y) x (P(x)  Q(x))  (x P(x))  (x Q(x)) x (P(x)  Q(x))  (x P(x))  (x Q(x)) Let’s prove the last of these equivalences using the definition of the truth of a formula of the form xφ Fall 2013 Frank / van Deemter / Wyner (c)2001-2002, Frank, van Deemter, and Wyner

Proving a Quantifier Equivalence Mathematics for Computing Science Fall 2013 Proving a Quantifier Equivalence x (P(x)  Q(x))  (x P(x))  (x Q(x)) Proof:  Suppose x (P(x)  Q(x)) is true. So, there is a constant a such that (P(x)  Q(x)) (x:=a) is true. So, for that a, the formula P(a)  Q(a) is true. One possibility is that P(a) is true. In this case, P(x)(x:=a) is true. So, x P(x) is true, so (x P(x))  (x Q(x)) is true. The other possibility is that Q(a) is true. In this case, Q(x)(x:=a) is true. So, x Q(x) is true, so (x P(x))  (x Q(x)) is true. Fall 2013 Frank / van Deemter / Wyner (c)2001-2002, Frank, van Deemter, and Wyner

Proving a Quantifier Equivalence Mathematics for Computing Science Fall 2013 Proving a Quantifier Equivalence x (P(x)  Q(x))  (x P(x))  (x Q(x)) Proof:  Suppose (x P(x))  (x Q(x)) is true. One possibility is that x P(x) is true. This would mean that there is an a such that P(x) (x:=a) is true. So, for that constant a, P(a) is true.Therefore, P(a)  Q(a) would also be true. Hence, (P(x)  Q(x))(x:=a) would be true. Hence, x (P(x)  Q(x)) would be true. The other possibility is that x Q(x). From this, x (P(x)  Q(x)) is proven in the same way QED Fall 2013 Frank / van Deemter / Wyner (c)2001-2002, Frank, van Deemter, and Wyner

Another Equivalence Law? Mathematics for Computing Science Fall 2013 Another Equivalence Law? How about this one? x (P(x)  Q(x))  (x P(x))  (x Q(x))? Fall 2013 Frank / van Deemter / Wyner (c)2001-2002, Frank, van Deemter, and Wyner

Mathematics for Computing Science Fall 2013 Not an Equivalence Law x (P(x)  Q(x))  (x P(x))  (x Q(x)) ? This equivalence statement is false. Counterexample (i.e. model making this false): P(x): x’s birthday is on 30 April Q(x): x’s birthday is on 20 December We can pick different people for x on the right since x in P(x) and x in Q(x) are not both bound to the same quantifier. Fall 2013 Frank / van Deemter / Wyner (c)2001-2002, Frank, van Deemter, and Wyner

Some consequences of these definitions Sometimes, predicate logic is taught very informally This makes it easy to understand simple formulas But each more complex case has to be explained separately, as if it was an exception By defining things properly once, complex formulas fall out as special cases One example: quantifier nesting Fall 2013 Frank / van Deemter / Wyner

Frank / van Deemter / Wyner 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 say things about what can and cannot be expressed in predicate logic. Fall 2013 Frank / van Deemter / Wyner

Frank / van Deemter / Wyner 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. Fall 2013 Frank / van Deemter / Wyner

Defining Other Quantifiers one at most one at least two exactly two infinitely many finitely many Fall 2013 Frank / van Deemter / Wyner

Frank / van Deemter / Wyner 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”? Fall 2013 Frank / van Deemter / Wyner

Frank / van Deemter / Wyner 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) Fall 2013 Frank / van Deemter / Wyner

Frank / van Deemter / Wyner Example: one Can predicate logic say “there exists exactly one object with property P”? Fall 2013 Frank / van Deemter / Wyner

Frank / van Deemter / Wyner 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)”) Fall 2013 Frank / van Deemter / Wyner

Frank / van Deemter / Wyner 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)) Fall 2013 Frank / van Deemter / Wyner

Frank / van Deemter / Wyner At least two Can predicate logic say “there exist at least two objects with property P”? Fall 2013 Frank / van Deemter / Wyner

Frank / van Deemter / Wyner 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) Fall 2013 Frank / van Deemter / Wyner

Frank / van Deemter / Wyner Exactly two Can predicate logic say “there exist exactly two objects with property P”? Fall 2013 Frank / van Deemter / Wyner

Frank / van Deemter / Wyner Exactly two 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) )) Fall 2013 Frank / van Deemter / Wyner

Frank / van Deemter / Wyner 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’? Fall 2013 Frank / van Deemter / Wyner

Frank / van Deemter / Wyner 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 Fall 2013 Frank / van Deemter / Wyner

What Cannot be Expressed in Predicate Logic: Infinitely Many Can predicate logic say “there exist infinitely 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”] How about finitely many? Fall 2013 Frank / van Deemter / Wyner

What Cannot be Expressed in Predicate Logic: Finitely Many How about finitely 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 Fall 2013 Frank / van Deemter / Wyner

Another Way to Infinity If we allow infinitely long disjunctions then all this can be expressed: !x P(x)  2!x P(x)  3!x P(x)  … Fall 2013 Frank / van Deemter / Wyner

Frank / van Deemter / Wyner Remember In propositional logic, we can strictly speaking only build formulas of finite size. E.g., we can write P(a)  P(b) P(a)  P(b)  P(c) P(a)  P(b)  P(c)  P(d) , etc up to some finite length. But this way, we could never say that all natural numbers have P Fall 2013 Frank / van Deemter / Wyner

What Cannot be Expressed in Predicate Logic: Most, Many 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 Fall 2013 Frank / van Deemter / Wyner

Formulas of Infinite Length? In predicate logic, you can say this easily: xP(x) It’s sometimes useful to pretend that propositional logic allows infinitely long formulas, but in the “official” version this is not possible. Fall 2013 Frank / van Deemter / Wyner

Frank / van Deemter / Wyner Decidability We’ve shown you two ways of checking propositional logic equivalencies: Checking truth tables Using equivalence laws You’ve seen how (1) can be done algorithmically (consider the T-tables and semantic evaluation). This shows that checking propositional logic equivalence is decidable But, predicate logic has variables over (potentially) infinite domains and combinations of quantifiers, so checking predicate logic equivalence is not decidable Fall 2013 Frank / van Deemter / Wyner

Frank / van Deemter / Wyner 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. One application: PROLOG Fall 2013 Frank / van Deemter / Wyner

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. Fall 2013 Frank / van Deemter / Wyner

Frank / van Deemter / Wyner Facts in Prolog A fact in Prolog represents a simple, non-compound proposition in predicate logic. E.g., likes(john,mary) Lowercase symbols are used for constants and predicates, uppercase is used for variables. Fall 2013 Frank / van Deemter / Wyner

Frank / van Deemter / Wyner 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). Fall 2013 Frank / van Deemter / Wyner

Frank / van Deemter / Wyner 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) Fall 2013 Frank / van Deemter / Wyner

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) Fall 2013 Frank / van Deemter / Wyner

Frank / van Deemter / Wyner 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” (! Called Negation-as-failure) If the query contains any variables, all values that make the query true are printed. Fall 2013 Frank / van Deemter / Wyner

Frank / van Deemter / Wyner 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: ... Fall 2013 Frank / van Deemter / Wyner

Frank / van Deemter / Wyner 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 Fall 2013 Frank / van Deemter / Wyner

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. Fall 2013 Frank / van Deemter / Wyner

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. Fall 2013 Frank / van Deemter / Wyner