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

Similar documents
Predicate Calculus - Syntax

Denote John by j and Smith by s, is a bachelor by predicate letter B. The statements (1) and (2) may be written as B(j) and B(s).

3/29/2017. Logic. Propositions and logical operations. Main concepts: propositions truth values propositional variables logical operations

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

Formal (Natural) Deduction for Predicate Calculus

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

Propositional Logic Not Enough

Ling 130 Notes: Predicate Logic and Natural Deduction

COMP Intro to Logic for Computer Scientists. Lecture 11

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

Discrete Mathematics and Its Applications

2-4: The Use of Quantifiers

Predicate Logic: Sematics Part 1

Mat 243 Exam 1 Review

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

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

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

Introduction to Sets and Logic (MATH 1190)

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

06 From Propositional to Predicate Logic

Proposi'onal Logic Not Enough

Chapter 2: The Logic of Quantified Statements. January 22, 2010

Introduction to first-order logic:

Logical Operators. Conjunction Disjunction Negation Exclusive Or Implication Biconditional

Announcements CompSci 102 Discrete Math for Computer Science

Propositional Functions. Quantifiers. Assignment of values. Existential Quantification of P(x) Universal Quantification of P(x)

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

First Order Logic Semantics (3A) Young W. Lim 9/17/17

Section 2.1: Introduction to the Logic of Quantified Statements

First Order Logic Semantics (3A) Young W. Lim 8/9/17

Test 1 Solutions(COT3100) (1) Prove that the following Absorption Law is correct. I.e, prove this is a tautology:

Topic #3 Predicate Logic. Predicate Logic

Semantics I, Rutgers University Week 3-1 Yimei Xiang September 17, Predicate logic

ITS336 Lecture 6 First-Order Logic

Lecture 3 : Predicates and Sets DRAFT

Predicates, Quantifiers and Nested Quantifiers

! Predicates! Variables! Quantifiers. ! Universal Quantifier! Existential Quantifier. ! Negating Quantifiers. ! De Morgan s Laws for Quantifiers

SYMBOLIC LOGIC UNIT 10: SINGULAR SENTENCES

Logic for Computer Science Handout Week 8 DERIVED RULE MODUS TOLLENS DERIVED RULE RAA DERIVED RULE TND

Predicate Calculus lecture 1

STRATEGIES OF PROBLEM SOLVING

THE LOGIC OF QUANTIFIED STATEMENTS. Predicates and Quantified Statements I. Predicates and Quantified Statements I CHAPTER 3 SECTION 3.

Proving Arguments Valid in Predicate Calculus

Chapter 2: The Logic of Quantified Statements

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.

G52DOA - Derivation of Algorithms Predicate Logic

ICS141: Discrete Mathematics for Computer Science I

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

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:

For all For every For each For any There exists at least one There exists There is Some

Predicate Logic. Andreas Klappenecker

Predicate Logic Thursday, January 17, 2013 Chittu Tripathy Lecture 04

CSI30. Chapter 1. The Foundations: Logic and Proofs Nested Quantifiers

Automated Reasoning Lecture 5: First-Order Logic

III. Elementary Logic

CS 220: Discrete Structures and their Applications. Predicate Logic Section in zybooks

1 Predicates and Quantifiers

LIN1032 Formal Foundations for Linguistics

Propositional Logic: Syntax

University of Ottawa CSI 2101 Midterm Test Instructor: Lucia Moura. February 9, :30 pm Duration: 1:50 hs. Closed book, no calculators

1.3 Predicates and Quantifiers

First order Logic ( Predicate Logic) and Methods of Proof

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

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

AAA615: Formal Methods. Lecture 2 First-Order Logic

Predicate in English. Predicates and Quantifiers. Predicate in Logic. Propositional Functions: Prelude. Propositional Function

Discrete Mathematics & Mathematical Reasoning Predicates, Quantifiers and Proof Techniques

COMP9414: Artificial Intelligence First-Order Logic

First Order Logic (1A) Young W. Lim 11/18/13

Propositional Language - Semantics

Introduction to Metalogic

