Overview Discrete Mathematics for Testers Set Theory Functions

Slides:



Advertisements
Similar presentations
Analysis of Algorithms CS 477/677
Advertisements

Overview Structural Testing Introduction – General Concepts
13 May 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Introduction.
1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Instructor Kostas Kontogiannis.
1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Instructor Kostas Kontogiannis.
1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Instructor Kostas Kontogiannis.
1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Case Studies Instructor Paulo Alencar.
UWaterloo An undergraduate degree program in Software Engineering at the University of Waterloo, jointly sponsored by the depts of CS and E&CE.
The Independent Choice Logic for modeling multiple agents under uncertainty David Poole Presented by Mei Huang Mar. 18,2005.
Overview Discrete Mathematics and Its Applications Baojian Hua
Computing Fundamentals 2 Overview Lecturer: Patrick Browne Room [KA] , Lab [KA] Based on Chapter 19. A Logical approach to Discrete Math.
CSE 3504: Probabilistic Analysis of Computer Systems Topics covered: Discrete time Markov chains (Sec )
CS 561, Sessions 28 1 Uncertainty Probability Syntax Semantics Inference rules.
1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Instructor Kostas Kontogiannis.
Graphing Piecewise Functions
1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Instructor Kostas Kontogiannis.
CS4472A : Specification, Testing and Quality Assurance Instructor: Shaimaa Ali.
Overview Integration Testing Decomposition Based Integration
1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Instructor Kostas Kontogiannis.
1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Instructor Kostas Kontogiannis.
1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Instructor Kostas Kontogiannis.
Mathematics in Computer Science at Loras College Steve Mosiman.
1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Instructor Kostas Kontogiannis.
1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Instructor Kostas Kontogiannis.
Knowledge Management in Theory and Practice
Chapter 2: Graphs and Networks Lesson 2: Hello Mr Euler…
Discrete Mathematics CS204 Spring CS204 Discrete Mathematics Instructor: Professor Chin-Wan Chung (Office: Rm 3406, Tel:3537) 1.Lecture 1)Time:
Discrete Math 6-1 Copyright © Genetic Computer School 2007 Lesson 6 Probability.
$100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300.
Unit Testing LEVEL GAME.  Create pieces array  Call move or interact  Use getters or return type to verify correct behavior  Test ends (don’t go GameEngine.BOARD_SIZE-1)
Discrete Mathematics ( 離散數學 ) Ming-Jer Tsai. Outline What is Discrete Mathematics? Why learn Discrete Mathematics? What will be taught in the class? How.
CS-7081 Irreflexive – (13 - 8). CS-7082 Example – (13 - 9)
Overview Functional Testing Boundary Value Testing (BVT)
MAT 2720 Discrete Mathematics Section 8.2 Paths and Cycles
Lecture 17: Trees and Networks I Discrete Mathematical Structures: Theory and Applications.
CS 614: Theory and Construction of Compilers Lecture 15 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
Knowledge Management in Theory and Practice
Lecture 16: Graph Theory III Discrete Mathematical Structures: Theory and Applications.
Statistics and Probability Theory Lecture 01 Fasih ur Rehman.
1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Instructor Kostas Kontogiannis.
Graphs Definition: a graph is an abstract representation of a set of objects where some pairs of the objects are connected by links. The interconnected.
Belief Networks Kostas Kontogiannis E&CE 457. Belief Networks A belief network is a graph in which the following holds: –A set of random variables makes.
BUSINESS MATHEMATICS & STATISTICS. LECTURE 1 COURSE OVERVIEW.
Math 8 Unit 7: Data Analysis and Probability. What you’ll learn: Critique ways in which data are presented Solve problems that involve the probability.
CS491/691: Introduction to Aerial Robotics YOUR TEAM NAME YOUR TOPIC TITLE (CONTROL, ESTIMATION, ETC)
CS 2130 Computational Structures (Discrete Mathematics for Computing)
UWaterloo An undergraduate degree program
Overview Theory of Program Testing Goodenough and Gerhart’s Theory
Unweighted Shortest Path Neil Tang 3/11/2010
Formal Language.
Lecture 15: Graph Theory II
Probability & Statistics Probability Theory Mathematical Probability Models Event Relationships Distributions of Random Variables Continuous Random.
Deep and Wide: Domain & Range
Normal Probability Distributions
Guide for writing a Software Testing Document
Discrete Mathematics Lecture 6: Set and Function
THE NORMAL DISTRIBUTION AND THE 68–95–99.7% RULE
Overview Functional Testing Boundary Value Testing (BVT)
Discrete Mathematics Lecture 13_14: Graph Theory and Tree
(4)² 16 3(5) – 2 = 13 3(4) – (1)² 12 – ● (3) – 2 9 – 2 = 7
DiGraph Definitions Adjacency Matrix Adjacency List
Introduction to Modeling
Overview Functional Testing Boundary Value Testing (BVT)
15.
Chapter 5: Graphs & Functions
Ordered Pair – (11 - 2) CS-708.
Advanced Software Engineering Ch 1 – Engineering Science
Line Graphs.
Overview Functional Testing Boundary Value Testing (BVT)
Functions What is a function? What are the different ways to represent a function?
Presentation transcript:

ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Instructor Kostas Kontogiannis

