Predicates (CSCI 2824 Spring 2015)In this lecture, we will cover the following topics:
PredicatesIn the previous lecture, we looked at propositions. Propositions are statements for which we can give “true” or “false” valuation. We will now generalize propositions to predicates. Predicates should be familiar from english grammar. Thus, the predicate can be informally expressed as: X is going to school, where X is a variable that can stand for a person. If we fill in values for X, such as Tom, Susan, My Fish and so on, we obtain propositions that can be given true or false valuations. A predicate is a statement with a variable such that whenever is substituted by a value, then it results in a proposition that can be given true or false valuation. Example-1(a):Let stand for the statement: __<x>__ is mortal. Q: What is ? A: The proposition Socrates is mortal. Example-1(b):We can use predicates in propositional formulas. Socrates is mortal AND he NOT is the son of Zeus. This can expressed as , where the predicate stand for the statement: __<x>__ is mortal, and the predicate stand for the statement: __<x>__ is the son of __<y>__. Example-2:Predicates can be arithmetic in nature. Here are some predicates over numbers:
Note that we can plug in various numbers and find out if the resulting statement is true of false.
Example-3:Predicates can involve multiple variables. Let stand for the statement: __<x>__ is the father of __<y>__ . Q: Using the predicate above, how do we express Darth is the father of Luke? A: . And the same applies to predicates over numbers:
Example-4:We can now bring in all the propositional connectives and combine them with predicates. Q: How do we say that ( Darth is the father of Luke OR Anakin is the father of Luke) AND (Luke is NOT the father of Darth) using the Father predicate from the previous example? A: . Example-5:Let be a predicate over numbers that stands for is prime. Which of the following formulae are true over numbers?
Answers:
Redo the example with the following interpretation of : . An application: Predicate logic forms the root of Prolog, which is used in artificial intelligence. Predicates and SetsWe can use predicates to select elements from a set. Let us fix a set .
Application: SQL for database managementStructured Query Language (SQL) is a data definition and manipulation language, based on relational calculus. In plain terms, SQL allows us to query (i.e., retrieve) data that satisfies certain criteria, which would be specified using predicates. Here is what a query looks like (syntax may be a little off), given e.g. a database db that stores a list of people and their ages. SQL Query
SELECT (name, age) FROM db WHERE ( name[1]=="z" && age < 20) This syntax uses the predicate name1==“z” && age < 20 (where name and age are the variables) and returns from the database db a list of people whose names start with “z” and who are less than 20 years old. Negation of Predicates and FormulasThe negation of predicate is written as . However, this can be simplified further by applying DeMorgan's Laws. Eg., Consider the predicate . It is cumbersome to write everywhere. Instead, we write . In other words, we say that the predicate represents the negation of . Starting from predicates, we can extend negations to formulae. What is the negation of: Answer: Note how the changes to a while negation. Rules for negation:
ExampleWrite down the negation of the following formulae: Q1: . A: . Q2: . A: . QuantifiersThe power of predicates arise from our ability to quantify. Let us illustrate quantification with an example. How do we express the statement: For all natural numbers , is divisible by OR is divisible by ? If we forget the for all in the first place, we can write This is a formula involving a predicate that allows us to plug-in values for . But the original statement was meant to hold for all possible values of . We use the universal or forall quantifier to say:
The other quantifier used is the existential or the exists quantifier. As an example, we wish to say: There is a number that is even and prime. The symbol stands for exists. Notice that it is an inverted . Quantified FormulaWhenever there is a quantifier in front of a formula, it is called a quantified formula. As an example consider the formula: In this formula the variable is called a bound or a quantified variable. The variable y is called a free variable. We usually write formulas as to denote that is a free variable in the formula. For example, which of the following are true for the formula above:
Formulas can have multiple quantifiers in front of them: Q Paraphrase this formula in plain english. A For every number there exists a number such that and is prime. Q Express this sentence in Logic: “ Forall persons x,y,z, If (x is the parent of y) and ( y is the parent of z) then (x is the grandparent of z) ”. Use predicates “P(x,y)” for parent and “GP(x,y)”, grand parent. Q Define the formula to express that is a sibling of using the parent relation, where two persons are siblings if they have a parent in common. A: |