Download Formal methods of software development and more Lecture notes Software Engineering in PDF only on Docsity!
Propositional, Predicate Logics and Set
Getinet Yilma Propositional logic Predicate Logic Set Theory
Propositional logic
Introduction to Propositional logic Proposition Operators Proposition Operators and Truth Table Result terminology
Propositional Logic…
- A proposition is a statement that can be either true or false; it must be one
or the other, and it cannot be both.
- The following are propositions:
- the reactor is on;
- the wing-flaps are up; and
- a program P terminates.
- The following are not propositions
- are you going out somewhere?
- and 2+
- Propositions can be atomic (single truth value) or complex (multiple joined
with connectives)
Proposition connectives
- Compound propositions combined simple ones with Logical operators
- A truth table for some formula p, q and operators describe the behavior of a formula under all possible interpretations.
p q p q p q p q p q
T T T T T T
T F F T F F
F T F T T F
F F F F T T
P P
T F
F T
Example
- Nebil and Yasin are cousins if their fathers are brothers
- P: Nebil and Yasin are Cousins
- Q: Their fathers are brothers
- P=>Q A polygon is a triangle if and only if A polygon has exactly 3 sides
- P: A polygon is a triangle.
- Q: A polygon has exactly 3 sides
- P: x + 2 = 7 Q: x = 5
- PQ
- Tautology : A compound proposition which is always true P or ~P is always true
- Contradiction : A compound proposition which is always false
- Satisfiable (consistent) happen when at least one (1) truth value brings the TRUE result.
Examples
- Logically Equivalent If PQ is always true then P and Q are said to be logically
equivalent.
- We write P≡Q e.g. ~(𝑃 ˅𝑄) ≡ ~𝑃˄~Q
Verify the following logical equivalences
- p(q( q)) ≡ p
- (p ( q)) ≡ ( p) q Verify truth tables to check whether the following are tautologies, contradictions or neither. p (p q) q (p ( p)) p (p q)
- Can an atomic statement be a tautology or a contradiction? Explain
Propositional logic: limitations
- Propositional logic: the world is described in terms of elementary propositions and their logical combinations. - A program P terminates - Program refers to object, terminates refers properties
- Objects and properties are hidden in the statement, it is not possible to reason about them
- Statements that hold for many objects must be enumerated
- Example: –
- John is a SE Student John has passed SEng
- Ann is a SE Student Ann has passed SEng
- Ken is a SE Student Ken has passed SEng
- Replacing John, Ann and Ken by a variable x
- x is a SE Student x has passed SEng
Propositional logic: limitations
- In Propositional logic statements that define the property of the group of objects are not quantified. - All new cars must be registered. - Some of the light switches can be turned off.
- We can use quantifiers
- Universal quantifier – the property is satisfied by all members of the group new cars must be registered
- Existential quantifier – at least one member of the group satisfy the property the light switches can be turned off
Predicate logic
Introduction predicate logic Quantifiers Application Correctness
Predicate Logic
- Predicate logic , first-order logic or quantified logic is a formal language in
which propositions are expressed in terms of predicates, variables and
quantifiers.
- Quantifiers express the extent to which a predicate is true over a range of
elements.
- For example, imagine we have the statement: “Every person who is 21 years
of age or older is able to purchase alcohol. Sarah is 21 years old.”
- what does “every person” really mean?
- As the range of possibilities is too broad, we need to apply one of two types of
quantifiers to help us achieve our goal:
- Universal Quantifiers
- Existential Quantifier
Predicate Logic
- Existential Quantifier is the proposition that a property is true for some value
in a particular domain.
- There exists an x such that P(x)
- There exists an element x in the domain such that P(x)
- For some x, P(x)
- There is some x such that P(x) And is symbolically denoted Suppose we have two predicate variables x and y, where the domain for x is F = {foxes} and y has the domain S = {snails}, where P(x,y) is “Foxes are faster than Snails.” x D, P(x) “there exists x, belonging to domain D, such that p(x) is true
Predicate Logic
Quantifiers In Truth Table
Predicate Logic
Quantifier Negation
- Using the five circles, as seen above, we make the following statement: “Some circles are shaded.”
- What would the negation of this statement be?
- “Some circles are not shaded.” is correct?
- No! Because this statement is also trues
- Remember, a negation must have the opposite truth value.
- “All circles are not shaded.” is correct? Yes.
- The trick is to flip the universal quantifier to an existential quantifier or vice versa, and then negate the statement, “Some circles are shaded.” “ All circles are not shaded .”
- Quantifiers give the ‘range’ and ‘universe’ over which the statement is being claimed.
Predicate Logic
The negation of quantification has the following properties: