Imperative programming

Sometimes it is natural to realize a specification with an imperative program in mind.

let B be a Set (the specification), A another Set (set of states), and Pre,Post:A->Prop
(the pre- and post- conditions);

If we build:

we can build a term of type B.

The usage of this construction is the following:

If the current goal is B, then the command

 Apply Imperative with A Pre Post;[
            Realizer <init:A> |
            Realizer <body:A->A> |
            Realizer <return:A->B> ].
followed by Program_all, will leave you some logical goals to solve.

An example can be found in the implementation of the logarithm of base 2

See also the while loop.

Apologies

We had no time to build a user-friendly "imperative" package, dealing with all sorts of loops, and constrol structures, breaks, and so on, with macros allowing to write directly commands of the form
Realizer {nat x y; while (zerop x) { ... }; return y;} 
We hope this will be done in few weeks.

Click here to look at the source .