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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

(12.4)<br />

✟<br />

nat(X ′ )<br />

{A/0, B/X ′ , X /X ′ }<br />

12 Technology of Test-Case Generation 335<br />

max(A, B, X )<br />

✟ ❍<br />

✟<br />

✟ ❍❍❍❍<br />

✟<br />

✟<br />

(12.6)<br />

(12.5)<br />

❍<br />

nat(X ′ )<br />

{A/s(X ′ ), B/0, X /s(X ′ )}<br />

max(A ′ , B ′ , X ′ )<br />

{A/s(A ′ ), B/s(B ′ ), X /s(X ′ )}<br />

Fig. 12.2. Resolution tree of max(A, B, X )<br />

It is easy to see that every equation of the form f (t1,...,tn) =t can be<br />

replaced by a literal ˜ f (t1,...,tn, t) witharityn + 1. Hence, we obta<strong>in</strong> a Horn<br />

clause resp. Prolog rule of the form<br />

˜f (t1,...,tn, r) ← ˜ f1(t1,1,...,t1,n1, r1),..., ˜ fm(tm,1,...,tm,nm, rm).<br />

Therefore, we have transformed the <strong>in</strong>itial specification <strong>in</strong>to a Prolog program.<br />

It rema<strong>in</strong>s to show how test cases can be generated with this program.<br />

Two important properties <strong>in</strong> this context are completeness and term<strong>in</strong>ation. To<br />

ensure a complete proof search strategy, iterative deepen<strong>in</strong>g can be used <strong>in</strong>stead<br />

of Prolog’s standard depth-first search. This, however, does not guarantee<br />

term<strong>in</strong>ation because some unsatisfiable goals cannot be detected. To solve this<br />

problem, rewrit<strong>in</strong>g is used by Bernot et al. [BGM91] to simplify goals before<br />

each resolution step <strong>in</strong> order to alleviate the detection of unsatisfiable goals.<br />

The ref<strong>in</strong>ement resp. unfold<strong>in</strong>g process to obta<strong>in</strong> a suitable decomposition of<br />

the specification <strong>in</strong>to sub-doma<strong>in</strong>s is implemented by recursively replac<strong>in</strong>g each<br />

def<strong>in</strong>ed operator by the cases correspond<strong>in</strong>g to its def<strong>in</strong>ition. This is already<br />

provided by Prolog’s resolution pr<strong>in</strong>ciple. For <strong>in</strong>stance, consider the predicate<br />

max/3 def<strong>in</strong>ed by the follow<strong>in</strong>g three clauses, where s denotes the successor<br />

function:<br />

max(0, X , X ) ← nat(X ). (12.4)<br />

max(s(X ), 0, s(X )) ← nat(X ). (12.5)<br />

max(s(A), s(B), s(X )) ← max(A, B, X ). (12.6)<br />

For example, max(s(0), s(s(s(0))), s(s(s(0)))) is true s<strong>in</strong>ce the maximum of<br />

s(0) . =1ands(s(s(0))) . =3iss(s(s(0))) . = 3. The resolution tree shown <strong>in</strong><br />

Fig. 12.2 is obta<strong>in</strong>ed when apply<strong>in</strong>g one resolution step to the goal max(A, B, X ).<br />

Theleavesofthistreeobviouslyrepresent a decomposition of max/3 accord<strong>in</strong>g<br />

to its def<strong>in</strong>ition. For the first two clauses we obta<strong>in</strong> the resolvent nat(X ′ ), and<br />

for the third clause we obta<strong>in</strong> the resolvent max(A ′ , B ′ , X ′ ) together with the<br />

correspond<strong>in</strong>g unifiers. These resolvents can now be further decomposed. The<br />

crucial po<strong>in</strong>t is to decide when the ref<strong>in</strong>ement process has to be stopped, i.e., to<br />

control the degree of decomposition. To this aim, meta-clauses are used by Bernot<br />

et al. [BGM91]. The literals are chosen for resolution accord<strong>in</strong>g to a selection

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

Saved successfully!

Ooh no, something went wrong!