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 Example-1(a):Let 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
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 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 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 Eg., Consider the predicate In other words, we say that the predicate Starting from predicates, we can extend negations to formulae. What is the negation of: Answer: Note how the 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 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 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 The symbol 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 We usually write formulas as 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 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 A:
|