Logic. Propositional Logic: Syntax. Wffs

Mathematical Logic Part Three

Predicate Logic & Quantification

Logical Structures in Natural Language: First order Logic (FoL)

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

Section Summary. Section 1.5 9/9/2014

At least one of us is a knave. What are A and B?

A Little Deductive Logic

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

Logic and Proofs. (A brief summary)

CS560 Knowledge Discovery and Management. CS560 - Lecture 3 1

5. Use a truth table to determine whether the two statements are equivalent. Let t be a tautology and c be a contradiction.

A Little Deductive Logic

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

Philosophy 240 Symbolic Logic Russell Marcus Hamilton College Fall 2014

22c:145 Artificial Intelligence. First-Order Logic. Readings: Chapter 8 of Russell & Norvig.

Predicate Logic. Example. Statements in Predicate Logic. Some statements cannot be expressed in propositional logic, such as: Predicate Logic

CS 2800: Logic and Computation Fall 2010 (Lecture 13)

Quantifiers Here is a (true) statement about real numbers: Every real number is either rational or irrational.

Stanford University CS103: Math for Computer Science Handout LN9 Luca Trevisan April 25, 2014

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

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

Review. Propositions, propositional operators, truth tables. Logical Equivalences. Tautologies & contradictions

MATH 215 DISCRETE MATHEMATICS INSTRUCTOR: P. WENG

Today s Lecture. ICS 6B Boolean Algebra & Logic. Predicates. Chapter 1: Section 1.3. Propositions. For Example. Socrates is Mortal

First-Order Logic. Chapter Overview Syntax

Logics - Introduction

Predicates and Quantifiers. Nested Quantifiers Discrete Mathematic. Chapter 1: Logic and Proof

CS1021. Why logic? Logic about inference or argument. Start from assumptions or axioms. Make deductions according to rules of reasoning.

Transcription:

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

Predicate Calculus Alternative names: predicate logic, first order logic, elementary logic, restricted predicate calculus, restricted functional calculus, relational calculus, theory of quantification, theory of quantification with equality, etc. In propositional logic only the logical forms of compound propositions are analyzed. A simple proposition is an unanalyzed whole which is either true or false. There are certain arguments that seem to be perfectly logical, yet they cannot be expressed by using propositional calculus. Predicate Calculus CS245, Logic and Computation 2 / 59

Example 1. All humans are mortal. 2. Socrates is human. From these two sentences, one should be able to conclude that 3. Socrates is mortal. We cannot show that this argument is sound using propositional calculus. To show that this argument is sound, we must be able to identify individuals, such as Socrates, together with their properties and predicates. This is the objective of predicate calculus. Predicate Calculus CS245, Logic and Computation 3 / 59

Socrates Socrates (470-399 B.C.) - founder of Western philosophy Teacher of Plato (himself teacher of Aristotle, founder of logic) I know that I know nothing. Predicate Calculus CS245, Logic and Computation 4 / 59

Back to predicate logic: Puzzles You visit an island where the people are of two types: each person is a knight (tells the truth) or a knave (lies). You talk to every person on the island and each one says All of us on the island are of the same type. Knight Knave always tells truth always lies Are they really the same type? Can you determine which type? Because everyone says the same thing, they must all be of the same type. Then the statement is true, and can only be said by a knight. Predicate Calculus CS245, Logic and Computation 5 / 59

Puzzles On the next island each person says Some of us are knights and some of us are knaves. Are they knights? Some of each? Again, they must all be of the same type (since they all say the same thing). Then the statement is false, and they must all be knaves. Predicate Calculus CS245, Logic and Computation 6 / 59

Puzzles Epimenides was a Cretan (lived in the island of Crete) who said All cretans are liars. Is this a paradox? If Epimenides was telling the truth, then all Cretans are liars, so he was lying. Contradiction. If Epimenides was lying, then not all Cretans are liars. That is consistent so long as there was a Cretan who was a truth-teller. Note: I am a knave is a true paradox. We have to be careful about paradoxes in our logic systems. Predicate Calculus CS245, Logic and Computation 7 / 59

