272: Software Engineering Fall 2012 Instructor: Tevfik Bultan Lecture 9: Test Generation from Models.

Slides:



Advertisements
Similar presentations
The simplex algorithm The simplex algorithm is the classical method for solving linear programs. Its running time is not polynomial in the worst case.
Advertisements

NP-Hard Nattee Niparnan.
1 Finite Constraint Domains. 2 u Constraint satisfaction problems (CSP) u A backtracking solver u Node and arc consistency u Bounds consistency u Generalized.
Theory of Computing Lecture 18 MAS 714 Hartmut Klauck.
Lecture 23. Subset Sum is NPC
The Theory of NP-Completeness
© The McGraw-Hill Companies, Inc., Chapter 8 The Theory of NP-Completeness.
Complexity 11-1 Complexity Andrei Bulatov NP-Completeness.
CS21 Decidability and Tractability
Computability and Complexity 15-1 Computability and Complexity Andrei Bulatov NP-Completeness.
1 Polynomial Church-Turing thesis A decision problem can be solved in polynomial time by using a reasonable sequential model of computation if and only.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 21 Instructor: Paul Beame.
NP-Complete Problems Reading Material: Chapter 10 Sections 1, 2, 3, and 4 only.
Computability and Complexity 16-1 Computability and Complexity Andrei Bulatov NP-Completeness.
1 Polynomial Time Reductions Polynomial Computable function : For any computes in polynomial time.
NP-Complete Problems Problems in Computer Science are classified into
NP-Completeness (2) NP-Completeness Graphs 4/17/2017 6:25 AM x x x x x
Integer Programming Difference from linear programming –Variables x i must take on integral values, not real values Lots of interesting problems can be.
Toward NP-Completeness: Introduction Almost all the algorithms we studies so far were bounded by some polynomial in the size of the input, so we call them.
Complexity ©D.Moshkovitz 1 Paths On the Reasonability of Finding Paths in Graphs.
CS 267: Automated Verification Lecture 13: Bounded Model Checking Instructor: Tevfik Bultan.
272: Software Engineering Fall 2012 Instructor: Tevfik Bultan Lecture 4: SMT-based Bounded Model Checking of Concurrent Software.
1 The Theory of NP-Completeness 2012/11/6 P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class of decision.
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
A Z Approach in Validating ORA-SS Data Models Scott Uk-Jin Lee Jing Sun Gillian Dobbie Yuan Fang Li.
Analyzing the Requirements with Formal Specifications Vienna Development Method Specification Language (VDM-SL) Book: Formal Software Development From.
April 10, 2002Applied Discrete Mathematics Week 10: Relations 1 Counting Relations Example: How many different reflexive relations can be defined on a.
DBSQL 3-1 Copyright © Genetic Computer School 2009 Chapter 3 Relational Database Model.
MCS 312: NP Completeness and Approximation algorithms Instructor Neelima Gupta
Lecture 22 More NPC problems
The Complexity of Optimization Problems. Summary -Complexity of algorithms and problems -Complexity classes: P and NP -Reducibility -Karp reducibility.
Author: Graham Hughes, Tevfik Bultan Computer Science Department, University of California, Santa Barbara, CA 93106, USA Source: International Journal.
Theory of Computing Lecture 17 MAS 714 Hartmut Klauck.
NP Complexity By Mussie Araya. What is NP Complexity? Formal Definition: NP is the set of decision problems solvable in polynomial time by a non- deterministic.
MCS 312: NP Completeness and Approximation algorthms Instructor Neelima Gupta
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
EMIS 8373: Integer Programming NP-Complete Problems updated 21 April 2009.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
1 Introduction to modeling Object-role modelling (ORM) Slides for this part are based on Chapters 3-7 from Halpin, T. & Morgan, T. 2008, Information Modeling.
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
NP-completeness Section 7.4 Giorgi Japaridze Theory of Computability.
Planning as Satisfiability (SAT-Plan). SAT-Plan Translate the planning problem into a satisfiability problem for length n of Plan garb 0 (proposition)present.
Satisfiability and SAT Solvers CS 270 Math Foundations of CS Jeremy Johnson.
Chapter 11 Introduction to Computational Complexity Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
NP Completeness Piyush Kumar. Today Reductions Proving Lower Bounds revisited Decision and Optimization Problems SAT and 3-SAT P Vs NP Dealing with NP-Complete.
Young CS 331 D&A of Algo. NP-Completeness1 NP-Completeness Reference: Computers and Intractability: A Guide to the Theory of NP-Completeness by Garey and.
COMPLEXITY. Satisfiability(SAT) problem Conjunctive normal form(CNF): Let S be a Boolean expression in CNF. That is, S is the product(and) of several.
Presented by Kyumars Sheykh Esmaili Description Logics for Data Bases (DLHB,Chapter 16) Semantic Web Seminar.
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
COMPLEXITY. Satisfiability(SAT) problem Conjunctive normal form(CNF): Let S be a Boolean expression in CNF. That is, S is the product(and) of several.
The NP class. NP-completeness Lecture2. The NP-class The NP class is a class that contains all the problems that can be decided by a Non-Deterministic.
1 SAT SAT: Given a Boolean function in CNF representation, is there a way to assign truth values to the variables so that the function evaluates to true?
IT 5433 LM3 Relational Data Model. Learning Objectives: List the 5 properties of relations List the properties of a candidate key, primary key and foreign.
TU/e Algorithms (2IL15) – Lecture 10 1 NP-Completeness, II.
Cook Theorem and NP-complete problems
NP-Completeness (2) NP-Completeness Graphs 4/13/2018 5:22 AM x x x x x
P & NP.
Logical Database Design and the Rational Model
NP-Completeness (2) NP-Completeness Graphs 7/23/ :02 PM x x x x
NP-Completeness (2) NP-Completeness Graphs 7/23/ :02 PM x x x x
NP-Completeness Proofs
Intro to Theory of Computation
Logics for Data and Knowledge Representation
NP-Completeness (2) NP-Completeness Graphs 11/23/2018 2:12 PM x x x x
Logics for Data and Knowledge Representation
Logics for Data and Knowledge Representation
CS21 Decidability and Tractability
Instructor: Aaron Roth
Instructor: Aaron Roth
NP-Completeness (2) NP-Completeness Graphs 7/9/2019 6:12 AM x x x x x
Presentation transcript:

