A dynamic semantics of C.
We distinguish between pure (i.e. side-effect-free) expressions
and expressions that may have side effects.
We allow the latter to appear only in certain parts of statements,
and we put restrictions to ensure a predictable order of evaluation.
Pure expressions may be evaluated in any order;
we evaluate them left to right.
We formalize a big-step operational interpretive semantics.
To ensure the termination of the ACL2 mutually recursive functions
that formalize the execution of statements, function calls, etc.,
these ACL2 functions take a limit on the depth of the recursive calls,
which ends the recursion with an error when it reaches 0,
which is decremented at each recursive call,
and which is used as termination measure.
Thus, a proof of total correctness
(i.e. the code terminates and produces correct results)
involves showing the existence of sufficiently large limit values,
while a proof of partial correctness
(i.e. the code produces correct results if it terminates)
is relativized to the limit value not running out.
The limit is an artifact of the formalization;
it has no explicit counterpart in the execution state of the C code.
The current definition of this dynamic semantics
may not be completely accurate in terms of
execution of arbitrary C in the covered subset of C,
in particular in the treatment of arrays.
However, it is accurate for our current uses
(namely, supporting proof generation in ATC. This dynamic semantics is work in progress;
we plan to make it completely accurate
for all the covered subset of C.
- Mutually recursive functions for execution.
- Execute the array subscripting operation on expression values.
- Execute a pure expression.
- Execute an assignment expression.
- Turn an initialization value into a value of a given type.
- Execute a structure pointer member operation
on an expression value.
- Execute & on an expression value [C:126.96.36.199/1] [C:188.8.131.52/3].
- Array-to-pointer conversion [C:184.108.40.206/3] on expression values.
- Execute a structure member operation on an expression value.
- Execute a unary operation on an expression value.
- Initialize the variable scope for a function call.
- Execute a function on argument values.
- Evaluate an integer constant.
- Execute a block item.
- Execute a strict pure binary operation on expression values.
- Execute a list of pure expression.
- Evaluate a binary expression with a strict pure operator,
on two values, returning a value.
- Execute a function call or a pure expression.
- Execute a list of block items.
- Execute a while statement.
- Execute * on an expression value [C:220.127.116.11/2] [C:18.104.22.168/4].
- Execute a statement.
- Execute a variable.
- Evaluate a type cast on a value.
- Execute a type cast on an expression value.
- Evaluate a unary operation that does not involve pointers,
on a value, returning a value.
- Execute a constant.
- Execute an initializer.
- Execute a function call or assignment expression.
- Evaluate a constant.
- Execution a function call.