Overview Discrete Mathematics for Testers Set Theory Functions Relations Probability Graphs Representation Paths Directed Graphs Graphs for Testing

Set Definition Format Explicit enumeration: Using decision rules: Example: Y = {10, 20, 30, 40} Using decision rules: Examples: Y = {item_number | 80 < item_number < 100} Y = {item_number : 80 < item_number <100} Y = {x | x is positive integer} Y = {x | PI(x)} Empty set: A set with no elements Y = {year : 2012 < year < 1812} = {} = O

Venn Diagrams Diagrams that illustrate diferent set relationships or illustrate a set with respect to the domain (U) Set operations: Union : A U B = { x : x in A or x in B} Intersection: A ∩ B = {x : x in A and x in B} Complement: A* = {x : x not in A} Relative complement: A – B = {x : x in A and x not in B} Symmetric difference: A B = {x: x in A x in B} = = (A U B) – (A ∩ B) + +

Set Relations and Partitions A Subset B: a in A  a in B A Proper Subset B: A subset B and (B – A) ≠ O Equal sets: A = B iff A subset B and B subset A Given a set B and a set of subsets A1, A2, An of B, the subsets are a partition of B iff A1 U A2 U .. An = B For i ≠ j Ai ∩Aj = O

Functions, Domains, Ranges Given two sets A and B, a function f :A  B is a subset of the product A X B such that for any of ai, aj in A, there exist bi, bj in B such that f(ai) = bi, and f(aj) = bj. The set A is called the domain of f and B is called the range of f. The function f can be represented as a set of pairs.

Function Types Functions are further described by the particulars of the mapping e.g. f(A) = {bi in B : bi = f(ai) for some ai in A} This set is sometimes called the image of A under f Types of functions that relate the image and the range are: Function f is a function of A onto B iff f(A) = B Function f is a function of A into B iff f(A) proper subset B Function f is a one-to-one function from A to B iff for all ai, aj in A, s.t. ai ≠aj implies that f(ai) ≠ f(aj)

Function Composition Suppose we have sets and functions such that the range of one is the domain of the next: f: A  B g: B  C h: C  D We can define a new function w:A  D such that w(a) = (h o g o f) (a) = h(g(f(a))) So, if f(a) = b, and g(b) = c, and h(c) = d then w(a) = h(g(f(a))) = h(g(b)) = h(c) = d

Application Snapshot Causal Flow Non-Causal Flow a f b g c a f g c b b

Relations Given two sets A, B a relation R is a subset of the Cartesian product A X B Functions are a special case of a relation: Both are subsets of some Cartesian product Functions have the additional requirement that a domain element can not be associated with more than one range element. When a relation is not a function then is also called a mapping. A relation has a property called cardinality

Relations among Sets Given two sets A, B, and a relation R among these sets, the cardinality of R is: one-to-one iff R is a one-to-one function from A to B many-to-one: iff R is a many-to-one function from A to B one-to-many: iff at least one element a in A is in two ordered pairs in R, that is (a, bi) in R and (a, bj) in R. many-to-many: iff at least one element a in A is in two ordered pairs in R, that is (a, bi) in R and (a, bj) in R and one element b in B is in two ordered pairs in R, that is (ak, b) in R and (an, b) in R

Participation of a Relation Let R be a relation s.t. R is a subset of A X B The participation of the relation R can be: total participation: iff every element of A is in some ordered pair in R partial participation: iff some element of A is not in any ordered pair in R onto participation: iff every element of B is in some ordered pair in R into participation: iff some element of B is not in some element in R