272: Software Engineering Fall 2012 Instructor: Tevfik Bultan Lecture 9: Test Generation from Models

Test Data Generation from Models Object-Role Modeling (ORM): A modeling language for specifying relational data models –Kind of like UML class diagrams or entity-relationship diagrams –Has formal semantics It allows the developer specify a data model with various constraints Used in industry Problem: –Satisfiability: Given an ORM diagram, are there any instances that satisfy the constraints specified in the diagram Test generation: Given a satisfiable ORM diagram, generate instances that satisfy the constraints specified in the diagram

ORM diagrams Ovals show entities or values (basic types) –These are sets of objects or values Rectangles show predicates –These represent the relations among the objects –They correspond to the tables in a relational database

ORM constraints Uniqueness constraint: Occurrence of a value in any column of a predicate is unique Mandatory constraint: Every object of an entity is implicitly assumed to participate in some of the predicates in which the entity has a role Frequency constraint: Specifies how many times a tuple can occur in a predicate Subset, equality constraints: It specifies that the tuples in the roles of the first predicate have to be among the tuples in the roles of the second Subtype constraints: Used to model subtyping among entities Value and cardinality constraints: Specify a range of values for primitive type or a cardinality (which can be a number or a range) for an entity Exclusion constraints: specifies that a particulate value can occur online in one table Ring constraints: Constraints on predicates (symmetric, acyclic, transitive, intransitive, reflexive, irreflexive, asymmetric)

Results For the most general case where constraints on the diagrams are specified using arbitrary queries –Satisfiability is undecidable For a more restricted class of diagrams, satisfiability checking is NP- hard Brute-force checking of satisfiability (bounded-exhaustive testing) does not scale For a class of diagrams that the authors define called ORM-, the satisfiability can be checked in polynomial time

NP-Hardness of ORM satisfiability NP-hardness proof shows that well-known NP-complete boolean satisfiability problem, 3SAT, can be reduced to an instance of ORM model satisfiability A 3-CNF formula has the following form: (c 1,1  c 1,2  c 1,3 )  (c 2,1  c 2,2  c 2,3 )  … where each c i,j represents expressions of the form q i or  q i over a set of boolean variables q 1, q 2, …, q n. We call (c i,1  c i,2  c i,3 ) clause c i. Determining satisfiability of a 3-CNF formula is an NP-complete problem A 3-CNF formula can be translated to a ORM diagram, such that, the 3-CNF formula is satisfiable if and only if the generated ORM diagram is satisfiable

NP-Hardness of ORM satisfiability 3-CNF formula to ORM diagram translation Introduce an object type for each q i Introduce an object type for each clause c i Introduce a value constraint for each of the object types above where their value is restricted to a single value qi or ci For each variable q i let n be the number of times it occurs in the clauses. If n > 0, create a (n+1)-ary predicate q i -true For each expression  q i let m be the number of times it occurs in the clauses. If m > 0, create a (m+1)-ary predicate q i -false Connect type q i to predicates q i -true and q i -false Impose and exclusion constraint on the roles played by q i in q i -true and q i -false (meaning that q i is either true or false, but not both) Connect each clause c i to the predicate q i -true if it contains q i or q i - false if it contains  q i

