07.01.2013 Views

Lecture Notes in Computer Science 3472

Lecture Notes in Computer Science 3472

Lecture Notes in Computer Science 3472

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

332 Levi Lúcio and Marko Samer<br />

<strong>in</strong> the follow<strong>in</strong>g, partition<strong>in</strong>g and fault-based heuristics can be seen as a uniform<br />

theoretical framework.<br />

Partition<strong>in</strong>g heuristics can <strong>in</strong> Z be formulated as theorems which describe<br />

the equivalence between the orig<strong>in</strong>al predicate and the partitions. In particular,<br />

there are two components of this equivalence: completeness, whichensures<br />

that the union resp. disjunction of the partitions covers the orig<strong>in</strong>al predicate,<br />

and disjo<strong>in</strong>tness, which ensures that the partitions are pairwise disjo<strong>in</strong>t. The<br />

correspond<strong>in</strong>g generic partition<strong>in</strong>g heuristics are<br />

∀ Vars(P) • P ⇔ P1 ∨ P2 ∨ ...∨ Pn<br />

∀ Vars(P) • ∀i, j :1..n • i �= j ⇒ ¬(Pi∧ Pj )<br />

where P denotes the orig<strong>in</strong>al predicate, Pi with 1 ≤ i ≤ n denotes a partition,<br />

and Vars denotes a function that returns the declarations of all variables occurr<strong>in</strong>g<br />

<strong>in</strong> its argument. To obta<strong>in</strong> partition<strong>in</strong>g heuristics, the above templates<br />

have to be <strong>in</strong>stantiated. Examples of such <strong>in</strong>stantiations concern<strong>in</strong>g disjunctive<br />

normal form have already been shown above (see transformation rules (12.1),<br />

(12.2), and (12.3)). An <strong>in</strong>stantiation of a boundary value analysis heuristic is<br />

given by:<br />

∀ A, B : Z • A ≥ B ⇔ (A = B) ∨ (A = B +1)∨ (A > B +1)<br />

To obta<strong>in</strong> concrete test cases, such a heuristic has to be applied to a selected<br />

predicate <strong>in</strong> a specification, i.e., it has to be <strong>in</strong>stantiated with the parameters<br />

of the predicate. For <strong>in</strong>stance, let us apply the above boundary value heuristic<br />

to the first predicate of the schema Modulo <strong>in</strong> Sec. 12.2.1. To this aim, we<br />

first have to prove with<strong>in</strong> CADiZ that the heuristic is a tautology. If this is<br />

the case, the heuristic’s <strong>in</strong>stantiation with respect to the predicate (A and B<br />

are <strong>in</strong>stantiated by b? andm? respectively) is computed by CADiZ’s pattern<br />

match<strong>in</strong>g mechanisms with<strong>in</strong> a tactic. The result<strong>in</strong>g equivalence is:<br />

b? ≥ m? ⇔ (b? =m?) ∨ (b? =m?+1)∨ (b? > m?+1)<br />

Now, the predicate b? ≥ m? <strong>in</strong> the schema can be replaced by the right hand<br />

side of this equivalence, which yields:<br />

Modulo<br />

b?, m?, r! :N<br />

(b? =m?) ∨ (b? =m?+1)∨ (b? > m?+1)<br />

(r! < m?) ∨ (m? =0)<br />

∃ k : N • b? =m? ∗ k + r!<br />

F<strong>in</strong>ally, the predicate part of this schema can be transformed <strong>in</strong>to disjunctive<br />

normal form. Each of the result<strong>in</strong>g six disjuncts represents one test case. Thus,<br />

the disjuncts can be separated <strong>in</strong>to schemas for each test case.<br />

Fault-based heuristics can be divided <strong>in</strong>to necessary conditions and sufficient<br />

conditions. Necessary conditions are able to dist<strong>in</strong>guish between different<br />

(mutated) subexpressions. This, however, is not always sufficient to detect

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!