0% found this document useful (0 votes)
76 views4 pages

Axiomatic Semantics

This document provides an overview of axiomatic semantics, which defines the meaning of programs and statements based on logical relationships between preconditions and postconditions rather than models of program state. It focuses on using axiomatic semantics for program verification by proving programs perform their specified computations. Meaning is defined by an statement's effect on assertions about affected data, expressed as predicates before and after execution. The weakest precondition is the least restrictive condition ensuring a postcondition is satisfied.

Uploaded by

shankar singam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views4 pages

Axiomatic Semantics

This document provides an overview of axiomatic semantics, which defines the meaning of programs and statements based on logical relationships between preconditions and postconditions rather than models of program state. It focuses on using axiomatic semantics for program verification by proving programs perform their specified computations. Meaning is defined by an statement's effect on assertions about affected data, expressed as predicates before and after execution. The weakest precondition is the least restrictive condition ensuring a postcondition is satisfied.

Uploaded by

shankar singam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Axiomatic Semantics:

In axiomatic semantics, there is no model of the state of a machine or


program or model of state changes that take place when the program
is executed. The meaning of a program is based on relationships
among program variables and constants, which are the same for every
execution of the program.
Axiomatic semantics has two distinct applications: program
verification and program semantics specification. This section focuses
on program verification in its description of axiomatic semantics.
Axiomatic semantics was defined in conjunction with the
development of an approach to proving the correctness of programs.
Such correctness proofs, when they can be constructed, show that a
program performs the computation described by its specification.

When axiomatic semantics is used to specify formally the meaning of


a statement, the meaning is defined by the statement’s effect on
assertions about the data affected by the statement.

Assertions:
The logical expressions used in axiomatic semantics are called
predicates, or assertions. An assertion immediately preceding a
program statement describes the constraints on the program variables
at that point in the program.
An assertion immediately following a statement describes the new
constraints on those variables (and possibly others) after execution of
the statement. These assertions are called the precondition and
postcondition, respectively, of the statement. For two adjacent
statements, the postcondition of the first serves as the precondition of
the second. Developing an axiomatic description or proof of a given
program requires that every statement in the program has both a
precondition and a postcondition.
In the following sections, we examine assertions from the point of
view that preconditions for statements are computed from given
postconditions, although it is possible to consider these in the opposite
sense. We assume all variables are integer type. As a simple example,
consider the following assignment statement and postcondition:
sum = 2 * x + 1 {sum > 1}

Precondition and postcondition assertions are presented in braces to


distinguish them from parts of program statements. One possible
precondition for this statement is {x > 10}.
In axiomatic semantics, the meaning of a specific statement is defined
by its precondition and its postcondition. In effect, the two assertions
specify precisely the effect of executing the statement.

Weakest Preconditions
The weakest precondition is the least restrictive precondition that will
guarantee the validity of the associated postcondition. For example, in
the statement and postcondition given in Section 3.5.3.1, {x > 10}, {x
> 50}, and {x > 1000} are all valid preconditions. The weakest of all
preconditions in this case is {x > 0}.

An inference rule is a method of inferring the truth of one assertion on


the basis of the values of other assertions. The general form of an
inference rule is as follows:
S1, S2, .,…., Sn
_______________
S
This rule states that if S1, S2, . . . , and Sn are true, then the truth of S
can be inferred. The top part of an inference rule is called its
antecedent; the bottom part is called its consequent.
An axiom is a logical statement that is assumed to be true. Therefore,
an axiom is an inference rule without an antecedent.

Assignment Statements
The precondition and postcondition of an assignment statement
together define precisely its meaning. To define the meaning of an
assignment statement, given a postcondition, there must be a way to
compute its precondition from that postcondition.
Let x = E be a general assignment statement and Q be its
postcondition.
Then, its precondition, P, is defined by the axiom
P = QxSE
which means that P is computed as Q with all instances of x replaced
by E. For example, if we have the assignment statement and
postcondition
a = b / 2 - 1 {a < 10}
the weakest precondition is computed by substituting b / 2 - 1 for a in
the postcondition {a < 10}, as follows:
b / 2 - 1 < 10
b < 22
Thus, the weakest precondition for the given assignment statement
and postcondition is {b < 22}

You might also like