Brute-force approach As it is possible to translate satisfiability of boolean formulas to satisfiability of ORM diagrams, it is also possible to translate satisfiaibility of ORM diagrams, satisfiability of boolean formulas The authors tried this approach They translated ORM diagrams to input languages of CoBaSa and Alloy Analyzer –These are tools that can check satisfiability queries about bounded models –They use SAT solvers as back-end solvers Experiments with this approach shows that ORM satisfiability checking using a SAT solver is not efficient and does not scale to large diagrams

ORM- Given the theoretical difficulty of the general ORM satisfiability problem and the practical inefficiency of the brute-force approach –the authors define a subset of the ORM language for which satisfiability can be determined efficiently. ORM- allows only a subset of ORM constraints Uniqueness constraints cannot overlap Mandatory constraints are allowed on a single role Frequency constraints cannot overlap Value and cardinality constraints are allowed Subtype constraints are allowed According the authors majority of constraints used in practice are covered by this subset. Note that, subset constraints, exclusion constraints and ring constraints are not allowed.

Testing Satisfiability of ORM- Using a transformation from the ORM- to integer constraints the authors show that the satisfiability of the ORM- can be checked by checking satisfiability of the resulting integer constraints They also show that the satisfiability of the resulting integer constraints can be checked in polynomial time

Converting to integer constraints For each type A introduce a variable a representing its cardinality. For each predicate R, introduce a variable r denoting its cardinality. For each role in R played by A introduce a variable r a representing the number of unique elements from A in this role Produce inequalities: r a ≤ a and r a ≤ r For each cardinality constraint for a type A such as min … max produce inequalities: min ≤ a and a ≤ max –Do the same for the predicates. The default min value is 1 and the default max value is M (which could be set to MaxInt) For each value constraint let ds denote the domain size for the value domain, generate the inequality: a ≤ ds For each mandatory constraint for a role played by type A in predicate R, generate the inequality: a ≤ r a

Converting to integer constraints For each frequency constraint with frequency with range f min, …, f max on the roles played in predicate R by types A, B, …, K, introduce the variable r ab…k representing the number of unique tuples in these roles and produce the following inequalities: r ≤ f max. r ab…k f min. r ab…k ≤ r r ab…k ≤ r a. r b. …. r k r a ≤ r ab…k, r b ≤ r ab…k, …, r k ≤ r ab…k For each subtype constraint between types A and S produce the inquality: a ≤ s

Converting to integer constraints For each predicate R with roles played by types A, B, …, N express the implicit uniqueness constraint over all roles by producing the inequality: r ≤ r ab…k. r lm…p. …. r n where right hand side are variables that correspond to ranges of roles that participate in some frequency constraints, followed by the variables corresponding to roles that are under no frequency constraint For each non-independent type A that plays roles in predicates R, S, …., V introduce the constraint: a ≤ r a + s a + … + v a which captures the implicit disjunctive mandatory constraint that each object of a non-independent type needs to appear in some predicate

Properties of this conversion The set of constraints generation by this conversion are satisfiable if and only if the ORM- diagram itself is satisfiable –Hence this approach is both sound and complete This means that we reduced the satisfiability of the ORM- diagrams to satisfiability of a set of integer constraints Satisfiability of integer constraints is a difficult problem itself. However, the integer constraints generated with this conversion are of a specific type for which the satisfiability can be checked efficiently as the authors show

Checking satisfiability of constraints Rewrite all inequalities of the form c. x ≤ y 1. y 2. …. y n as form x ≤ (y 1. y 2. …. y n ) / c For each variable maintain its current upper bound. In every step substitute the current upper bounds for all variables on the rhs and after arithmetic manipulation obtain upper bound candidates for each variable and choose the smallest one Repeat until either an upper bound crosses a lower bound or all upper bounds remain unchanged The algorithm runs in polynomial time because if there are n variables in the system, each inequality can yield a different upper bound at most n times.

Test Generation Any set of integer values satisfying the generated integer constraints can be used to construct an instance of the ORM- data model These instances can then be used as test cases for testing a database So the overall approach would be: –Given a database, specify an ORM- diagram that characterizes a set of test cases for testing the database –First check the satisfiability of the ORM- diagram by generating integer constraints as described above and then check the satisfiability of the generated integer constraints –If the integer constraints are satisfiable, find integer values that satisfy the constraints and convert those integer values the instances of the ORM- model