0% found this document useful (0 votes)
24 views39 pages

M2-RL-Mathematics Formal Methods

The document discusses various topics in discrete mathematics including permutations, combinations, propositional logic, sets, relations, and graph theory. It defines key terms and concepts for each topic and provides examples to illustrate them. Discrete mathematics concepts are important tools for test engineers to bring rigor, precision and efficiency to testing.

Uploaded by

ryan2318722
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views39 pages

M2-RL-Mathematics Formal Methods

The document discusses various topics in discrete mathematics including permutations, combinations, propositional logic, sets, relations, and graph theory. It defines key terms and concepts for each topic and provides examples to illustrate them. Discrete mathematics concepts are important tools for test engineers to bring rigor, precision and efficiency to testing.

Uploaded by

ryan2318722
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 39

Software Testing

Methodologies
BITS Pilani Prashant Joshi
Module 2: Agenda

Module 2: Mathematics & Formal Methods

Topic 2.1 Permutations & Combinations

Topic 2.2 Propositional Logic

Topic 2.3 Discrete Math

Topic 2.4 Graph Theory

2 Software Testing Methodologies


Math for Test Engineers

• For Test Engineers – Know our focus


• Testing is a craft; math are the craftsman’s
tools
• Bring Rigor, Precision and Efficiency
• Our treatment of math
• Largely informal – What is required for Test Engineers and not
for mathematicians
• Our focus is discrete mathematics
• Aim is
• To make test engineers better at their craft

3 Software Testing Methodologies


BITS Pilani
Pilani Campus

Topic 2.1: Permutations &


Combinations
Permutation & Combination

• Selecting several things out of a larger


group

• Two aspects to look at


• Order
• Repetition

5 Software Testing Methodologies


Combination

• Order does not matter


• Example: Fruits in a fruit salad. It does not
matter in which the fruits are put into the
salad. It could be Apple, Banana and
Strawberry or any other order

6 Software Testing Methodologies


Permutation

• Order does matter


• Example: A lock which opens with a
sequence of digits. We call it the
combination lock. It is indeed a
permutation lock
• Sequence 437 (347 will never work!)

Indeed a permutation lock

7 Software Testing Methodologies


Permutation

• Repetition – Yes & No


• Example
• Repetition allowed: Digits in the permutation lock may repeat like
“333” or “557”
• Repetition now allowed: First three standings in a running race

8 Software Testing Methodologies


Permutation

• Choosing r things out of n

Repetition
• n possibilities for each of the r choices 𝑟
n
Cr
𝑛
Without Repetition
• Possibilities reduce with every selection
𝑛!
( 𝑛− 𝑟 ) !

9 Software Testing Methodologies


Combination

Choosing r things out of n

Repetition allowed
( 𝑛+𝑟 −1 ) !
𝑟 ! ( 𝑛 −1 ) !

Without Repetition

𝑛!
𝑟 ! ( 𝑛− 𝑟 ) !

10 Software Testing Methodologies


Software Testing
Methodologies
BITS Pilani Prashant Joshi
BITS Pilani
Pilani Campus

Topic 2.2: Propositional Logic


Propositional Logic

• A proposition is a sentence that is either TRUE


or FALSE
• Given a proposition, it is always possible to tell
if it is T or F
• Propositional logic has operations, expressions,
and identities
• Logical Operators
• Logical Expressions
• Logical Equivalence

13 Software Testing Methodologies


Propositional Logic

14 Software Testing Methodologies


Software Testing
Methodologies
BITS Pilani Prashant Joshi
BITS Pilani
Pilani Campus

Topic 2.3: Discrete Math


Propositional Logic

• A proposition is a sentence that is either TRUE


or FALSE
• Given a proposition, it is always possible to tell
if it is T or F
• Propositional logic has operations, expressions,
and identities
• Logical Operators
• Logical Expressions
• Logical Equivalence

17 Software Testing Methodologies


Propositional Logic

18 Software Testing Methodologies


BITS Pilani
Pilani Campus

Topic 2.3: Discrete Math


Set Theory

Collection of things which have a common property


• Things that one wears (Specific activity wear)
• Sports kit for badminton
• Months in a year or months with 31 days
Listing
Elements

Decision rule
Decision rule

20 Software Testing Methodologies


Venn Diagrams

• Picture(s) for Sets


• A set of depicted as a circle with interior of the
circle corresponds to the elements of the set

U
April
November
September
June

Venn diagram of 30 day month


21 Software Testing Methodologies
Set Operations

