Model-based vs. Functional Program Specification and Correctness Software Testing and Verification Bonus Review Material Prepared by Stephen M. Thebaut, Ph.D. University of Florida
Model-based vs. Functional Specification {true} temp := x x := y y := temp {x=y’ Л y=x’ Л temp=x’} Comparable specified function (f): f = (x,y,temp := y,x,x) Function computed by the program ([S]): [S] = (x,y,temp := y,x,x) Is the program “correct”? {P} S {Q} ? {P} S {Q} strongly ? f = [S] ? f [S] ?
Weakened Post-Condition {true} temp := x x := y y := temp {x=y’ Л y=x’} Comparable specified function (f): f = (x,y := y,x) Function computed by the program ([S]): [S] = (x,y,temp := y,x,x) Is the program “correct”? {P} S {Q} ? {P} S {Q} strongly ? f = [S] ? f [S] ?
Strengthened Pre-Condition {x>0 Л y>0} temp := x x := y y := temp {x=y’ Л y=x’} Comparable specified function (f): (x>0 Л y>0 x,y := y,x) Function computed by the program ([S]): [S] = (x,y,temp := y,x,x) Is the program “correct”? {P} S {Q} ? {P} S {Q} strongly ? f = [S] ? f [S] ?
A different program… {x>0 Л y>0} if (x>0 & y>0) then temp := x x := y y := temp end_if {x=y’ Л y=x’} Comparable specified function (f): (x>0 Л y>0 x,y := y,x) Function computed by the program ([S]): (x>0 Л y>0 x,y,temp := y,x,x | true I) Is the program “correct”? {P} S {Q} ? {P} S {Q} strongly ? f = [S] ? f [S] ?
A really different program… {x>0 Л y>0} if (x>0 & y>0) then temp := x x := y y := temp else while (1=1) do no-op end_while end_if_else {x=y’ Л y=x’} Comparable specified function (f): (x>0 Л y>0 x,y := y,x) Function computed by the program ([S]): (x>0 Л y>0 x,y,temp := y,x,x) Is the program “correct”? {P} S {Q} ? {P} S {Q} strongly ? f = [S] ? f [S] ?
Pre-condition weakened again {true} if (x>0 & y>0) then temp := x x := y y := temp else while (1=1) do no-op end_while end_if_else {x=y’ Л y=x’} Comparable specified function (f): f = (x,y := y,x) Function computed by the program ([S]): (x>0 Л y>0 x,y,temp := y,x,x) Is the program “correct”? {P} S {Q} ? {P} S {Q} strongly ? f = [S] ? f [S] ?
Model-based vs. Functional Program Specification and Correctness Software Testing and Verification Bonus Review Material Prepared by Stephen M. Thebaut, Ph.D. University of Florida