Title: Logic Coverage Exercise
1Logic Coverage Exercise
- 1. input(A,B)
- if (Agt0) OR (Blt0) then
- A A5
- end_if
- 3. if (ABgt0) AND (ABlt0) then
- 4. B AB
- end_if
- 5. output(A,B)
1
2
3
4
5
2Logic Coverage Exercise (a)
- 1. input(A,B)
- if (Agt0) OR (Blt0) then
- A A5
- end_if
- 3. if (ABgt0) AND (ABlt0) then
- 4. B AB
- end_if
- 5. output(A,B)
1
2
3
4
5
Path condition for lt1,2,3,5gt
3Logic Coverage Exercise (a)
- 1. input(A,B)
- if (Agt0) OR (Blt0) then
- A A5
- end_if
- 3. if (ABgt0) AND (ABlt0) then
- 4. B AB
- end_if
- 5. output(A,B)
1
2
3
4
5
Path condition for lt1,2,3,5gt
4Logic Coverage Exercise (a)
- 1. input(A,B)
- if (Agt0) OR (Blt0) then
- A A5
- end_if
- 3. if (ABgt0) AND (ABlt0) then
- 4. B AB
- end_if
- 5. output(A,B)
1
2
3
4
5
Path condition for lt1,2,3,5gt (Agt0) V (Blt0) ?
5Logic Coverage Exercise (a)
- 1. input(A,B)
- if (Agt0) OR (Blt0) then
- A A5
- end_if
- 3. if (ABgt0) AND (ABlt0) then
- 4. B AB
- end_if
- 5. output(A,B)
1
2
3
4
5
Path condition for lt1,2,3,5gt (Agt0) V (Blt0) ?
6Logic Coverage Exercise (a)
- 1. input(A,B)
- if (Agt0) OR (Blt0) then
- A A5
- end_if
- 3. if (ABgt0) AND (ABlt0) then
- 4. B AB
- end_if
- 5. output(A,B)
1
2
3
4
5
Path condition for lt1,2,3,5gt (Agt0) V (Blt0) ?
(A5B0) V ((A5)B0)
7Logic Coverage Exercise (a)
- 1. input(A,B)
- if (Agt0) OR (Blt0) then
- A A5
- end_if
- 3. if (ABgt0) AND (ABlt0) then
- 4. B AB
- end_if
- 5. output(A,B)
1
2
3
4
5
Path condition for lt1,3,4,5gt
8Logic Coverage Exercise (a)
- 1. input(A,B)
- if (Agt0) OR (Blt0) then
- A A5
- end_if
- 3. if (ABgt0) AND (ABlt0) then
- 4. B AB
- end_if
- 5. output(A,B)
1
2
3
4
5
Path condition for lt1,3,4,5gt
9Logic Coverage Exercise (a)
- 1. input(A,B)
- if (Agt0) OR (Blt0) then
- A A5
- end_if
- 3. if (ABgt0) AND (ABlt0) then
- 4. B AB
- end_if
- 5. output(A,B)
1
2
3
4
5
Path condition for lt1,3,4,5gt (A0) ? (B0) ?
10Logic Coverage Exercise (a)
- 1. input(A,B)
- if (Agt0) OR (Blt0) then
- A A5
- end_if
- 3. if (ABgt0) AND (ABlt0) then
- 4. B AB
- end_if
- 5. output(A,B)
1
2
3
4
5
Path condition for lt1,3,4,5gt (A0) ? (B0) ?
11Logic Coverage Exercise (a)
- 1. input(A,B)
- if (Agt0) OR (Blt0) then
- A A5
- end_if
- 3. if (ABgt0) AND (ABlt0) then
- 4. B AB
- end_if
- 5. output(A,B)
1
2
3
4
5
Path condition for lt1,3,4,5gt (A0) ? (B0) ?
(ABgt0)
? (ABlt0)
12Logic Coverage Exercise (b)
- 1. input(A,B)
- if (Agt0) OR (Blt0) then
- A A5
- end_if
- 3. if (ABgt0) AND (ABlt0) then
- 4. B AB
- end_if
- 5. output(A,B)
statement branch condition
comp. cond. path
1
2
3
4
5
test case 1 A1, B3
13Logic Coverage Exercise (b)
- 1. input(A,B)
- if (Agt0) OR (Blt0) then
- A A5
- end_if
- 3. if (ABgt0) AND (ABlt0) then
- 4. B AB
- end_if
- 5. output(A,B)
statement branch condition
comp. cond. path
1
2
3
4
5
test case 1 A1, B3
14Logic Coverage Exercise (b)
- 1. input(A,B)
- if (Agt0) OR (Blt0) then
- A A5
- end_if
- 3. if (ABgt0) AND (ABlt0) then
- 4. B AB
- end_if
- 5. output(A,B)
T
F
statement branch condition
comp. cond. path
1
2
3
4
5
test case 1 A1, B3
15Logic Coverage Exercise (b)
- 1. input(A,B)
- if (Agt0) OR (Blt0) then
- A A5
- end_if
- 3. if (ABgt0) AND (ABlt0) then
- 4. B AB
- end_if
- 5. output(A,B)
T
F
statement branch condition
comp. cond. path
1
2
3
4
5
test case 1 A1, B3
16Logic Coverage Exercise (b)
- 1. input(A,B)
- if (Agt0) OR (Blt0) then
- A A5
- end_if
- 3. if (ABgt0) AND (ABlt0) then
- 4. B AB
- end_if
- 5. output(A,B)
T
F
statement branch condition
comp. cond. path
1
2
3
T
F
4
5
test case 1 A1, B3
17Logic Coverage Exercise (b)
- 1. input(A,B)
- if (Agt0) OR (Blt0) then
- A A5
- end_if
- 3. if (ABgt0) AND (ABlt0) then
- 4. B AB
- end_if
- 5. output(A,B)
T
F
statement branch condition
comp. cond. path
1
2
3
T
F
4
5
test case 1 A1, B3
18Logic Coverage Exercise (b)
- 1. input(A,B)
- if (Agt0) OR (Blt0) then
- A A5
- end_if
- 3. if (ABgt0) AND (ABlt0) then
- 4. B AB
- end_if
- 5. output(A,B)
statement branch condition
comp. cond. path
T
F
1
2
3
T
F
4
5
test case 1 A1, B3 test case 2 A-1, B-5
19Logic Coverage Exercise (b)
- 1. input(A,B)
- if (Agt0) OR (Blt0) then
- A A5
- end_if
- 3. if (ABgt0) AND (ABlt0) then
- 4. B AB
- end_if
- 5. output(A,B)
statement branch condition
comp. cond. path
T, F
F, T
1
2
3
T
F
4
5
test case 1 A1, B3 test case 2 A-1, B-5
20Logic Coverage Exercise (b)
- 1. input(A,B)
- if (Agt0) OR (Blt0) then
- A A5
- end_if
- 3. if (ABgt0) AND (ABlt0) then
- 4. B AB
- end_if
- 5. output(A,B)
statement branch condition
comp. cond. path
T, F
F, T
1
2
3
T, F
F, T
4
5
test case 1 A1, B3 test case 2 A-1, B-5
21Logic Coverage Exercise (b)
- 1. input(A,B)
- if (Agt0) OR (Blt0) then
- A A5
- end_if
- 3. if (ABgt0) AND (ABlt0) then
- 4. B AB
- end_if
- 5. output(A,B)
statement branch condition ? comp.
cond. path
T, F
F, T
1
2
3
T, F
F, T
4
5
test case 1 A1, B3 test case 2 A-1, B-5
22Logic Coverage Exercise (c)
- 1. input(A,B)
- if (Agt0) OR (Blt0) then
- A A5
- end_if
- 3. if (ABgt0) AND (ABlt0) then
- 4. B AB
- end_if
- 5. output(A,B)
statement branch condition ? comp. cond.
path
T, F
F, T
1
2
3
T, F
F, T
4
5
test case 1 A1, B3 test case 2 A-1, B-5
test case 3 A3, B-1
23Logic Coverage Exercise (c)
- 1. input(A,B)
- if (Agt0) OR (Blt0) then
- A A5
- end_if
- 3. if (ABgt0) AND (ABlt0) then
- 4. B AB
- end_if
- 5. output(A,B)
statement branch condition ? comp. cond.
path
T, F, T
F, T, T
1
2
3
T, F
F, T
4
5
test case 1 A1, B3 test case 2 A-1, B-5
test case 3 A3, B-1
24Logic Coverage Exercise (c)
- 1. input(A,B)
- if (Agt0) OR (Blt0) then
- A A5
- end_if
- 3. if (ABgt0) AND (ABlt0) then
- 4. B AB
- end_if
- 5. output(A,B)
statement branch condition ? comp. cond.
path
T, F, T
F, T, T
1
2
3
T, F, T
F, T, T
4
5
test case 1 A1, B3 test case 2 A-1, B-5
test case 3 A3, B-1
25Logic Coverage Exercise (c)
- 1. input(A,B)
- if (Agt0) OR (Blt0) then
- A A5
- end_if
- 3. if (ABgt0) AND (ABlt0) then
- 4. B AB
- end_if
- 5. output(A,B)
statement branch condition ? comp. cond.
path
T, F, T
F, T, T
1
2
3
T, F, T
F, T, T
4
5
test case 1 A1, B3 test case 2 A-1, B-5
test case 3 A3, B-1
26Logic Coverage Exercise (c)
- 1. input(A,B)
- if (Agt0) OR (Blt0) then
- A A5
- end_if
- 3. if (ABgt0) AND (ABlt0) then
- 4. B AB
- end_if
- 5. output(A,B)
statement ? branch condition ? comp. cond.
path
T, F, T
F, T, T
1
2
3
T, F, T
F, T, T
4
5
test case 1 A1, B3 test case 2 A-1, B-5
test case 3 A3, B-1
27Logic Coverage Exercise (c)
- 1. input(A,B)
- if (Agt0) OR (Blt0) then
- A A5
- end_if
- 3. if (ABgt0) AND (ABlt0) then
- 4. B AB
- end_if
- 5. output(A,B)
statement ? branch condition ? comp. cond.
path
T, F, T
F, T, T
1
2
3
T, F, T
F, T, T
4
5
test case 1 A1, B3 test case 2 A-1, B-5
test case 3 A3, B-1 test case 4 A0,
B0
28Logic Coverage Exercise (c)
- 1. input(A,B)
- if (Agt0) OR (Blt0) then
- A A5
- end_if
- 3. if (ABgt0) AND (ABlt0) then
- 4. B AB
- end_if
- 5. output(A,B)
statement ? branch condition ? comp. cond.
path
T, F, T, F
F, T, T, F
1
2
3
T, F, T
F, T, T
4
5
test case 1 A1, B3 test case 2 A-1, B-5
test case 3 A3, B-1 test case 4 A0,
B0
29Logic Coverage Exercise (c)
- 1. input(A,B)
- if (Agt0) OR (Blt0) then
- A A5
- end_if
- 3. if (ABgt0) AND (ABlt0) then
- 4. B AB
- end_if
- 5. output(A,B)
statement ? branch condition ? comp. cond.
path
T, F, T, F
F, T, T, F
1
2
3
T, F, T
F, T, T
4
5
test case 1 A1, B3 test case 2 A-1, B-5
test case 3 A3, B-1 test case 4 A0,
B0
30Logic Coverage Exercise (c)
- 1. input(A,B)
- if (Agt0) OR (Blt0) then
- A A5
- end_if
- 3. if (ABgt0) AND (ABlt0) then
- 4. B AB
- end_if
- 5. output(A,B)
statement ? branch condition ? comp. cond.
path
T, F, T, F
F, T, T, F
1
2
3
T, F, T, F
F, T, T, F
4
5
test case 1 A1, B3 test case 2 A-1, B-5
test case 3 A3, B-1 test case 4 A0,
B0
31Logic Coverage Exercise (c)
- 1. input(A,B)
- if (Agt0) OR (Blt0) then
- A A5
- end_if
- 3. if (ABgt0) AND (ABlt0) then
- 4. B AB
- end_if
- 5. output(A,B)
T, F, T, F
F, T, T, F
statement ? branch ? condition ? comp.
cond. path
1
2
3
T, F, T, F
F, T, T, F
4
5
test case 1 A1, B3 test case 2 A-1, B-5
test case 3 A3, B-1 test case 4 A0,
B0
32Logic Coverage Exercise (c)
- 1. input(A,B)
- if (Agt0) OR (Blt0) then
- A A5
- end_if
- 3. if (ABgt0) AND (ABlt0) then
- 4. B AB
- end_if
- 5. output(A,B)
T, F, T, F
F, T, T, F
statement ? branch ? condition ? comp.
cond. ? path
1
2
3
T, F, T, F
F, T, T, F
4
5
test case 1 A1, B3 test case 2 A-1, B-5
test case 3 A3, B-1 test case 4 A0,
B0
33While Loop Verification Exercise
- y gt 0
- z x
- n y
- while ngt1 do
- z zx
- n n-1
- end_while
- z xy
34While Loop Verification Exercise
- y gt 0 I z x(y1-n)
- z x ? n 1
- n y
- while ngt1 do
- z zx
- n n-1
- end_while
- z xy
35While Loop Verification Exercise
- y gt 0 I z x(y1-n)
- z x ? n 1
- n y
- while ngt1 do
- z zx
- n n-1
- end_while
- z xy
36While Loop Verification Exercise
- y gt 0 I z x(y1-n)
- z x ? n 1
- n y
- while ngt1 do
- z zx
- n n-1
- end_while
- z xy
- initialization PgtI
- Does (ygt0 ? zx ? ny) ? (zx(y1-n) ? n1)?
37While Loop Verification Exercise
- y gt 0 I z x(y1-n)
- z x ? n 1
- n y
- while ngt1 do
- z zx
- n n-1
- end_while
- z xy
- initialization PgtI
- Does (ygt0 ? zx ? ny) ? (zx(y1-n) ? n1)?
- Yes. Clearly, if zx and ny, it follows that
- zx(y1-n)
- Similarly, if nygt0, it follows that n1.
38While Loop Verification Exercise
- y gt 0 I z x(y1-n)
- z x ? n 1
- n y
- while ngt1 do
- z zx
- n n-1
- end_while
- z xy
39While Loop Verification Exercise
- y gt 0 I z x(y1-n)
- z x ? n 1
- n y
- while ngt1 do
- z zx
- n n-1
- end_while
- z xy
- preservation I?b s I
- zx(y1-n) ? n1 ? ngt1
40While Loop Verification Exercise
- y gt 0 I z x(y1-n)
- z x ? n 1
- n y
- while ngt1 do
- z zx
- n n-1
- end_while
- z xy
- preservation I?b s I
- zx(y1-n) ? n1 ? ngt1 zx(y1-n) ? ngt1
41While Loop Verification Exercise
- y gt 0 I z x(y1-n)
- z x ? n 1
- n y
- while ngt1 do
- z zx
- n n-1
- end_while
- z xy
- preservation I?b s I
- zx(y1-n) ? n1 ? ngt1 zx(y1-n) ? ngt1
- z zx
42While Loop Verification Exercise
- y gt 0 I z x(y1-n)
- z x ? n 1
- n y
- while ngt1 do
- z zx
- n n-1
- end_while
- z xy
- preservation I?b s I
- zx(y1-n) ? n1 ? ngt1 zx(y1-n) ? ngt1
- z zx
- zx(y2-n) ? ngt1
43While Loop Verification Exercise
- y gt 0 I z x(y1-n)
- z x ? n 1
- n y
- while ngt1 do
- z zx
- n n-1
- end_while
- z xy
- preservation I?b s I
- zx(y1-n) ? n1 ? ngt1 zx(y1-n) ? ngt1
- z zx
- zx(y2-n) ? ngt1
- n n-1
44While Loop Verification Exercise
- y gt 0 I z x(y1-n)
- z x ? n 1
- n y
- while ngt1 do
- z zx
- n n-1
- end_while
- z xy
- preservation I?b s I
- zx(y1-n) ? n1 ? ngt1 zx(y1-n) ? ngt1
- z zx
- zx(y2-n) ? ngt1
- n n-1
- zx(y2-(n1)) ? (n1)gt1
45While Loop Verification Exercise
- y gt 0 I z x(y1-n)
- z x ? n 1
- n y
- while ngt1 do
- z zx
- n n-1
- end_while
- z xy
- preservation I?b s I
- zx(y1-n) ? n1 ? ngt1 zx(y1-n) ? ngt1
- z zx
- zx(y2-n) ? ngt1
- n n-1
- zx(y2-(n1)) ? (n1)gt1
- zx(y1-n) ? n1 I
46While Loop Verification Exercise
- y gt 0 I z x(y1-n)
- z x ? n 1
- n y
- while ngt1 do
- z zx
- n n-1
- end_while
- z xy
47While Loop Verification Exercise
- y gt 0 I z x(y1-n)
- z x ? n 1
- n y
- while ngt1 do
- z zx
- n n-1
- end_while
- z xy
- finalization (I?b) gt Q
- Does (zx(y1-n) ? n1 ? n1) ? zxy?
48While Loop Verification Exercise
- y gt 0 I z x(y1-n)
- z x ? n 1
- n y
- while ngt1 do
- z zx
- n n-1
- end_while
- z xy
- finalization (I?b) gt Q
- Does (zx(y1-n) ? n1 ? n1) ? zxy?
- Yes, since (zx(y1-n) ? n1 ? n1) ? (n1?
zx(y1-1)) ? zxy
49While Loop Verification Exercise
- n 0
- p 1
- k 0
- while kltn do
- p 2p
- k k1
- end_while
- p 2n
50While Loop Verification Exercise
- n 0 I p 2k? k n
- p 1
- k 0
- while kltn do
- p 2p
- k k1
- end_while
- p 2n
51While Loop Verification Exercise
- n 0 I p 2k? k n
- p 1
- k 0
- while kltn do
- p 2p
- k k1
- end_while
- p 2n
52While Loop Verification Exercise
- n 0 I p 2k? k n
- p 1
- k 0
- while kltn do
- p 2p
- k k1
- end_while
- p 2n
- initialization PgtI
- Does (n0 ? p1 ? k0) ? (p2k? kn)?
53While Loop Verification Exercise
- n 0 I p 2k? k n
- p 1
- k 0
- while kltn do
- p 2p
- k k1
- end_while
- p 2n
- initialization PgtI
- Does (n0 ? p1 ? k0) ? (p2k? kn)?
- Yes. Clearly, if p1 and k0, it follows that
- p2k
- Similarly, if n0 and k0 it follows that kn.
54While Loop Verification Exercise
- n 0 I p 2k? k n
- p 1
- k 0
- while kltn do
- p 2p
- k k1
- end_while
- p 2n
- preservation I?b s I
- p2k? kn ? kltn
-
55While Loop Verification Exercise
- n 0 I p 2k? k n
- p 1
- k 0
- while kltn do
- p 2p
- k k1
- end_while
- p 2n
- preservation I?b s I
- p2k? kn ? kltn p2k? kltn
-
56While Loop Verification Exercise
- n 0 I p 2k? k n
- p 1
- k 0
- while kltn do
- p 2p
- k k1
- end_while
- p 2n
- preservation I?b s I
- p2k? kn ? kltn p2k? kltn
- p 2p
-
57While Loop Verification Exercise
- n 0 I p 2k? k n
- p 1
- k 0
- while kltn do
- p 2p
- k k1
- end_while
- p 2n
- preservation I?b s I
- p2k? kn ? kltn p2k? kltn
- p 2p
- p2k1? kltn
58While Loop Verification Exercise
- n 0 I p 2k? k n
- p 1
- k 0
- while kltn do
- p 2p
- k k1
- end_while
- p 2n
- preservation I?b s I
- p2k? kn ? kltn p2k? kltn
- p 2p
- p2k1? kltn
- k k1
-
59While Loop Verification Exercise
- n 0 I p 2k? k n
- p 1
- k 0
- while kltn do
- p 2p
- k k1
- end_while
- p 2n
- preservation I?b s I
- p2k? kn ? kltn p2k? kltn
- p 2p
- p2k1? kltn
- k k1
- p2k? kn I
60While Loop Verification Exercise
- n 0 I p 2k? k n
- p 1
- k 0
- while kltn do
- p 2p
- k k1
- end_while
- p 2n
61While Loop Verification Exercise
- n 0 I p 2k? k n
- p 1
- k 0
- while kltn do
- p 2p
- k k1
- end_while
- p 2n
- finalization (I?b) gt Q
- Does (p2k? kn ? kn) ? p2n?
62While Loop Verification Exercise
- n 0 I p 2k? k n
- p 1
- k 0
- while kltn do
- p 2p
- k k1
- end_while
- p 2n
- finalization (I?b) gt Q
- Does (p2k? kn ? kn) ? p2n?
- Yes, since (p2k? kn ? kn) ? (kn ? p2k) ?
p 2n