Predicates, terms, quantifiers Generally, predicates are used to describe certain properties or relationships between individuals or objects. Example: Human(x) - x is human Mortal(x) - x is mortal Human(Socrates) Predicates take true/false values. The entities like Socrates are called terms. Terms play a similar role in predicate calculus as nouns and pronouns do in the English language. Predicate Calculus CS245, Logic and Computation 8 / 59

Predicates, terms, quantifiers In addition to terms and predicates, one uses quantifiers. Quantifiers indicate how frequently a certain statement is true. Specifically, the universal quantifier is used to indicate that a statement is always true, whereas the existential quantifier indicates that a statement is sometime true. Predicate calculus is a generalization of propositional calculus. Hence, besides terms, predicates, and quantifiers, predicate calculus contains propositional variables, constants and connectives as part of the language. An important part is played by functions which are essential when discussing equations. Predicate Calculus CS245, Logic and Computation 9 / 59

Predicate calculus in Computer Science Predicate calculus gives the underpinnings to the languages of logic programming, such as Prolog. Predicate calculus is increasingly used for specifying the requirements of computer applications. In the area of proving program correctness, predicate calculus allows one to precisely state under which conditions a program gives the correct output. Predicate Calculus CS245, Logic and Computation 10 / 59

The Domain (universe of discourse) Example. 1. Joan is Paul s mother. 2. Joan is Mary s mother. 3. Any two persons having the same mother are siblings. 4. Paul and Mary are siblings. The truth of the statement Joan is Paul s mother can only be assessed within a certain context. There are many people named Joan and Paul, and without further information the statement in question can refer to many different people, which makes it ambiguous. To prevent such ambiguities we introduce the concept of a domain or universe of discourse. Predicate Calculus CS245, Logic and Computation 11 / 59

Domain Definition The universe of discourse or domain is the collection of all persons, ideas, symbols, data structures, and so on, that affect the logical argument under consideration. In the argument concerning Mary and Paul, the universe of discourse (domain) may, for instance, consist of the people living in a particular house or a particular block. Many arguments involve numbers and, in this case, one must stipulate whether the domain is the set of natural numbers, the set of integers, the set of real numbers, or the set of complex numbers. The truth of a statement may depend on the domain selected! The statement there is a smallest number is true in the domain of natural numbers, but false in the domain of integers. Predicate Calculus CS245, Logic and Computation 12 / 59

Domain If the universe of discourse Predicate Calculus consists CS245, of persons, Logic and Computation the individual 13 / 59 The elements of the domain are called individuals. An individual can be a person, a number, a data structure, or anything else one wants to reason about. To avoid trivial cases, one stipulates that every domain must contain at least one individual. Hence, the set of all natural numbers less than 0 does not constitute a domain (universe of discourse) because there is no negative number. Instead of the word individual one sometimes uses the word object, such as in the domain must contain at least one object. To refer to a particular individual or object, identifiers must be used. These identifiers are called individual constants.

Predicates Generally, predicates make statements about individuals: Mary and Paul are siblings. Joan is the mother of Mary. Socrates is human. The sum of 2 and 3 is 5. In each of these statements, there is a list of individuals, which is given by the argument list, together with phrases that describe certain relations among or properties of the individuals mentioned in the argument list. These properties or relations are referred to as predicates. Predicate Calculus CS245, Logic and Computation 14 / 59

Argument list In the statement Mary and Paul are siblings, the argument list is given by Mary and Paul, in that order, whereas the predicate is described by the phrase are siblings. Similarly, the statement Socrates is human has an argument list with the single element Socrates in it, and its predicate is described by is human. The entries of the argument list are called arguments. The arguments can be either variables or individual constants, but since we have not discussed variables yet, we restrict our attention to the case when all arguments are individual constants. Predicate Calculus CS245, Logic and Computation 15 / 59

