0% found this document useful (0 votes)
34 views

Formal Methods in Software Engineering: Lecture # 05

The document discusses formal methods in software engineering, specifically covering rules of inference and logical deductions. It introduces basic rules of inference like conjunction elimination and conditional elimination. It also discusses mathematical data types like sets, operations on sets like union and intersection. It provides examples of set notations and proving set equalities. The goal is to use logic rules and reasoning about sets to prove that Superman does not exist by deriving a contradiction.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Formal Methods in Software Engineering: Lecture # 05

The document discusses formal methods in software engineering, specifically covering rules of inference and logical deductions. It introduces basic rules of inference like conjunction elimination and conditional elimination. It also discusses mathematical data types like sets, operations on sets like union and intersection. It provides examples of set notations and proving set equalities. The goal is to use logic rules and reasoning about sets to prove that Superman does not exist by deriving a contradiction.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

FORMAL METHODS IN

SOFTWARE
ENGINEERING
LECTURE # 05

RULES OF INFERENCE AND LOGICAL DEDUCTIONS


RULES OF
INFERENCE
INTRODUCTION

• This rule states that we can make complex propositions, if


we are given simple propositions
• Given p we can conclude p or q is true
P
_______
P or q
• Given q, we can conclude p or q is true
Q
________
P or Q
INTRODUCTION RULE OF
CONDITIONAL(=>)
• If we know q is true, we can conclude p=>q is also true.
[p] // no matter what value of P

Q
-----
P=>q is true
ELIMINATION RULE

• If we are given complex proposition, we can conclude a simple


proposition from it.
• Given p and q
• When p and q is true, it means we can conclude p is true.
P and Q
---------
p

• When p and q is true, it means we can conclude q is true.


ELIMINATION RULE OF
CONDITIONAL(=>)
• Given p is true and p=>q is true, we can conclude q is also
true.
ELIMINATION RULE OF NEGATION

• Given P and not p= false


• If we started with a false statement, we can conclude anything

• Given False
• We can conclude p
• Given False
• We can conclude q
EXAMPLE

Does the Superman Exist?


If Superman were able and willing to prevent evil, he would
do so. If Superman were unable to prevent evil, he would be
incapable; if he were unwilling to prevent evil, he would be
malevolent. Superman does not prevent evil. If Superman
exists, he is neither incapable nor malevolent. Therefore
Superman does not exist.
• Superman exists X
• Superman is willing to prevent evil W
• Superman is able to prevent evil A
• Superman is malevolent M
• Superman is incapable I
• Superman prevents evil E
• Our objective is to prove the proposition:

((W and A)  E)
and ((not A)  I)
and ((not W)  M)
and (not E)
and (X  not (I or M))
 not X
MATHEMATICAL
DATA TYPES
SETS

• Set is a bunch of objects, which are called the elements.


• Order of elements is not significant.
• For example, here are some sets:
• A = {Alex, Tippy, Shells, Shadow} dead pets
• B = {red, blue, yellow} primary colors
• C = {{a,b} , {a,c} , {b,c}} a set of sets
• The expression e ∈ S asserts that e is an element of set S
• For example
• blue ∈ B
SOME POPULAR SETS

• Mathematicians have devised special symbols to represent some


common sets.
• symbol set elements
• ∅ the empty set none
• N nonnegative integers {0, 1, 2, 3,...}
• Z integers {...,−3,−2,−1, 0, 1, 2, 3,...}
• Q rational numbers 1 , −5 , 16, etc.
2 3

• R real numbers π, e, −9, √2, etc.


• C complex numbers i, , √2 − 2i, etc.
2
COMPARING AND COMBINING
SETS
• The expression S ⊆ T indicates that set S is a subset of set T (it could
be said that S = T)
• N ⊆ Z and Q ⊆ R (every rational number is a real number .
• There are two ways to combine sets
• Union of sets
• Intersection of sets
• Example
• Let
• X ::= {1, 2, 3}
• Y ::= {2, 3, 4}
COMPARING AND COMBINING
SETS
• Unión of X and Y is :
• X ∪ Y = {1, 2, 3, 4}.

• Intersection of X and Y is:


• X ∩ Y = {2, 3}.
COMPLEMENT OF SET

• For any subset, A, we define A bar to be the set of all elements


not in A
• For example
• Positive real numbers is the set of negative real numbers
together with zero
• R+(bar) = R(bar) ∪{0} .
• Let A and B are disjoint sets A ∩ B = ∅
• then we can write set A as
• :A is a subset of the complement of B.
POWER SET

• The set of all the subsets of a set,


• P(A), of A.
• So B ∈P(A) Iff B ⊆ A.
• P({1, 2}) are ∅, {1} , {2} and {1, 2}.
SET BUILDER NOTATION

• An important use of predicates is in set builder notation.


• A ::= {n ∈ N | n is a prime and n =4k +1 for some integer k}
• The set A consists of all nonnegative integers n for which
the predicate “n is a prime and n =4k +1 for some integer
k” is true. Thus, the smallest elements of A are: 5, 13, 17, 29,
37, 41, 53, 57, 61, 73,....
• B ::= {x ∈ R | x3 − 3x +1 > 0 }
• C ::={ a + bi ∈ C | a2 +2b2 ≤ 1 }
PROVING SET EQUALITIES

• X = Y means that z ∈ X if and only if z ∈ Y , for all elements,


z.
• For example
• A ∩ (B ∪ C)=(A ∩ B) ∪ (A ∩ C)
QUESTIONS

You might also like