Presentation is loading. Please wait.

Presentation is loading. Please wait.

Propositional and predicate logic

Similar presentations


Presentation on theme: "Propositional and predicate logic"— Presentation transcript:

1 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.

2 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 week Accra is the capital of Ghana 2 + 4 = 6 Following propositions evaluate to FALSE The angles of a triangle add up to 360 London is the capital of France 2 - 4 = 7

3 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 Wednesdays Q : >

4 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.

5 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.

6 The truth table for the 'not' operator

7 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.

8 The truth table for 'and' P Q P  Q T T T T F F F T F F F F

9 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.

10 The truth table for ‘or' P Q P  Q T T T T F T F T T F F F

11 The truth table for 'exclusive or'
P Q P  Q T T F T F T F T T F F F

12 The implication operator
The implication operator attempt 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.

13 The truth table for implication
Q P  Q T T T T F F F T T F F T

14 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

15 The truth table for equivalence
P Q P  Q T T T T F F F T F F F T

16 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, this could occur when a program terminates incorrectly, or 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, which allows a proposition to take the value undefined as well as true or false.

17 Three valued truth table for ‘and’
P Q P  Q T F Undefined

18 Compound statements Use brackets to avoid confusion Illustration
Assume that P represents the statement Physics is easy Q 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.

19 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 F T F T F

20 Logical equivalence : a demonstration
(P  Q)  P  Q P Q P  Q (P  Q) P Q P  Q T F T F F F F F T F T T F T T F T F T T T T

21 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 F F T T T

22 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 F T F

23 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.

24 Representing sets 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;

25 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 cat Studies(x,y): x studies y Prime(n): n is a prime number

26 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. By substitution (giving a value to the variable) By Quantification

27 Substitution C( x ) Studies( x , y ) Prime( x )
Simba ): Simba is a cat Olawale, physics ): Olawale studies physics 3 ): 3 is a prime number

28 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 !

29 For all the x’s which are members of the set Cats, x chases mice
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.

30 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.

31 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.


Download ppt "Propositional and predicate logic"

Similar presentations


Ads by Google