Predicates - contd. In predicate calculus, each predicate is given a name, which is followed by the list of arguments. The list of arguments is enclosed in parantheses. To express Joan is the mother of Mary one could choose an identifier, say mother to express the predicate is the mother of, and one would write mother (Joan, Mary). Many logicians use only single letters for predicate names and constants. They would write, for instance M(j, m) instead of mother(joan, Mary); that is, they would use M as a name for the predicate is the mother of, j for Joan and m for Mary. To save space, we will often use this convention. Note that the order of arguments is important: Clearly, the statements mother(mary, Joan) and mother(joan, Mary) have a completely different meaning. Predicate Calculus CS245, Logic and Computation 16 / 59

Arity The number of elements in the argument list of a predicate is called the arity of the predicate. For instance, mother(joan, Mary) has arity 2. The arity of a predicate is fixed: A predicate cannot have two arguments in one case and three in another. Alternatively, one can consider two predicates different if their arity is different. Predicate Calculus CS245, Logic and Computation 17 / 59

Example The following statement illustrates this: The sum of 2 and 3 is 5. The sum of 2, 3 and 4 is 9. To express these statements in predicate calculus, one can either use two predicate names such as sum2 and sum3 and write sum2(2, 3, 5) and sum3(2, 3, 4, 9) respectively, or one can use the same symbol, say sum with the implicit understanding that the name sum in sum(2, 3, 5) refers to a different predicate than in sum(2, 3, 4, 9). Predicate Calculus CS245, Logic and Computation 18 / 59

One-place predicate = Property A predicate with arity n is often called an n-place predicate. A one-place predicate is called a property. The predicate Human(x) and Mortal(x) are one-place predicates, or properties. The predicate is the mother of, as in Joan is the mother of Mary is a two-place predicate; that is, its arity is 2. The predicate in the statement The sum of 2 and 3 is 6 (which is false) is a three-place predicate is the sum of. Predicate Calculus CS245, Logic and Computation 19 / 59

Atomic formulas A predicate name, followed by an argument list in parantheses is called an atomic formula. The atomic formulas can be combined by logical connectives like propositions. For instance, if Human(Socrates) and Mortal(Socrates) are two atomic formulas, expressing that Socrates is a human implies that Socrates is mortal becomes Human(Socrates) Mortal(Socrates). Predicate Calculus CS245, Logic and Computation 20 / 59

Assignments If all arguments of a predicate are individual constants, then the resulting atomic formula must be either true or false This is part of the definition of the predicate. For instance, if the domain consists of Joan, Doug, Mary and Paul, we have to know for each ordered pair of individuals whether or not the predicate is the mother of is true. This can be done in the form of a table. The method that assigns truth values to all possible combinations of individuals of a predicate is called an assignment. Predicate Calculus CS245, Logic and Computation 21 / 59

Example 1 Assignment for the Predicate mother: Doug Joan Mary Paul Doug 0 0 0 0 Joan 0 0 1 1 Mary 0 0 0 0 Paul 0 0 0 0 Predicate Calculus CS245, Logic and Computation 22 / 59

Example 2 The domain consists of the four numbers 1, 2, 3, 4. The predicate greater is true if the first argument is greater than the second argument. Hence, greater(4, 3) is true and greater(3, 4) is false. Assignment for the predicate greater: 1 2 3 4 1 0 0 0 0 2 1 0 0 0 3 1 1 0 0 4 1 1 1 0 Predicate Calculus CS245, Logic and Computation 23 / 59

Observations In a finite domain (universe of discourse), one can represent the assignments of predicates with arity n by n-dimensional arrays. Note that the mathematical symbols >, < are predicates. However, these predicates are normally used in infix notation. By this, we mean that they are placed between the arguments. For instance, to express that 2 is greater than 1, we write 2 > 1 rather than > (2, 1). Predicate Calculus CS245, Logic and Computation 24 / 59

Variables and instantiation Often one does not want to associate the arguments of an atomic formula with a particular individual. To avoid this, variables are used. Variables are frequently chosen from the end of the alphabet; that is x, y and z, with or without subscripts, suggest variable names. Examples: Human(x) Mortal(x) dog(y) brown(y) grade(x) (x 0) (x 100) Clearly, the first and third formulas contain the variable x, and the second the variable y. Predicate Calculus CS245, Logic and Computation 25 / 59

