Upload
nickolas-greer
View
214
Download
0
Tags:
Embed Size (px)
Citation preview
Propositional and predicate logic
At the end of this lecture you should be able to:
• distinguish between propositions and predicates;
• utilize and construct truth tables for a number of logical connectives;
• explain the three-valued logic system;
• determine whether two expressions are logically equivalent;
• explain the difference between bound and unbound variables;
• bind variables by substitution and by quantification.
Propositions
In classical logic, propositions are statements that are either TRUE or FALSE.
Following are examples of propositions that evaluate to TRUE
There are seven days in a weekAccra is the capital of Ghana2 + 4 = 6
Following propositions evaluate to FALSE
The angles of a triangle add up to 360London is the capital of France2 - 4 = 7
Using symbols
In mathematics we often represent a proposition symbolically by a variable name such as P or Q.
For example:
P : I go shopping on WednesdaysQ : 102.001 > 101.31
Logical connectives
Propositions can be combined into compound statements by operators called logical connectives;
The purpose of defining these connectives is to provide precise meanings to such words as "and" and "or" that occur in the natural language;
The way we give semantic meaning to these connectives is to provide tables known as truth tables;
These give a value for every possible combination of the values of the individual statements that make up the compound proposition.
Negation
the operation known as negation yields a proposition with a value opposite to that of the original one;
the operator in question is called the not operator;
it is represented by the symbol ¬;
if P is a proposition, then not P is represented by:
¬P
if P represented the statement I like dogs,
then ¬P represents the statement I do not like dogs.
The truth table for the 'not' operator
P ¬P
T
TF
F
The and operator
The operator known as and is represented by the symbol .
The statement P and Q is therefore represented by:
P Q
If P represents: I like shopping
and Q represents: The sun is shining
then P Q would represent the statement:
I like shopping and the sun is shining.
The truth table for 'and'
P Q P Q
T T T
T
T
F F
F F
F F F
The or operator
The operator known as or is represented by the symbol
;
The statement P or Q is therefore represented by:
P Q
If P represents: It is raining
and Q represents: Today is Tuesday
then P Q would represent the statement:
It is raining or today is Tuesday.
The truth table for ‘or'
P Q P Q
T T T
T
T
F T
F T
F F F
The truth table for 'exclusive or'
P Q P Q
T T F
T
T
F T
F T
F F F
The implication operator
The implication operator attempts to give meaning to the expression P implies Q;
The implication operator is represented by the symbol
The statement P implies Q is therefore represented by:
P Q
An alternative way of expressing implication is if P then Q.
if P represents: It is Wednesday
and Q represents: I do the ironing
then P Q would represent the statement:
if it is Wednesday I do the ironing.
The truth table for implication
P Q P Q
T T T
T
T
F F
F T
F F T
The equivalence operator
The idea of equivalence deals with the "otherwise" part of implication;
This is analogous to an IF ... THEN ... ELSE statement in a programming language;
It is represented by the symbol .
Effectively it states:
if P is true then Q is true, otherwise Q is false;
in other words:
P is equivalent to Q, which is represented by:
P Q
The truth table for equivalence
P Q P Q
T T T
T
T
F F
F F
F F T
Three-valued logic
Both in the world of computing and the world of mathematics, occasions arise when it is not possible to evaluate expressions precisely;
For example, when somebody tried to evaluate the square root of a negative integer;
It is possible to account for such situations by defining a three-valued logic.
Three valued truth table for ‘and’
P Q P Q
T T T
T F F
T Undefined Undefined
F T F
F F F
F Undefined F
Undefined T Undefined
Undefined F F
Undefined Undefined Undefined
Compound statements Use brackets to avoid confusion
Illustration
Assume that
P represents the statement Physics is easyQ represents the statement Chemistry is interesting
then: ¬P Q would mean
Physics is not easy and chemistry is interesting.
And ¬(P Q) would mean
It is not true both that physics is easy and that chemistry is interesting.
Logical equivalence
Two compound propositions are said to be logically equivalent if identical results are obtained from constructing their truth tables;
This is denoted by the symbol .
For example ¬ ¬P P
P ¬ P ¬ ¬ P
T TF
F T F
Logical equivalence : a demonstration
(P Q) P Q
P Q P Q (P Q)
T
T
T
T
T T
T
T
F
F
F F
F
F
F
F
P Q P Q
T
T
T
F
T
T
T
T
F
F
F
F
Tautologies
A statement which is always true (that is, all the rows of the truth table evaluate to true) is called a tautology.
For example, the following statement is a tautology:
P P
This can be seen from the truth table:
P ¬ P P P
T
T
T
FT
F
Contradictions
A statement which is always false (i.e. all rows of the truth table evaluate to false) is called a contradiction.
For example, the following statement is a contradiction:
P P
Again, this can be seen from the truth table:
P ¬ P P P
T
F
F
FT
F
Sets
The propositional logic allows us to argue about individual values, but it does not give us the ability to argue about sets of values.
A set is any well-defined, unordered, collection of objects;
For example we could refer to:
the set containing all the people who work in a particular office;
the set of whole numbers from 1 to 10;
the set of the days of the week;
the set of all the breeds of cat in the world.
We often denote the name of the set by an upper case letter and the elements by lower case letters.
For example:
A = {s, d, f, h, k } B = {a, b, c, d, e, f}
the symbol means "is an element of".
the statement "d is an element of A" is written: d A
the statement "p is not an element of A" is written: p A
For the purpose of reasoning about sets of values, a more powerful tool than the propositional logic has been devised, namely the predicate logic;
Representing sets
Predicates
A predicate is a truth valued expression containing free variables;
These allow the expression to be evaluated by giving different values to the variables;
Once the variables are evaluated they are said to be bound.
Examples
C(x): x is a catStudies(x,y): x studies yPrime(n): n is a prime number
Binding Variables
Predicates such as those above do not yet have a value - they only have a value when the variables themselves are given a value;
There are two ways in which this can be done.
1. By substitution (giving a value to the variable)
2. By Quantification
Substitution
C( x )
Studies( x , y )
Prime( x )
Simba ): Simba is a cat
Olawale, physics ): Olawale studies physics
3 ): 3 is a prime number
Quantification
A quantifier is a mechanism for specifying an expression about a set of values;
There are three quantifiers that we can use, each with its own symbol:
The Universal Quantifier,
The Existential Quantifier
The Unique Existential Quantifier !
The Universal Quantifier,
This quantifier enables a predicate to make a statement about all the elements in a particular set.;
For example:
If M(x) is the predicate x chases mice, we could write:
x Cats M(x)
this reads:
For all the x’s which are members of the set Cats, x chases mice
Or
All cats chase mice.
The Existential Quantifier
In this case, a statement is made about whether or not at least one element of a set meets a particular criterion.
For example
if, P(n) is the predicate n is a prime number, we could write:
n P(n)
this reads:
There exists an n in the set of natural numbers such that n is a prime number
or
There exists at least one prime number in the set of natural numbers.
The Unique Existential Quantifier !
This quantifier modifies a predicate to make a statement about whether or not precisely one element of a set meets a particular criterion.
For example
If G(x) is the predicate x is green, we could write
!x Cats G(x)
this would mean:
There is one and only one cat that is green.