Relations on a Single Set Let R be a relation defined in the same set A X A A relation R is: reflexive: iff for all a in A <a, a> in R symmetric: iff <a,b> in R then <b,a> in R anti-symmetric: if <a,b> in R and <b,a> in R then it implies that a=b transitive: iff <a,b> in R and <b,c> in R then <a,c> in R Such a relation R is an ordering relation if it is reflexive, anti-symmetric and, transitive. Similarly, R is an equivalence relation if it is reflexive, symmetric, and transitive.

Propositional Logic Propositions are sentences specified in propositional logic notation that can be evaluated to True or False. A simple proposition (e.g. p, q, r) is a valid sentence Valid sentences can be constructed by other sentences using logical operators (and, or, not, implies, exclusive_or) Two proposition logic sentences are equivalent iff their truth tables are identical (e.g. S= p  q) is equivalent with the sentence W = ~p or q) A proposition is a tautology if it is always true (e.g. S = a or ~a) A proposition is a contradiction if it is always false (e.g. S = a and ~a)

Probability Theory Events: things that happen Universe of Discourse: all events that can possibly happen, and is denoted by U. Let p is a proposition about elements in U: The truth set of a proposition p, written T(p), is the set of all elements in U for which p is true (note T(p) U T(~p) = U) The probability that a proposition p is true is defined as Pr(p) = |T(p)| / |U| The definition of U is crucial on determining the value of Pr(p) Facts: Pr(~p) = 1 – P(p) Pr(p and q) = Pr(p) * Pr(q) Pr(p or q) = Pr(p) + Pr(q) – Pr(p and q)

Graph Theory for Testers A graph G = (V, E) is composed of a finite and non empty set V = {n1, n2, nm) of nodes and a set E = {e1, e2, ep} of edges, where each edge ek = {ni, nj}, for some nodes ni, nj in V.

Example e1 V = {n1, n2, n3, n4, n5, n6, n7} E = {e1, 2, e3, e4, e5} = {{n1, n2}, {n1, n4}, {n3, n4}, {n2, n5}, {n4, n6}} n1 n2 e2 e4 e3 n3 n4 n5 e5 n6 n7 Degree of a node: the number of edges that have the node as an endpoint. Example: deg(n1) = 2, deg(n7) = 0, deg(n4) = 3.

Incidence Matrices An incidence matrix of a graph G = (V, E) with m nodes and n edges is an m X n matrix where the elements in row i, and column j is 1 iff node i is an endpoint of edge j, otherwise is 0. e1 e2 e3 e4 e5 n1 1 n2 n3 n4 n5 n6 n7

Adjacency matrix The adjacency matrix of a graph G = (V, E) with m nodes, and n edges, is an m X m matrix, where the elements in row i and column j is 1 iff there is an edge between node i and node j, otherwise is 0. n1 n2 n3 n4 n5 n6 n7 1

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 as an endpoint. Paths can be described either as a sequence of edges, or as a sequence of nodes. Paths are defined between a source node and a target node.

Example Paths Path (from-to) Node sequence Edge sequence n1 – n5 n1, n2, n5 e1, e4 n6 – n5 n6, n4, n1, n2, n5 e5, e2, e1, e4 n3 – n2 n3, n4, n1, n2 e3, e2, e1

Connectedness Nodes ni, nj are connected iff there is a path from node ni to node nj “Connectedness” is an equivalence relation on the node set of a graph “Connectedness” defines a partition on the node set of a graph. A component of a graph is a maximal set of connected nodes Example: Two components in the sample graph C1 = {n1, n2, n3, n4, n5, n6}, and C2 = :n7}

Condensation Graphs Given a graph G = (V, E), its condensation graph is formed by replacing each component by a condensing node. C1 n7

Complexity of a Graph A measure of the complexity of a graph is its cyclomatic complexity measure. The cyclomatic complexity of a graph G, is a number V(G) = e – n + 2, where e is the number of edges in the graph, and n is the number of vertices (nodes) in the graph.

Directed Graphs A directed graph (or digraph) D = (V, E), consists of a finite set of vertices V = {n1, n2, … nm}, and a set of edges E = {e1, e2, ep}, where each edge ek = <ni, nj> is an ordered pair of nodes in V.

Example Directed Graph V = {n1, n2, n3, n4, n5, n6, n7} E = {e1, 2, e3, e4, e5} = {<n1, n2>, <n1, n4>, <n3, n4>, <n2, n5>, <n4, n6>} n1 n2 e2 e4 e3 n3 n4 n5 e5 n6 n7