As in propositional calculus, formulas can be given names. For instance, one can define A as follows: A = Human(x) Mortal(x). which means that when we write A we really mean Human(x) Mortal(x). Syntactically, one can use variables in any place where one is allowed to use constants. The word term is therefore used to refer to either a constant or a variable. More generally, a term is anything that can be used in place of an individual (formal definition later). Predicate Calculus CS245, Logic and Computation 26 / 59

Instantiation If A is a formula, one often has to replace all occurrences of a particular variable by a term. For example, in the expression Human(x) Mortal(x), one may want to replace all instances of x by the term Socrates which yields Human(Socrates) Mortal(Socrates). Generally, if A is a formula, the formula obtained by replacing all variables x in A by the term t is denoted by S x t A. Specifically, if A is defined as previously, then stands for S x SocratesA Human(Socrates) Mortal (Socrates). Predicate Calculus CS245, Logic and Computation 27 / 59

Instantiation Definition Let A represent a formula, x represent a variable, and t represent a term. Then S x t A represents the formula obtained by replacing all occurrences of x in A by t. S x t A is called an instantiation of A, and t is said to be an instance of x. Example: Let a, b, c be individual constants, P, Q, be predicate symbols, and x and y be variables. Find S x t S x a (P(a) Q(x)) S y b (P(y) Q(y)) Sa y Q(a). S y a (P(x) Q(x)). is an operation that can be performed on predicates; therefore it is not a predicate itself, and this makes St x a meta-formula. Predicate Calculus CS245, Logic and Computation 28 / 59

Quantifiers Consider the following three statements: 1. All humans are mortal. 2. Some people like their meat raw. 3. Everyone gets a break once in a while. All these statements indicate how frequently certain things are true. In predicate calculus one uses quantifiers in this context. Predicate Calculus CS245, Logic and Computation 29 / 59

Universal quantifier Definition. Let A represent a formula, and let x represent a variable. If we want to indicate that A is true for all possible values of x in the domain, we write xa. Here, x is called universal quantifier, and A is called the scope of the quantifier. The variable x is said to be bound by the quantifier. The symbol is pronounced for all. Predicate Calculus CS245, Logic and Computation 30 / 59

Comments The quantifier and the bounded variable that follows have to be treated as a unit, and this unit acts somewhat like a unary connective. Statements containing words like every, each, and everyone usually indicate universal quantification. Such statements must typically be reworded such that they start with for every x, which is then translated into x. Predicate Calculus CS245, Logic and Computation 31 / 59

Example (1) Express Everyone gets a break once in a while in predicate calculus. Solution: We define B to mean gets a break once in a while. Hence, B(x) means that x gets a break once in a while. The word everyone indicates that this is true for all x. This leads to the following translation: xb(x) (2) Our initial argument becomes: x(human(x) Mortal(x)) Human(Socrates) Mortal(Socrates) Predicate Calculus CS245, Logic and Computation 32 / 59

Existential quantifier Definition Let A represent a formula, and let x represent a variable. If we want to indicate that A is true for at least one value x in the domain, we write xa. This statement is pronounced There exists an x such that A. Here, x is called the existential quantifier, and A is called the scope of the quantifier. The variable x is said to be bound by the quantifier. Statements containing phrases as some, and at least one suggest existential quantifiers. They should be rephrased as there is an x such that which is translated by x. Predicate Calculus CS245, Logic and Computation 33 / 59

Examples Example: Let P be the predicate like their meat raw. Then xp(x) can be translated as There exist people who like their meat raw or Some people like their meat raw. Example: If the universe of discourse (domain) is a collection of things, x blue(x) should be understood as There exists objects that are blue or Some objects are blue. Predicate Calculus CS245, Logic and Computation 34 / 59

Comments x and x have to be treated like unary connectives. The quantifiers are given a higher precedence than all binary connectives. For instance, if P(x) and Q(x) means that x is living and that x is dead, respectively, then one has to write x(p(x) Q(x)) to indicate that everything is either living or dead. xp(x) Q(x) means that either everything is living, or x is dead. Predicate Calculus CS245, Logic and Computation 35 / 59

