1.
Logic & Formal Methods Predicate Logic Instructor: Dr H. Farooq Ahmad Sarmad Sadik TA: Muhammad Afzal, Maqbool Reference: Discrete Mathematics with Examples by Simpson
2.
Topics <ul><li>Universal quantification </li></ul><ul><li>Existential quantification </li></ul><ul><li>Satisfaction and validity </li></ul><ul><li>The negation of quantifiers </li></ul><ul><li>Free and bound variables </li></ul><ul><li>Substitution </li></ul><ul><li>Restriction </li></ul><ul><li>Uniqueness </li></ul><ul><li>Equational reasoning </li></ul><ul><li>Natural deduction </li></ul><ul><li>One point rule </li></ul>Page
3.
Pros and cons of propositional logic <ul><li>Propositional logic is declarative </li></ul><ul><li>Propositional logic allows conjunction, disjunction, negated information </li></ul><ul><li>Propositional logic is compositional : </li></ul><ul><ul><li>meaning of B 1,1 P 1,2 is derived from meaning of B 1,1 and of P 1,2 </li></ul></ul><ul><li>Meaning in propositional logic is context-independent (unlike natural language, where meaning depends on context) </li></ul><ul><li>Propositional logic has very limited expressive power (unlike natural language) </li></ul>
4.
First-order logic <ul><li>Whereas propositional logic assumes the world contains facts , </li></ul><ul><li>first-order logic (like natural language) assumes the world contains </li></ul><ul><ul><li>Objects: people, houses, numbers, colors, baseball games, wars, … </li></ul></ul><ul><ul><li>Relations & functions: red, round, prime, brother of, bigger than, part of, comes between, father of, best friend, one more than, plus, … </li></ul></ul>
5.
Syntax of FOL: Basic elements <ul><li>Constants KingJohn, 2, NUS,... </li></ul><ul><li>Functions Sqrt, LeftLegOf,... </li></ul><ul><li>Variables x, y, a, b,... </li></ul><ul><li>Connectives , , , , </li></ul><ul><li>Equality = </li></ul><ul><li>Quantifiers , </li></ul>
6.
Predicates <ul><li>A predicate is a proposition whose truth depends on the value of one or more variables. </li></ul><ul><li>For example, “n is a perfect square” is a predicate whose truth depends on the value of n. </li></ul><ul><li>A function like notation is used to denote a predicate supplied with specific variable values. P(n)=“n is a perfect square” </li></ul><ul><li>P(4) is true and P(5) is false. </li></ul>Page
7.
Universal Quantification <ul><li>Universal Quantification denoted as </li></ul><ul><li>Universal Quantification allows us to capture statements of the form “for all” or “for every”. </li></ul><ul><li>For example, “every natural number is greater than or equal to zero” can be written formally as </li></ul>Page
8.
Universal Quantification <ul><li>A quantified statement consists of three parts: the quantifier, the quantification, which describes the variables and the type of variable with which the statement is concerned and the predicate which is normally some statement about the quantified variables. </li></ul><ul><li>Every predicate logic statement can be considered as follows </li></ul>Page
10.
Exercise <ul><li>Everybody likes Jaffa cakes </li></ul><ul><li>All vegetarians don’t like Jaffa cakes </li></ul><ul><li>Everybody either likes Jaffa cakes or is a vegetarian </li></ul><ul><li>Either every body likes Jaffa cakes or everybody is a vegetarian </li></ul>Page
14.
Existential quantification <ul><li>Existential quantifier denoted by </li></ul><ul><li>As universal quantification is used to assert that a certain property holds of every element of a set, existential quantification is used to assert that such a property holds of some (or at least) elements of a set </li></ul><ul><li>“ Some natural numbers are divisible by 3” may be written as </li></ul>Page
15.
Exercise <ul><li>Some people like Jaffa cakes </li></ul><ul><li>Some vegetarians don’t like Jaffa cakes </li></ul><ul><li>Some people either like Jaffa cakes or are vegetarian </li></ul><ul><li>Either some people like Jaffa cakes or some people are vegetarian </li></ul>Page
19.
Satisfaction and validity <ul><li>The predicate n>3 can be considered neither true nor false unless we know the value associated with n </li></ul><ul><li>A predicate p is valid if and only if it is true for all possible values of the appropriate type. That is, if a predicate p is associated with a variable x of type X, then p is valid if, and only if, </li></ul><ul><li>Example </li></ul>Page
20.
Satisfaction and validity <ul><li>A predicate p is satisfiable if and only if it is true for some values of the appropriate type. That is, if a predicate p is associated with a variable x of type X, then p is satisfiable if, and only if , </li></ul><ul><li>Example </li></ul>Page
21.
Satisfaction and validity <ul><li>A predicate p is unsatisfiable if, and only if, it is false for all possible values of the appropriate type. </li></ul><ul><li>If a predicate p is associated with a variable x of type X, then p is unsatisfiable if, and only if, </li></ul>Page
22.
Satisfaction and validity <ul><li>The analogies between valid, satisfiable and unsatisfiable predicates, and tautologies, contingencies and contradictions: </li></ul><ul><li>valid predicates and tautologies are always true </li></ul><ul><li>satisfiable predicates and contingencies are sometimes true and sometimes false </li></ul><ul><li>unsatisfiable predicates and contradictions are never true </li></ul>Page
23.
The negation of quantifiers <ul><li>The statement “some body like Brian” may be expressed via predicate logic as </li></ul><ul><li>To negate this expression, we may write as, </li></ul><ul><li>which in natural language may be expressed as “nobody likes Brian” </li></ul>Page
24.
The negation of quantifiers <ul><li>Logically saying “nobody likes Brian” is equivalent to saying “everybody does not like Brian”. </li></ul><ul><li>The negation of quantifiers behaves exactly in this fashion, just as in natural language, “nobody likes Brian” and “everybody does not like Brian” are equivalent so in predicate logic </li></ul><ul><li>And </li></ul><ul><li>are equivalent. </li></ul>Page
25.
The negation of quantifiers <ul><li>Law 5 </li></ul><ul><li>When negation is applied to a quantified expression it flips quantifiers as it moves inwards(i.e negation turns all universal quantifiers to existential quantifiers and vice versa, and negates all predicates) </li></ul>Page
26.
The negation of quantifiers <ul><li>Consider the statement, </li></ul><ul><li>The effect of negation of this expression can be determined as, </li></ul>Page
28.
Free and bound variables <ul><li>Consider two predicates </li></ul><ul><li>n>5…..Eq. 1 </li></ul><ul><li>In equation 2, the variable n is bound, it is existentially quantified variable. </li></ul><ul><li>In equation 1, n is free as its value may not be determined or restricted </li></ul>Page
29.
Free and bound variables <ul><li>Example </li></ul><ul><li>In this statement, y and x are two variables. y is universally quantified and it is bound, while x is free variable. </li></ul><ul><li>In statement, </li></ul><ul><li>The occurrence of x in the declaration is binding, any occurrences of x in p are bound, and any occurrences of any variables other than x are free </li></ul>Page
30.
Free and bound variables <ul><li>Example </li></ul><ul><li>Exercise, Determine the scope of the universal and existential quantifiers of the following predicate, </li></ul><ul><li>The distinction between predicates and propositions can be stated as predicates are logical statements which can contain free variables while propositions are logical statements which contain no such holes </li></ul>Page
31.
Substitution <ul><li>Consider statement, </li></ul><ul><li>we may replace the name n with any term t, provided that t is of the same type as n. This process is called substitution: the expression p[t/n] denotes the fact that the term t is being substituted for the variable name n in the predicate p. </li></ul><ul><li>Example, we may denote the substitution of 3 for n in the predicate n>5 by </li></ul>Page
32.
Substitution <ul><li>Also, we may denote the substitution of 3+4 for n in n>5 by </li></ul><ul><li>n>5[3+4/n] </li></ul><ul><li>Substitution is only for free variables </li></ul>Page
33.
Substitution <ul><li>More than one substitution in case of more than one free variable </li></ul><ul><li>Consider predicate, </li></ul><ul><li>Here x and y are both free variables. We may substitute nigel for x as follows, </li></ul><ul><li>Now substituting ken for y, </li></ul>Page
34.
Substitution <ul><li>Similarly, in one step, overall substitution may be denoted as, </li></ul><ul><li>These two substitutions take place sequentially, first nigel is substituted for x, then ken is substituted for y. However, for simultaneous substitutions, </li></ul>Page
35.
Substitution <ul><li>To illustrate the difference between sequential and simultaneous substitution, consider the example, </li></ul><ul><li>In former there is only one occurrence of y and in latter there are two occurrences of y </li></ul>Page
36.
Restriction <ul><li>Filters role in predicate logic </li></ul><ul><li>Considering an example, all natural numbers which are prime numbers and are greater than 2 are odd, may be written as, </li></ul><ul><li>Using a filter, statement may be written as, </li></ul><ul><li>Form of restricted predicates as, </li></ul>Page
37.
Restriction <ul><li>Restriction can also be used in existential quantification, “there has been a female British Prime Minister”, may be written as </li></ul>Page
39.
Exercise <ul><li>Represent the following statement in the form, </li></ul><ul><li>Everyone who likes cheese likes spam </li></ul><ul><li>There is a person who likes cheese that likes spam </li></ul><ul><li>Everyone who likes cheese also likes spam and likes bananas </li></ul>Page
41.
Uniqueness <ul><li>Existential quantifier, allows us to represent statements such as “there is at least one x, such that…”. </li></ul><ul><li>In order to be more specific, consider, “there is exactly one x, such that…” </li></ul><ul><li>Consider an example statement, </li></ul><ul><li>it is the case that the predicate x+1=1 is true for exactly one natural number:0 </li></ul>Page
42.
<ul><li>The operator which allow us to state that “ there is exactly one natural number, x, is denoted as </li></ul><ul><li>As an example, </li></ul>Uniqueness Page
43.
Uniqueness <ul><li>Assuming the statement </li></ul><ul><li>It is sometimes useful to pinpoint exactly which element of X for which predicate p holds. Also, it is convenient to perform some operation on this value. </li></ul><ul><li>The µ operator allows us to do exactly this, the statement ( µ x:X | p) is read as “ the unique x from set X such that p holds of x ” </li></ul><ul><li>Example, ( µ x:N | x+1=1) where µ is associated with value 0 </li></ul>Page
44.
Uniqueness <ul><li>When a unique element of the relevant type does possess the relevant property, then we are free to construct statements as given previously </li></ul><ul><li>On the other hand, µ expressions that are not associated with a unique element generate an undefined value. </li></ul><ul><li>As an example, the µ expressions </li></ul><ul><li>( µ n:N | n is even) </li></ul><ul><li>and </li></ul><ul><li>( µ c:Country | population (c) > 10,000,000) </li></ul><ul><li>are both undefined </li></ul>Page
45.
Uniqueness <ul><li>We can incorporate terms into set comprehensions, so we can apply terms in µ expressions. Expressions of the form, </li></ul><ul><li>return the result of applying the term t to the unique element of the set X which satisfies the predicate p </li></ul><ul><li>gives the value Washington </li></ul>Page
46.
Uniqueness <ul><li>If there is no unique element which possesses the relevant property, then the result is undefined </li></ul><ul><li>and </li></ul><ul><li>are both undefined. </li></ul>Page
47.
Exercise <ul><li>Write the following in terms of µ expressions </li></ul><ul><ul><li>The tallest mountain in the world </li></ul></ul><ul><ul><li>The height of the tallest mountain </li></ul></ul><ul><ul><li>The oldest person in the world </li></ul></ul><ul><ul><li>The nationality of the oldest person in the world </li></ul></ul><ul><ul><li>The smallest natural number </li></ul></ul>Page
50.
Equational Reasoning <ul><li>Law 8 </li></ul><ul><li>If a predicate holds for all elements of a set, then it holds for some of them </li></ul><ul><li>Law 9 </li></ul><ul><li>If a predicate holds for exactly one element of a set, then it holds for at least one of them </li></ul>Page
51.
Equational Reasoning <ul><li>Law 10 </li></ul><ul><li>If p holds for all elements of X and t is a term of type X, then p holds for t </li></ul><ul><li>Example, </li></ul><ul><li>The predicate </li></ul><ul><li>holds for all natural numbers. The term 3+4 is of type N and as such, </li></ul><ul><li>holds. </li></ul>Page
52.
Equational Reasoning <ul><li>Law 11 </li></ul><ul><li>This law states that if t is a term of type X and p holds of t, then we can conclude that p holds for some elements of X </li></ul><ul><li>Example </li></ul><ul><li>The proposition 7 ε N is true and furthermore 7 is prime. As such, </li></ul>Page
53.
Equational Reasoning <ul><li>The quantification of any variables with regards to propositions which are always true or always has absolutely no effect. This notion is captured by following laws, </li></ul><ul><li>Law 12 </li></ul><ul><li>Law 13 </li></ul><ul><li>Law 14 </li></ul><ul><li>Law 15 </li></ul>Page
54.
Equational Reasoning <ul><li>The predicate is concerned with three variables: x, y and z. </li></ul><ul><li>x is bound and y and z are free. As x does not appear in the predicate y=z, we are free to assume that the existential quantification of x has no effect on the truth or falsity of that predicate. </li></ul><ul><li>We conclude that following equivalence holds. </li></ul>Page
55.
Equational Reasoning <ul><li>Law 16 </li></ul><ul><li>It states that as x does not appear free in q, the following holds </li></ul><ul><li>Example, </li></ul>Page
56.
Equational Reasoning <ul><li>Law 17 </li></ul><ul><li>It states that as x does not appear free in q, the following holds, </li></ul><ul><li>Example </li></ul>Page
57.
Equational Reasoning <ul><li>Law 18 </li></ul><ul><li>It states as x does not appear free in q, the following holds </li></ul><ul><li>Example </li></ul>Page
58.
Equational Reasoning <ul><li>Law 19 </li></ul><ul><li>It states as x does not appear free in q, the following holds </li></ul><ul><li>Example </li></ul>Page
59.
Equational Reasoning <ul><li>Example: A theorem in predicate logic </li></ul><ul><li>Proof: </li></ul>Page
63.
Natural deduction <ul><li>Natural deduction can also be extended to predicate logic </li></ul><ul><li>Natural deduction rules for universal quantification </li></ul><ul><li>Rule1 states that if p holds for all values of X, then provided that t is of type X- p holds for t </li></ul>Page
64.
Natural deduction <ul><li>Example: </li></ul><ul><li>All natural numbers which are prime and greater than 2 are odd. 7 is prime and greater than 2 and we may conclude that it is odd. </li></ul>Page
65.
Natural deduction <ul><li>Rules for existential quantification </li></ul><ul><li>If x ε X such that p holds for x, then if we are able to define further predicate, q in which x does not appear free, then we may conclude q </li></ul>Page
66.
Natural deduction <ul><li>Intro rule </li></ul><ul><li>If p is true for any term t of set X, then we conclude that, holds </li></ul>Page
68.
The one-point rule <ul><li>It states that p is a person that likes Emily, but also that the name of person is Rick </li></ul><ul><li>We can conclude that rick ε Person and rick likes emily are both true </li></ul><ul><li>Law 20 </li></ul>Page
69.
The one-point rule <ul><li>Example </li></ul>Page
70.
References <ul><li>Discrete Mathematics with Examples by Simpson </li></ul>Page