

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Due Tuesday, March 9, 2004
replace(nothing, something, [], List). replace(a, 1, [a, b, r, a, c, a, d, a, b, r, a], List). replace(b, 0, [no, bs, here], List). replace(nest, here, [nest, [second, nest, level], [third, [nest], level], [[[big, nest]]]], List).
Test this predicate using the following calls:
structtypeeq(array(1, 10, int), array(0, 9, int)). structtypeeq(record([field(a, int)], field(b, float)]), record([field(x, int), field(y, float)])). structtypeeq(record([field(a, int), field(b, float)]), record([field(a, int), field(b, float), field(c, int)])). structtypeeq(record([field(n, int), field(trees, array(1, 100, pointer(tree)))]), record([field(n, int), field(trees, array(1, 100, pointer(tree)))])).
delete(nothing, [], List). delete(a, [a, b, r, a, c, a, d, a, b, r, a], List). delete(b, [no, bs, here], List). delete(nest, [nest, [second, nest, level], [third, [nest], level], [[[big, nest]]]], List).
i := n; while (i > 0) loop i := i - 1; end loop;
Using the axiomatic semantics of Core, show that the assertion {n ≥ 0 } S {i = 0} is correct. Hint: Use the loop invariant i ≤ n. The consequence rules may be used to force the other rules into a form consistent with this loop invariant. (You should analyze the program to understand why this loop invariant was chosen.)