The variable x in a quantifier is just a placeholder, and it can be replaced by any other variable name not appearing elsewhere in the formula. For instance xp(x) and yp(y) mean the same thing: they are logically equivalent. The expression yp(y) is a variant of xp(x). Predicate Calculus CS245, Logic and Computation 36 / 59

Variant of a formula Definition A formula is called a variant of xa if it is of the form ys x y A where y is any variable name and S x y A is the formula obtained from A by replacing all instances of x by y. Similarly, xa and ys x y A are variants of one another. Predicate Calculus CS245, Logic and Computation 37 / 59

Comments 2 Quantifiers may be nested. Example: Translate the sentence There is somebody who knows everyone into the language of predicate calculus. Use K(x, y) to express the fact that x knows y. Solution. The best way to solve this problem is to go in steps. We write informally x(x knows everybody) Here, x knows everybody is still in English and means that for all y is it true that x knows y. Hence x knows everybody = yk(x, y) We now add the existential quantifier and obtain x yk(x, y). Predicate Calculus CS245, Logic and Computation 38 / 59

Example: Translate Everybody has a mother. Predicate Calculus CS245, Logic and Computation 39 / 59

Comments 3 The English statement Nobody is perfect also includes a quantifier, nobody which is the absence of an individual with a certain property. In predicate calculus, the fact that nobody has property P cannot be expressed directly. To express the fact that there is no x for which an expression A is true one can either use xa or x A. If P represents the property of perfection, both xp(x) and x P(x) indicate that nobody is perfect. xp(x) - It is not the case that there is somebody who is perfect, x P(x) - for everyone, it is not the case that he or she is perfect Predicate Calculus CS245, Logic and Computation 40 / 59

The two methods to express that nobody is A must of course be logically equivalent, xa = x A. There are many quantifiers in English, such as a few, most, and about a third, that are useful in daily language, but are not precise and cannot be used in logic. We do not consider them further. Predicate Calculus CS245, Logic and Computation 41 / 59

Bound and free variables The variable appearing in the quantifier is said to be bound. For instance, in the expression x(p(x) Q(x)), the variable x appears three times and each time x is a bound variable. Any variable that is not bound is said to be free. Later we will see that the same variable can occur both bound and free in a formula. For this reason it is also important to indicate the position of the variable in question. Predicate Calculus CS245, Logic and Computation 42 / 59

Example: Find the free variables in z(p(z) Q(x)) yq(y). Solution: Only one variable x is free. All occurrences of z are bound, and so are all occurrences of the variable y. Note that the status of a variable changes as formulas are divided into subformulas. For instance, in xp(x), x occurs twice and it is bound both times. Nevertheless, in P(x) the variable x is free. Predicate Calculus CS245, Logic and Computation 43 / 59

Comments Instantiation only affects free variables. Specifically, if A is a formula, S x t A only affects the free occurrences of the variable x in A. For instance, S x y xp(x) is still xp(x); that is, the variable x is not instantiated. However, S x y (Q(x) xp(x)) yields Q(y) xp(x). Hence, instantiation treats the variable x differently, depending on whether it is free or bound, even if this variable appears twice in the same expression. Obviously, two things are only identical if they are treated identically. This implies that, if a variable appears both free and bound within the same formula, we have in fact two different variables that happen to have the same name. Predicate Calculus CS245, Logic and Computation 44 / 59

Comments We can consider the bound variables to be local to the scope of the quantifier just as parameters and locally declared variables in procedural programming languages are local to the procedure in which they are declared. The analogy to procedural programming languages can be extended further if we consider the variable name in the quantifier as a declaration. This analogy also suggests that, if several quantifiers use the same bound variable for quantification, then all these variables are local to their scope and they are therefore distinct. Predicate Calculus CS245, Logic and Computation 45 / 59

Comparison of bound variables with variable usage in programming Predicate Calculus CS245, Logic and Computation 46 / 59

