















































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!
















































©^ 2007 by Spencer Rugaber
©^ 2007 by Spencer Rugaber
©^ 2007 by Spencer Rugaber
are called
operational
definitions
two mathematical approaches^ •
Axiomatic
: use of predicate calculus (with equality) to
express properties of system state
-^
Denotational
: adds the use of well-defined constructs such as
sets, lists, and maps to model state directly
©^ 2007 by Spencer Rugaber
©^ 2007 by Spencer Rugaber
©^ 2007 by Spencer Rugaber
©^ 2007 by Spencer Rugaber
B and
A then
" is the turnstile symbol and should be read as “provable”
©^ 2007 by Spencer Rugaber
{P} S {Q} and
{R} then
{P} S {Q} and
{P} then
That is, you can
weaken
post-conditions and
strengthen
preconditions
Notice that there are three separate notations usedhere −^
S^
is a statement in a programming language
−^
P, Q
and
R
are predicates in predicate logic
−^
|−
, and,
,^ and
and
then
are symbols in this specific
axiomatic semantics
©^ 2007 by Spencer Rugaber
©^ 2007 by Spencer Rugaber
If an assignment statement looks like
where
might be a complex expression, possibly involvingvariable
, then we must consider two cases: predicates
that refer to
and predicates that do not
For predicates that do not refer to
, we would expect
that they would be unchanged by the assignmentstatement. That is, {P} V := E; {P}
-^
But how about predicates that refer to
To understand these, we must introduce the concept of substitution
©^ 2007 by Spencer Rugaber
is given by
VE
VE
is the logical expression obtained from
by
substituting the expression
for all occurrences of
VE is sometimes expressed as
©^ 2007 by Spencer Rugaber
Consider the assignment statement
c := 5;
. If we
know before executing it that
{a > b}
is true, we
would like to be able to conclude after execution that {a > b
c = 5}
is true
Formally, the reasoning for this uses the rule ofconsequence as follows– The assignment statement is
c := 5;
is
c E
is
is
{a > b
c = 5}
VE is
{a > b
{a > b
true}
{a > b}
©^ 2007 by Spencer Rugaber
A minor notational enhancement can be used to makepredicates describing this kind of situation more readable^ – In the predicate that comes
after
the assignment, an apostrophe
can adorn the variable being assigned to. The apostrophe isintended to denote the value of the variable after the assignmentis complete. An unadorned occurrence of the same variableindicates the value before the assignment. The apostrophe ismerely syntactic sugar; it has no semantic significance
For example, the assignment
b := b + 5
can be
denoted as
{a > b + 5} b := b + 5 {a > b’}
©^ 2007 by Spencer Rugaber
The semantic for assignment given above encouragesubstituting backwards. That is, the substitution takesplace in the predicate that comes before the assignmentstatement. This approach is called the
weakest
precondition semantics
-^
Notice what happens when we try to substitute in theforward direction^ {b > 7} b := b + 5; {(b+5) > 7}
⇒
{b > 2}
which is not at all what this statement means
-^
To get this one right, a little algebra must be applied