Properties of Directed Graphs The indegree (or fan-in) of a node in a directed graph is the number of distinct edges that have the node as a terminal node (target node). Example: indeg(n1) = 0, indeg(n4) = 2 The outdegree (or fan-out) of a node in a directed graph is the number of distinct edges that have the node as a start node (source node). Example: outdeg(n1) = 2, outdeg(n6) = 0 A node with in indegree = 0 is called a source node (n1, n3, n7) A node with outdegree = 0 is called a sink node (n5, n6, n7) A node with indegree ≠ 0 and outdeg ≠ 0 is called a transfer node (n2, n4) A node that is both a source and a sink is an isolated node The source and sink nodes in a graph constitute the external boundary of the graph

Adjacency Matrix of a Directed Graph The adjacency matrix of a directed graph D = (V, E) with m nodes is an m X m matrix which in row i and column j there is an entry equal to 1 iff there is an edge from node i to node j, otherwise the entry is equal to 0 The sum of a row is the outdegree of a node The sum of a column is the indegree of a node

Paths and Semi-Paths A directed path is a sequence of edges such that, for any adjacent set of edges ei, ej in the sequence, the terminal node of ei is the initial node of ej A cycle is a directed path that begins and ends in the same node A directed semi-path is a sequence of edges such that, for at least one adjacent pair of edges ei, ej in the sequence, the initial node of the first edge is the initial node of the second edge or the terminal node of the first edge is the terminal node of the second edge Directed paths are also called chains Example: There is a path from n1 to n6, There is a semi-path between n1 and n3 There is a semi-path between n2 and n4 There is a semi-path between n5 and n6

Reachability Matrix The reachability matrix of a directed graph D = (V, E) with m nodes is an m X m matrix R = (r(i, j)), where the entry r(i, j) = 1 iff there is a path from node i to node j, otherwise the entry is equal to 0 The reachability matrix R can be computed as R= I + A + A2 + … + Ak where k is the length of the longest path in D n1 n2 n3 n4 n5 n6 n7 1

N-Connectedness Two nodes ni and nj in a directed graph are: 0-connected: iff there is no path from ni to nj 1-connected: iff there is a semi-path but no path between ni, nj 2-connected: iff there is a path between ni, nj 3-connected: iff there is a path from ni to nj and a path from nj to ni A strong component of a directed graph is the maximal set of 3-connected nodes

Example n1 and n7 are 0-connected n2 and n6 are 1-connected

Condensation Graph of a DiGraph A condensation graph is a a graph D'=(V',E') based on the directed graph D=(V,E) where each vertex in V' corresponds to a strongly connected component in D and edge (u,v) is in E' if and only if there exists an edge in E connecting any of the vertices in the component of u to any of the vertices in the component of v.

Example Condensation DiGraph

Example Condensation Graph

Program Graphs Given a program written in an imperative programming language, its program graph is a directed graph in which: Nodes are program statements (or statement fragments), and edges represent flow of control Control flow of imperative programs is defined by sequencing, iteration, and choice constructs

Digraphs of the Structured Programming Constructs Sequence if-then-else case if-then loop-pre-test loop-post-test

Finite State Machines A Finite State Machine (FSM) is a directed graph (S, T, Ev, Act, Guard), in which S is a set of nodes, T is a set of edges, and Ev, Act, Guard are sets of events, actions, and guards associated with the transitions in T.

Example FSM (with events, actions and guards) Selling Unhappy Happy bid [(value >= 100) & (value < 200)] /sell bid [value >= 200] /sell bid [value < 100] /reject

Petri-Nets A Petri-Net is a bipartite graph (P, T, In, Out), in which P, T are disjoint sets of nodes and In and Out are sets of edges, where In is a subset of P X T, and out is a subset of T X P A marked Petri-Net is a 5-tuple (P, T, In, Out, M) in which (P, T, In, Out) is a Petri-Net and M is a set of mappings of places to positive integers (number of tokens in a Place) A transition in a Petri-Net is enabled when there is at least one token in each input place When an enabled transition fires one token is removed from each of its input places and is added in each of the output places

Example p1 p5 p2 P = {p1, p2, p3, p4, p5} T = {t1, t2, t3} In = { <p1, t1>, <p5, t1>, <p5, p3>, <p2, p3>, <p3, t2>} Out = {<t1, p3>, <t2, p4>, <t3, p4>} M = <1, 1, 1, 2, 0> t1 t3 p4 p3 t2

Example Petri Net