When forming variants, one must be careful not to interfere with local definitions. To illustrate this, consider the statement y has a mother. If M is a predicate name for is mother of then this statement translates into xm(x, y). One obviously must not form the statement ym(y, y), which means that y is her own mother. Predicate Calculus CS245, Logic and Computation 47 / 59

For similar reasons there are restrictions to instantiation. For example, the instantiation S y x ( xm(x, y)) is illegal because it results in xm(x, x). In such cases, one tampers with the way in which a variable is defined, and this has undesired side effects. We will refer to instances in which a variable becomes bound, or otherwise changes scope, as variable clashes. All variable chashes must be avoided!!!! Predicate Calculus CS245, Logic and Computation 48 / 59

Restrictions of quantifiers Sometimes, quantification is over a subset of the universe of discourse. Suppose, for instance, that animals form the universe of discourse. How can one express sentences such as All dogs are mammals and Some dogs are brown? Predicate Calculus CS245, Logic and Computation 49 / 59

Restrictions for the universal quantifier Consider the first statement All dogs are mammals. Since the quantifier should be restricted to dogs, one rephrases the statement If x is a dog, then x is a mammal leads to x(dog(x) mammal(x)). Predicate Calculus CS245, Logic and Computation 50 / 59

Generally, the sentence x(p(x) Q(x)) can be translated as All individuals with property P also have property Q.. Predicate Calculus CS245, Logic and Computation 51 / 59

Restrictions of the existential quantifier Consider now the statement Some dogs are brown. This means that there are some animals that are dogs and that are brown. Of course, the statement x is a dog and x is brown can be translated as dog(x) brown(x). There are some brown dogs can be now translated as x(dog(x) brown(x)). Predicate Calculus CS245, Logic and Computation 52 / 59

The statement x(p(x) Q(x)) can in general be interpreted as Some individuals with property P have also property Q. Predicate Calculus CS245, Logic and Computation 53 / 59

Note that if the universal quantifier is to apply only to individuals with a given property, we use the conditional to restrict the domain. If we similarly want to restrict application of the existential quantifier, we use the conjunction. Predicate Calculus CS245, Logic and Computation 54 / 59

Only Consider statements containing the word only such as only dogs bark. To convert this into predicate calculus, this must be reworded as It barks only if it is a dog or its contrapositive equivalent If it barks, then is is a dog. One has therefore x( barks(x) dog(x)). Predicate Calculus CS245, Logic and Computation 55 / 59

Exercises Let P(x) be the statement x = x 2. If the universe of discourse is the set of integers, what are the truth values of the following? (a) P(0) (b) P(1) (c) P(2). Predicate Calculus CS245, Logic and Computation 56 / 59

Exercises 1. Translate the following propositions into formulas of predicate calculus (select suitable symbols). The universe of discourse is the set of all complex numbers: All rational numbers are real numbers. Not all real numbers are rational numbers. Some real numbers are not rational numbers. Every natural number is either odd or even. No natural number is both odd and even. Predicate Calculus CS245, Logic and Computation 57 / 59

Exercises Let Q(x, y) be the statement x + y = x y. If the universe of discourse for both variables is the set of integers, what are the truth values of the following? a) Q(1, 1) b) Q(2, 0) c) yq(1, y) d) xq(x, 2) e) x yq(x, y) f ) x yq(x, y) g) y xq(x, y) h) y xq(x, y) i) x yq(x, y) Predicate Calculus CS245, Logic and Computation 58 / 59

Exercises Let L(x, y) be the predicate x loves y, where the domain for both x and y is the set of all people in the world. Express the following in predicate calculus. a) Everybody loves Jerry. b) Everybody loves somebody. c) There is somebody whom everybody loves. d) Nobody loves everybody. e) There is somebody whom Lydia does not love. f) There is somebody whom no one loves. g) There is exactly one person whom everybody loves. h) There are exactly two people whom Lynn loves. i) Everyone loves himself or herself. j) There is somebody who loves no one besides himself or herself. Predicate Calculus CS245, Logic and Computation 59 / 59