Formal methods of software development, Lecture notes of Software Engineering

Prepositional predicate is a formal method concept

Typology: Lecture notes

2022/2023

Uploaded on 01/26/2024

mtiku-tadesse
mtiku-tadesse 🇪🇹

4 documents

1 / 50

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Propositional, Predicate Logics and Set
Getinet Yilma
Propositional logic
Predicate Logic
Set Theory
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32

Partial preview of the text

Download Formal methods of software development and more Lecture notes Software Engineering in PDF only on Docsity!

Propositional, Predicate Logics and Set

Getinet YilmaPropositional logicPredicate LogicSet Theory

Propositional logic

Introduction to Propositional logicProposition OperatorsProposition Operators and Truth TableResult 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
    • PQ
  • 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 PQ 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

  1. p(q(  q)) ≡ p
  2. (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 logicQuantifiersApplicationCorrectness

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:

  1. Universal Quantifiers
  2. 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.”  xD, 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: