Slide 36
Slide 36 text
logic Z Count{L}(int *a, Z m, Z n, int v);
axiom CountSectionEmpty:
∀ int *a, v, Z m, n;
n ≤ m ⇒ Count(a, m, n, v) == 0;
axiom CountSectionHit:
∀ int *a, v, Z n, m;
a[n] == v ⇒
Count(a, m, n + 1, v) == Count(a, m, n, v) + 1;
int a = 5;
assert Count(&a+1, 0, -1, 5) == 0
&& Count(&a+1, 0, 0, 5) == 0;
assert Count(&a+1, 0, 0, 5) == Count(&a+1, 0, -1, 5) + 1;
Logic errors. Can you see the
contradiction?
The real example