• Union is the set


• Intersection is the set
• Complement of A is the set
• Relative complement of B WRT A is the set

• Symmetric difference of A and B is the set

Refer to Venn Diagrams of basic sets in T1

22 Software Testing Methodologies


Set Operations

• Unordered pair
• Ordered pair
What is the difference?

• Cartesian Product

23 Software Testing Methodologies


Set Relations

• Subset
• A is subset of B if and only if all elements of A are also in B
• Proper subset
• A is a proper subset of B if and only if there is at least one element in B which is
not in A
• Equal Sets
• Each is a subset of the other

Look up the notations in the book T1 Chapter 3

24 Software Testing Methodologies


Set Partitions

• Particularly important for test engineers


• Divide the whole in parts

• Given a set B, and a set of subsets A1, A2…, An


of B, the subsets are a partition of B iff

, and

25 Software Testing Methodologies


Software Testing
Methodologies
BITS Pilani Prashant Joshi
BITS Pilani
Pilani Campus

Topic 2.4: Graph Theory


Graph

• A graph (also known as linear Graph) is an abstract


mathematical structure defined from two sets – set of
nodes and set of edges that form connections between
nodes
• Example: Computer Network
• Definition
• A Graph G = (V,E) is composed of a finite (and
nonempty) set V of nodes and a set of E of unordered
pairs of nodes
V  {n1 , n2 , n3 ..., nm )

E  {e1 , e2 , e3 ..., e p )

28 Software Testing Methodologies


A Graph

• Nodes and Edges Sets


• Connection between nodes

n1 n2 n5
e1 e4

e2

n3 n3 n7
e3

e5

n6

29 Software Testing Methodologies


Use of representation

• Nodes as program statements


• Edges
• Flow of control
• Define/use relationships

30 Software Testing Methodologies


Degree of a Node

• The degree of a node in a graph is the number of edges that


have that node as an endpoint deg(n)

n1 n2 n5
e1 e4

e2

n3 n3 n7
e3

deg(n1) = 2 e5
deg(n2) = 2
deg(n7) = 0 n6

31 Software Testing Methodologies


Use of Degree of Node

• Indicates Popularity
• Social scientists
• Social interactions
• Friendship/communicates with
• Example:
• Graph with nodes are objects and edges are
messages; degree can represent the extent of
integration testing that is appropriate for the object

32 Software Testing Methodologies


Incidence Matrix

• The incidence matrix is a graph G=(V,E) with m nodes


and n edges is a m x n matrix, where the element in row
i, column j is a 1 if and only if node i is an endpoint of
edge j; otherwise the element is 0
e1 e2 e3 e4 e5
n1 1 1 0 0 0
n2 1 0 0 1 0
n3 0 0 1 0 0
n4 0 1 1 0 1
n5 0 0 0 1 0
n6 0 0 0 0 1
n7 0 0 0 0 0

33 Software Testing Methodologies


Use of this representation

• Degree of node is zero


• Unreachable node

34 Software Testing Methodologies


Adjacency Matrix

• Deals with connections


• The adjacency matrix of a Graph G=(V,E) with m nodes
is an m x m matrix, where the element in row i, column j
is 1 if and only if an edge exists between node i and
node j; otherwise, the element is 0
n1 n2 n3 n4 n5 N6 n7
n1 0 1 0 1 0 0 0
n2 1 0 0 0 1 0 0
n3 0 0 0 1 0 0 0
n4 1 0 1 0 0 1 0
n5 0 1 0 0 0 0 0
n6 0 0 0 1 0 0 0
n7 0 0 0 0 0 0 0

35 Software Testing Methodologies


Use of this representation

• Deals with connections


• Useful for later graph theory concepts example: paths

36 Software Testing Methodologies


Paths

• A path is a sequence of edges such that for any adjacent


pair of edges ei, ej in the sequence, the edges share a
common (node) endpoint

Path Node Sequence Edge Sequence


Between n1 and n5 n1, n2, n5 e1, e4
Between n6 and n5 n6, n4, n1, n2, n5 e5, e2, e1, e4
Between n3 and n2 n3, n4, n1, n2 e3, e2, e1

37 Software Testing Methodologies


Graph
n1

• n1 represents a series of statements


• n7 also represents a series of statement n2
• Is this the correct representation?
• n3
How does this help us get to testing?
• What does this help in?
n4

n5

n6

n7

38 Software Testing Methodologies


Software Testing
Methodologies
BITS Pilani Prashant Joshi

You might also like