Mirkowska, Salwicki - Algorithmic Logic (1e 1987)
Mirkowska, Salwicki - Algorithmic Logic (1e 1987)
LOGIC
Grazyna Mir Rows ka
Andrzej Salwicki
ALGORITHMIC
LOGIC
ARS POLONA
Krakowskie Przedmiescie 7, 00-068 Warszawa 1, Poland
PRINTED IN POLAND
CONTENTS
P R E F A C E ........................................................................................ IX
CHAPTER I. INTRODUCTION ............................................ 1
1. The m o tiv a tio n s ...................................................................... 1
2. An informal introduction to formalized la n g u a g e s ............... 5
3. Assigning meanings to p r o g r a m s ......................................... 11
4. Semantic properties of p r o g r a m s ......................................... 16
5. Expressivity. An introduction to the language of algorithmic
lo g ic ............................................................................................ 18
6. On applications ...................................................................... 20
INTRODUCTION
1. THE MOTIVATIONS
at, can be of only limited use, or, possibly, they might work in an inter
active manner indicating trouble spots to those who operate them.
Hence the first type of semantic questions met in algorithmics (the
name sometimes used for the field of design and analysis of algorithms)
can be called computability problems. These include, for example,
questions like: “Is a given function or relation computable?” More
precisely, suppose we are given an algebraic system 31, also called
a data structure. (The system consists of a set called the universe, com
prising certain operations and relations. Does there exist an algorithm
to compute a function / i n 31?).
This and similar problems can be treated if one defines the meaning
of the notion of algorithm.
Suppose we are given an algorithm and a requirement, also called
a specification. The second group of semantic questions can be called
correctness problems. Here one can find questions such as: “Is an algo
rithm correct with respect to a specification?” “Does the algorithm
in question terminate?” “Is an algorithm a proper implementation
of the system required?”
The third important class of semantic questions, optimality prob
lems, contains questions like: “Is a given algorithm the best solution
of a problem?” “Does an optimal algorithm exist?” (From the abstract
theory of computational complexity we have learned that there exist
problems such that every algorithm solving one of those problems
can be replaced by a better algorithm which has asymptotically lower
computational complexity.)
The necessity of solving the above-mentioned problems in practice
makes it clear that we need to find a general mathematical theory of pro
grams. One possible way to approach this problem is to present a theory
of programs as a logical formalized system: algorithmic logic is one
of the first attempts in this direction.
The status of computer science as a deductive or an empirical science
is of secondary importance. In any case, it seems obvious to us that
research in computer science and the development of its applications
necessarily require a proper deductive system. To reason about algo
rithms we need appropriate inference rules which describe the semantics
of programming constructs. This need has been explained in many
publications (cf. Dijkstra, 1976; Scott, 1970). The research program
of algorithmic logic takes into consideration the demand for the con
2. INTRODUCTION TO FORMALIZED LANGUAGES 5
_L r
6
Fig. 2.1
2. INTRODUCTION TO FORMALIZED LANGUAGES 9
04- a 1j -<
-
Fig. 2.2
(Figure 2.2), then we can compose them by putting one after the other.
The flow-diagram of the composed program is described in Figure 2.3.
It is obtained by identifying the exit of P x with the entry of P2.
p p
r i *2
Fig. 2.3
Fig. 2.4
It is easy to see that the set of programs defined in this way forms
an algebra, which is generated from assignments by means of the oper
ations of composition, branching, and iteration. We shall call programs
of this class structural or modular ones.
10 I INTRODUCTION
We have seen in the previous section that one program may have many
interpretations. The process of interpretation (i.e., semantics) is defined
separately of the syntactical rules. Syntax decides which expressions
are well-formed ones; it does not determine the meaning of an expression.
It is generally agreed that in order to define an interpretation of a pro
12 I INTRODUCTION
R emark. This may seem an odd way to find that 1*1 = 1. The lit
erature concerning PROLOG and other non-imperative languages, and
also the discussion about the ‘fifth generation5 of computers, show
that there are many computer scientists who are convinced of the future
applicability of such a style of programming. □
14 I INTRODUCTION
\
j &(x, 0) = 0
/ g(s(0), 0) = 0
For this reason another method has been suggested by Scott and
Strachey (1971). Their proposal is to treat a program as an implicit
definition of an input-output mapping between states. The mapping
(i.e., semantics) is the least solution of a system of functional equations
which can be associated with every program. The elegance and simpli
city, of this method, which is called denotational semantics, have attracted
many researchers. The programmers can comment that, when this
method of identification of a mathematical object is used, its application
in verifying properties of programs is not always possible.
The third method of defining semantics, the axiomatic semantics
is similar to denotational semantics. A semantics is axiomatically defined
whenever a set of axioms and inference rules is given such that every
true semantic property of a program can be proved in the system.
Obviously, we require that the system should be consistent. Denota
tional semantics can be placed half way towards axiomatic semantics.
One can regard implicit equations as axioms. There are no syntactic
rules of inference; instead, the method offers a powerful semantic
tool—the least fixed point of the system of equations is proposed as
a solution.
For us, operational semantics based on the notion of computation
seems the most natural. Axiomatic semantics or mathematical identi
fication of meaning are secondary for a programmer who deals with
computations in his everyday practice. The programmers intuitions are
formed by computations. We realize that for the designer or imple-
menter of a programming language, denotational and axiomatic sem
antics may be very attractive. However, even the designer of a lan
guage should not overlook questions of effectiveness of implementation
connected with the operational semantics.
Practice allows us to make experiments and to develop our intuitions
about a computational process. However, this is not enough. What
we need is the possibility of formulating a specification before the
software is designed, and verifying the correctness of software with
respect to this specification. Let us quote here the well-known assertion
that computational experiments can help us to find a bug in our pro
gram, but no experiment can prove correctness of the program with
respect to a potentially infinite set of initial data. The verification should
be made before applying the program to the data. This is the proper
place for axiomatic semantics. It offers axioms and inference rules
16 I INTRODUCTION
Correctness. Does the program compute the results which were expected
from it? Our requirements (specification) can be given as a pair of
conditions, an input condition (precondition) for the data and an
output condition for the results (postcondition).
(program) (formula)
are also regarded as formulas.
The proposed meaning of the formula Koc, where K is a program
and a is a formula, would read “the formula Koc is satisfied in a data
structure 31 at a valuation v iff the computation of the program K
which starts from the initial data v in the structure 31 is finite and the
results satisfy the formula a”.
Let us look at a few of the semantic properties:
(i) a program K terminates iff the formula (Ktrue) is valid,
(ii) a program K is correct with respect to a precondition a and
a postcondition /? iff the formula (a => Kfi) is valid,
(iii) two programs K and M are equivalent with respect to a postcon
dition a iff the formula (Koc = Mac) is valid.
The cases of non-deterministic or concurrent programs require slight
modifications. A non-deterministic program can possess more than
one computation. It is then natural to split the question about results
into two different problems: “Do all results satisfy the required prop
erty?” and “Is there a result which satisfies the property?”. Accordingly,
20 I INTRODUCTION
6. ON APPLICATIONS
The main questions dealt with in this chapter are: “What are the
semantic properties of programs?” and “How can they be expressed
in a formalized language?”
We start with the definition of a class o f algorithmic languages which
admit iterative programs. Iterative programs are built from assignment
statements by means of program connectives like composition, branch
ing and iteration. Each program is interpreted as a binary input-output
relation in the set of all computer memory states. We then define the
notion of computation. This allows us to discuss semantic properties
of programs, like termination, correctness, etc. The importance of these
notions for the analysis of programs is obvious.
To express semantic properties of programs we shall use algorithmic
formulas, i.e., the constructions of a form K[i where K is a program
and is a formula. The intuitive meaning of this formula is “after
execution of program K the property holds”. Such constructions allow
us to express properties of programs and data structures which are
not expressible in the first-order language.
The next step is to formulate laws and rules concerning computa
tional processes. They provide us with formal tools for reasoning about
programs. We aim to construct a formal system in which all valid sen
tences are provable and all provable sentences are valid. However,
a more strict investigation of the semantics of the algorithmic language
leads to the conclusion that the compactness property does not hold.
This means that there exists a sentence which is a semantic con
sequence of an infinite set of formulas and which is not a consequence
of any finite subset of this set. The most important consequence of this
fact is that the logical system we are going to construct cannot be a fi-
nitistic one.
In this chapter we shall present a formal system of algorithmic logic
in the Hilbert style which uses infinitistic rules of inference of the co-type.
We shall prove that all provable formulas of this system are valid.
24 II LOGIC OF DETERMINISTIC ITERATIVE PROGRAMS
1. LANGUAGE
D efinition 1.2. The set o f terms T is the smallest set which contains
the set o f individual variables Vt and is closed with respect to the rule
that i f (p is an n-argument functor, qoe 0 9 and r l9 ... , r n are terms, then
the expression <p(r1, ..., rn) is a term. □
The set of all formulas F will be described later after the definition
of programs. We now recall the notion of an open formula.
D efinition 1.3. The set o f open formulas F0 is the least set that con
tains the set o f propositional variables V0 and such that
(i) if a, p belong to F0 then the expressions (aVjS), (a a /?), (a => /?),
~ a also belong to F0,
(ii) if r l9 ..., rn are terms and o is an n-argument predicate, then
q ( t 19 . . . 9 rn) belongs to F0. □
E xample 1.2. Assume/?, q are propositional variables and < , < , = are
two-argument predicates. Let x 9 y 9 z and + , • be as in Example 1.1.
The expressions
(1) (x = ((/• y) + z) a (z < y aO^ /)),
( ( ~ ? a p)=> (x + y ) - z < x + ( y - z ))
are then open formulas. □
oc —
» p = (a => /?),
—a = ~ a .
The set o f all propositional variables and elementary formulas is a set
° f free generators o f the algebra <F0, u , n , , - > .
26 II LOGIC OF DETERMINISTIC ITERATIVE PROGRAMS
The proof is analogus to that in classical logic, and also to the proof
of Lemma 1.3 below. □
D efinition 1.3. The set o f all programs IT is the least set such that:
(i) Every expression o f the form (x := r) or (q : = y) is a program,
where x is an individual variable, r is a term, q is a propositional variable,
y is an open formula.
(ii) Jf y is an open formula and M and M ' are programs then the
expressions if y then M else M ' fi, while y do M od, begin M; M ' end
are programs. □
The set of all expressions defined in (i) shall be called the set o f assign
ment instructions and will be denoted by S. Note that the pairs of words
then—else, else—fi, do—od, begin—end, play the role of parentheses
similar to (,). To avoid superfluous parentheses we shall write for example
1° begin M 1 ; ...; M n end instead of begin M t ; begin M 2 ; ... begin
M„_1 ; M n end ... end end;
2° while y do M x; M 2 od instead of while y do begin M 1 ; M 2 end od;
3° if y then M i ; M 2 else M[ ;M2 fi instead of if y then begin M i ;
M 2 end else begin M [ ; M 2 end fi. According to the definition the ex
pression (x :== x) is a program for every variable x. We shall denote
such a program by Id.
For the sake of simplicity we shall write if y then M fi instead of if y
then M else Id fi.
If M is a program and i— a natural number, then M l is a shortened
form of the program begin M; ; M end; M° = Id. The program begin
i times
M; M ' end is called the composition of programs M, M '; the program
if y then M else M ' fi is called the branching between the two programs M
and M', the program while y do M od is called the iteration o f the pro
gram M.
do
z := z - y ;
i : = i +1
od;
end; □
D efinition 1.4. The set o f all formulas F is the least extension o f the
set F0 such that:
(i) I f M is a program and a is a formula, then Ma is a formula.
28 II LOGIC OF DETERMINISTIC ITERATIVE PROGRAMS
(3) (3 j ) ( 0 := y) U (* := * + l ) * < x)
is a formula, where x, y 9 z, i are individual variables; + , * are
two-argument functors, < , = , ^ are two-argument predicates; 0, 1
are zero-argument functors. □
(O' - (* + j))+ z )-
2. As a second example let us take the formula (1) to be w. The ex
pression Jw is then a formula of the form
(x = ((/• (x + y ))+ z )A (z < (x +; f) a O < /)).
Obviously if x does not appear in the expression w then sw is ident
ical to w.
3. Note also these negative examples. When w is the formula (2) or
(3) then the expression sw is not a well-formed expression. □
Now we give the strict definitions of the free and bounded occurrence
of an individual variable in a formula.
2. SEMANTICS
Example 2.1. Let R be the data structure of real numbers and let
addition ( + ) and multiplication (•) be an interpretation of functors
-r, • of the language L.
The term ((/ - y) + z) then determines the three-argument function
/(/, v, z) in R such that for every valuation v in R
f(v { i), v(y), v(z)) = r«(v).
In particular, / ( 1 ,2 ,3 ) = 5. □
The element Ts%(v) of A is called the value o f the term r in the struc
ture 91 at the valuation v.
Analogously, every formula a of the language L determines a mapping
ol% from the set of all valuations W into the Boolean algebra B0,
{
ots&(v') if M<%(v) is defined and v' =
0 otherwise,
(UMa)^(V) = l.u.b.(Mla)gi^) (cf. Appendix A),
ie N
{(~}Mu)yL(v) — g.l.b.(M*a)«a(fl) (cf. Appendix A),
ie AT
((3x)a(x))®(®) = l.u.b. aa(»5),
aeA
((Vx)z(x)}u(v) = g.l.b. a®f©5),
aeA
2. SEMANTICS 33
The strict analysis of the example allows us to observe that the process
of evaluating a result of a program consists of consecutive steps in accord
ance with the structure of the program.
The notion of computation defined below captures the intuition
of the evaluation process.
or
< y ; M, M u M 29 M 3, ..., M„>, when ya (a) = 0.
5° I f a configuration o f a computation is in the form (v; ) i.e., i f it
has an empty list o f programs, //ze/z ft /s the last configuration o f the
computation and the computation is called finite. The valuation v is
called the result o f the computation. □
Assume that
®i = (X : = X + 1 )» (© S ),
i.e.
v fx ) — i and v fz ) = v(z) for z # x.
Then
a*(®) = l.u.b.(j < x)9,(®i) = l.u.b. (vi(y) < v ^ x ))
ieN ieN
Hence, for every valuation v in the structure 91, the formula a has the
value 1. □
Hence for every term r and every assignment instruction s (1) holds.
The proofs of (2) and (3) although a little longer, but are based
on the same idea and are therefore omitted.
(4) It is sufficient to prove property (4) for formulas of the form Mft9
where ft is an open formula and M is a while-free program.
The proof is by induction on the length of M.
(a) Suppose M is an assignment instruction s. According to property
(2) for every data structure 31 and valuation v 9 (s(3)%(v) = sfa(v).
By Lemma 1.4, sfl is an open formula. Thus s]i is the formula we need.
The inductive assumption is: suppose that for the programs M l9 M 2
and every formula /? there exist open formulas /?l5 /?2 such that
2. SEMANTICS 37
that v(x) is an even non-negative number satisfies the formula <5 and
any other valuation does not satisfy 8.
Hence 8 is satisfiable, but is not valid in 31 and is not a tautology.
Consider another simple example, in this case letting 8 be the formula
(5) M (otvft) = (Mot v Mft)
where M is a program and a, ft are formulas.
Let 31 be a data structure and v be a valuation. Then by the definition
of semantics 31, v\=. M(otv ft) iff M%(v) is defined and 31, v '\— (a v ft)
for v* = M%(v). Hence 31, v M(otw ft) iff 31, v |z: Mot or 31, v \=z Mft iff
31, v\= (Mot v Mft). Since 31, v are arbitrarily chosen, then 8 is valid in
every data structure, i.e., 8 is a tautology. □
3. EXPRESSIVENESS
Termination property
The most important property, and one of the easiest to describe, is the
termination property expressed as “the program has a finite compu
tation”, (see also Chapter I, § 4). According to the definition of se
mantics (cf. § 2), 31, v M true means that the program M has a finite
computation which starts from the initial valuation v in the data struc
ture 31.
Thus the termination property can be expressed by the formula
M true.
This formula gives us no information about how the terminating
property of a program depends on its structure, but it can be useful
to verifying the termination property. The appropriate facts are sum-
mated up in the following lemma. We shall use fin(M) as a denotation
of the formula M true, hoping that the wording of the lemma will
thereby be more suggestive.
3. EXPRESSIVENESS 39
Lemma 3.1. For every data structure $1, every open formula y, every
assignment instruction s, and arbitrary programs M, M \ the following
properties hold:
(1) 31 |n fin(V) ee true,
(2) 311= fin(begin M; M ' end) = fin(M'),
(3) 31 fin (if y then M else AT fi)
= (y a fin(M)) v ( ~ y a fin(M')),
(4) 31 }= fin (while y do M od) = U M ~ y .
Proof. The first three properties are very simple and easy to verify,
so we shall not prove them here. We would like to call the reader’s
attention to property (4). Its character is a little different from that
of the others.
By the definition of semantics (cf. § 2) for an arbitrary valuation v,
we have
31, v [= fin (while y do M od)
iff there exists such a natural number /, that M l is defined at v and
y%(M^(v)) = 1 for j < U y*{M k{v)) = 0 (i.e., after the i-th iteration
of the program M the formula y does not hold at the resulting valuation)
iff there exists f, such that 31, v [= M l ~ y iff 31, v [ z K j M - y . □
Observe that property (4) of Lemma 3.1 can be reformulated as
follows: For every valuation v
31, v |= fin(w hile y do M od) iff
there exists a natural number / such that
31, v [= fin(Mf) and 31, v' [= ~ y , v r = M%(v).
Sometimes it is convenient to have information as to whether the
program diverges. Let loop (M) denote the formula ~ M true. Obviously,
for every data structure 31 and valuation v
3l,^[=loop(M ) iff
M has an infinite computation in the structure 31 and the
valuation v.
Under the assumptions of the previous lemma we have the following:
Lemma 3.2.
3 1 1= loop (5) = false,
40 II LOGIC OF DETERMINISTIC ITERATIVE PROGRAMS
Observe now that the expression 31, v j= M true means that v is proper
data for the program M in the structure 31, i.e., there exists a valuation v*
such that M%(v) = v \ Hence, the formula M true describes the domain
of the program M, i.e., the domain of the mapping M%.
Obviously, the formula Ma satisfies both conditions (i) and (ii) and
therefore Ma is the weakest precondition.
3. EXPRESSIVENESS 45
Lemma 3.4.
(a) In every data structure 21 the following formulas are valid
(1) begin M; AT end a = M(Af'a),
(2) if y then M else M ' fi a = ((y A M a )v (^ y A M 'a )),
(3) M(ocvfi) = (AfavAfjff),
(4) M(oca /?) = (M oca Mf$).
(b) I f the formula (a => /?) is valid in a data structure 21, then the
formula (Mac => Mfi) is valid in 2t.
Proof.
(a)
(1) Let v be a valuation in a data structure 21.
21, v [n begin M; M ' end a iff
there exists a valuation v f such that (begin Af; AT' end)<a(z;)
= v' and 21, v' [= a iff
there exist valuations v ', v" such that M%(v") = v \ M%(v)
— v '\ 2t, v' [= a iff
there exists valuation v ” such that v" = M\n(v) and
21, |= M'oc iff
21, v |=:M(M'a).
The analogous proofs of (2), (3) and (4) are omitted (see also
Example 2.4).
(b) Let us assume that
211= O => /?)•
If 21, v }=: Mac for some valuation v, then by the definition of semantics,
there exists a valuation v f such that
M%(v) — v' and 21, v' [= a.
Hence there exists a valuation v' such that M^(v) = v f and 21, v’ /?,
i.e. 21, v }=: Mft.
46 II LOGIC OF DETERMINISTIC ITERATIVE PROGRAMS
As a consequence
31 [=: (Moc => Mp).
Correctness
D efinition 3.3. Program M is correct with respect to an input for
mula oc and an output formula p in a data structure 31 iff the formula
(oc => Mfi) is valid in 31. □
M*i{v) = v f.
Hence, there exists a valuation v' such that 31, v'\=aM and v' = M%(v).
Since 31 [= (ocM => j3), then 31, ^ |= Mfi.
Conversely, assume that
311= ((M true a oc) => Mft).
3. EXPRESSIVENESS 47
If for a valuation v, ^H9v\=z otM then there exists a valuation v' such
that 91, v ' a and = v. Hence there exists a valuation v',
such that
91, v' \=z (M true a a) and ^
By assumption, there exists a valuation v' such that
91, v' } = : and M%(v) — v,
i.e. 91, ^ [=/?. As a result, 91 }=: (aM => /?). □
Verification condition
od;
( a 7) {z ^ y A y = 2/+1 a z = x — i 2 a x > Oa / ^ 0}
(a8) {x—z2 ^ 2 / + 1 a z = x — i 2 A y = 2/+1}
if z = y then
(a9) { x — i 2 = 2 / + 1 az = x —i2 }
y := 0
(a io) {j = 0 a x = 0‘+ l ) 2}
else
(axl) {z2 < x < (z+ 1)2a z = x —/2}
j := z
(<*12) {y = x - i 2 a i2 < x < (z + 1)2}
fi
6*13) (J = * “ [ |/* ] 2}
end
0 *14 -) {j =
In this example, formulas (a2)-(a 6) can be repeated in order to
obtain a version of the annotated program formally corresponding
to Definition 3.5. Observe that whenever a computation passes from
one instruction to the other instruction then the following property
holds: if a formula a written before the instruction M is satisfied by
a state preceding the execution of the statement M, then the formula
appearing after the instruction M is satisfied by the state resulting from
the previous one after execution of the instruction M, cf. the formulas
(a3 =>( / : = z+ l)a4),
((«2 a z - j; < 0) => a7). □
3. EXPRESSIVENESS 49
By (3) and (6), 9t, ^ |= (ax v a2), and since 9 I,^ |= M true, then
91, a [= Mi true and 91, v \=z y and v* = M ^\{v)
or
91, ^ |= M2 true and 91, [= ~ y and v' = M 2%(v).
Thus by (5)
9l,a'|= /?i or 9 I,‘* /|=/?2.
As a consequence of (6), 9I,?/|= /? which contradicts assumption (4).
Hence
9 11= (( ocaM true)=> 0 ).
The remaining cases can be discussed analogously. □
E xam ple 4.1. Let Z be a set which consists of all formulas of the form
(1) (M~oc=> ~ Ma),
where M is a program and a is a formula.
Let 91 be an arbitrary data structure and v a valuation in 91.
Suppose 91, v |= M ~ oc and non 91, v [= ~ Moc. Hence 91, v |=
tzM ~oc and 91, ^ 1= Moc. Then there exists a finite computation
of the program M such that its result satisfies the formula oc and the
formula ~ a , which is a contradiction. Hence for every valuation v
9 I ,^ i= M ~ a implies 91, a |
Thus, every data structure 91 is a model for the set of formulas Z.
For our next example let us take as Z the set
(2) {while y do M od true, P|M y},
where y is an open formula, and M is a program. We shall prove that
there is no model for the set Z.
52 II LOGIC OF DETERMINISTIC ITERATIVE PROGRAMS
L emma 4.1. For arbitrary sets o f formulas Z and Z ' the following
properties hold:
(i) Z cz Cn(Z),
(ii) i f Z cz Z', then Cn(Z) cz Cn(Z'),
(iii) Cn (Cn(Z)) = Cn(Z).
P ro o f .
(i) This property is an immediate consequence of Definition 4.3,
(ii) Suppose a e Cn(Z) and Z cz Z'. Then every model of Z is a model
of {a} and every model of Z ' is a model of Z. Hence Z f \= a and there
fore a e Cn(Z'),
(iii) By the first two properties
Cn(Z) cz Cn(Cn(Z)).
To prove the converse, let a e Cn(Cn(Z)).
54 II LOGIC OF DETERMINISTIC ITERATIVE PROGRAMS
Theorem 4.1. It is not the case that whenever each finite subset o f
a given set o f formulas has a model then the set has a model, i.e. the
semantic consequence operation has no compactness property.
P roof. T o prove the theorem it is sufficient to consider the
set Z u {~ a} from the above example. □
T heorem 4.2 (on categoricity). The set AR has one enumerable model
up to isomorphism.
P roof. Example 4.1 shows that AR has an enumerable model 91
in the set of natural numbers.
Let 91 be any model of the set AR. We shall prove that 91 is isomor
phic to 91, i.e., there exists a one-to-one mapping h from the set of
natural numbers N onto the universe A of the structure 91 such that
HO) = 0*,
h(n 4" 1) = succ^(/z(zz)), for all n e N .
56 II LOGIC OF DETERMINISTIC ITERATIVE PROGRAMS
C o r o lla r y . The set AR has an infinite model and does not have a model
o f cardinality greater than K0. □
5. AXIOMATIZATION
Axl. ((a -->(])■=> ((/? => <5) => (oc => 5))) ,
Ax2. (a= > (av/3)),
Ax3. (fi => (oc v fi)),
Ax4. ((a => <5) => ((/? => <5) => ((av/1) => <5))),
Ax5. ((a a fi) => oc),
Ax6. (( oca/3) => /?),
Ax7. ((5 => a) => ((<5 => j8) => (<5 => (a a / ? ) ) ) ) ,
Ax8. (a => (/? => 5)) = ((a a /?) => (5),
Ax9. ((a a ^ a ) => fi),
AxlO. ((a => (a a ~ a )) => ~ a ) ,
A xil, fav ^ a ),
Ax 12.
Axl 3. s~oc — ~soc,
Ax 14. M ( oca fi) = (M oca Mfi),
Axl 5. M(ocv fi) — (Moc v Mfi),
Axl6. U M a = (a v U M (M a )),
A xl7. s ( a a (~)M(Moc)),
Axl8. .9((3x)a(x)) = (3j) (s ((x := j)a (x ))), where j is an in
dividual variable not occurring in s9
Axl9. (((x : = r)oc(x)) => (3x)a(x)), where r is a term,
Ax20. (Vx)a(x) = ~(3x) ~a(x),
Ax21. begin M; M ' end oc = M(M'oc),
Ax22. if y then M else M f fi a = ((yA Moc) v (~ y A M'oc)),
Ax23. while y do M od a = ( ( ~ y a a) v (y a M(while y do M
od a))).
We shall denote the set of all axioms by Ax.
The inference rules are as follows:
a, (oc=>fi) («=> P)
rl. r2.
P (Moc => A/y5) ’
, (M((x: = y)oc(x)) => fi)
where j is an individual variable,
(M(3x) a(x) => jff)
occurring neither in oc nor in fi,
4 {(M '(M loc) => j8)}fgAf rS {Q? =>
(M '1J Ma => fi) (^ A T flM a )
((a a true) => a){Ax5} (((a a true) a) => (a => (true ■■=>a))) {Ax8}
r2
by Fact
= ( ( r A P'i) v ( ~ y a /?','))
In particular,
I—((if 7 then M f\)l( ~ y /\ a) => l_J if y then M il ( ~ y a a)).
Hence by the co-rule r6
(fl3) h - (while y do M od a I J if y then M fi ( ~ y a a)).
We shall prove
(4) I—((if y then M fi)l(~ yA a) => while y do M od a )
analogously by induction with respect to the number of iterations /.
For / = 0 we have
(f 14) b - ( ( ~ y A a ) = > (( ~ 7 a a ) v (7 a M (while y do M od a ) ) ) )
{Ax2}
I—((~ 7 A a) => while y do M od a ) {Axl, r l , Ax23, f 14}
Assume that for a fixed natural number i,
(f 15) f—((if y then M fi)l( ~ 7 Aa) => while y do M od a).
We shall prove (4) for the natural number (z+1).
(f 16) I - ( (if y then M fi)i+1( ~ y A a)
=> ((7 a M (while 7 do M od a ) ) v
v ( ~ 7 A ( if 7 then M fi)*(~7A a )))) {fl5, Ax22}
64 II LOGIC OF DETERMINISTIC ITERATIVE PROGRAMS
(f 17) l - ( ( if y then M f i) i+ 1 ( ~ y A «)
=> ( y a M (w hile y d o M od a ))v (~ y A « ))), {f!6 }
b- ( ( if y then M fi)t+1 ( ~ y A a )
=> w hile y do M od a). {Ax23,fl7}
Thus by the principle of induction (4) is proved.
By the co-rule r4 we have
(f 18) b- ( U i f y then M f i ( a) => w hile y do M od a).
By (f 13) and (fl8)
b- (while y do od a = U if y then M f i ( ~ y a «))■ □
6. MODELS A ND CONSISTENCY
Lemma 6.2. jFbr every inference rule o f AL, if the premises o f the rule
are valid in a data structure 31, then the conclusion o f the rule is also
valid in 31.
6. MODELS AND CONSISTENCY 67
Corollary 6.3.
(i) The algorithmic logic AL is consistent.
(ii) J f a theory T has a model, then it is consistent.
It is sufficient to prove property (ii).
P ro o f .
Let 51 be a model of a theory T = <L, C, A ) and let every formula oc
be a theorem of T. By Corollary 6.1, for an arbitrary valuation v we have
51,^1= oc and 51, v \=l ~ oc,
which is a contradiction. □
This section presents the tautologies and inference rules which we con
sider useful in proving properties of programs.
The proofs in this section are not formal. We have omitted many
steps related to classical propositional calculus in order to underline
axioms and inference rules specific to algorithmic logic.
In all the formulas below a, are arbitrary formulas, M, M ' are
arbitrary programs, y, y are open formulas and Z is a set of formulas.
0) b- M ~ oc => ~ Moc.
70 II LOGIC OF DETERMINISTIC ITERATIVE PROGRAMS
P roof .
b- false, {Example 5.4}
b- ~ M (~ a A a ),
b- ( ^ M ^ a v ~M a), {Axl4}
\—(M ~ oc => ~Moc). □
(4') 1- (M true => ((M a => M/J) = M (a => 0 ))). {(3), (4)}.
(5) For every natural number /,
b- (M*a => 1JMa).
(6) For every natural number /,
b- (P)M a => M la).
7. USEFUL TAUTOLOGIES AND INFERENCE RULES 71
( 8) h- ( ( a a P ) M ( a => A f a ) ) => f ~ ) M a ) .
Proof.
h - ( f ) M ( a => M a ) => M ‘ ( a => M a ) ) fo r e v e ry i e T V , { ( 5) }
( f l) F - ( H M ( a => M a ) => ( M i oc = > M i + 1oc) ) fo r e v e ry i e TV,
{ ( 3) }
F- ( ( a a p | M ( a => M a ) ) => a ) . { A x 5}
A s s u m e th a t fo r a n a t u r a l n u m b e r i,
(f2) F ((a A (~ )M (o c => M a ) ) => M ‘a ) ,
h- ((aA => Ma)) => (M 'a a (M'a => M i+ 1a))),
C \ M ( *
{fl,f2}
I- ((aA DM(oc => Afa)) => (M i+1aA (M 'a => M t+1a))).
Hence by the principle of induction
h ( (« a p)Af(a => M a)) => M fa ) for every i e TV,
F- ((a a (~}M(oc => M a)) => P |M a ). {co-rule r5} □
Proof.
h- (f)M (M a) => M*(Ma)) for every z e TV, {(6)}
F- (P|M (M a) => M (M fa)) for every i 6 TV, {A x 2 1 }
(f 1) F- => M f l M a), {r5}
F -(p |M a => M 1ol) for every / eTV, {(6)}
F- ( M f |M a => M (M loc)) for every z*eTV, {r2}
F- (M p )M a => M*(Ma)) for every i eTV, {A x 2 1 }
(f2) F- (Af H Ma => p | M i M ol)), {r5}
F- ( M H ^ * s D M(Ma))- {f1, f2}
(10) F- \ J M ( M ol) = M (JM a .
The proof analogous to the previous formula is omitted. □
(12) (« = > «
{f)M x ^ f W
The proof is analogous to the previous one.
a, M true
(13)
Moc
For the proof see Example 5.1.
(y => ~ M ~ y)
(14)
\y => ~ while y do M od true)
Proof. Let Z be an arbitrary set of formulas
(fl) Z (y => ~ M~y), {assumption}
Z b- (((y A M ~ y )v ~y)= > ~ y ) , {A xl-A xll}
Z f- (if y then M fi ~ y => ~y). {Ax22}
Assume that for a natural number i
(f2) Z ((if y then M fi)' ~ y => ~ y ), {inductive assumption}
Z h- ((if y then M fi)i+1 ~ y => if y then M fi ~ y ),
{r2,f2}
Z b~ ((if y then M fi)£+1—y => ((yAM^ - y ) v ~ y )),
{Ax22}
Z h- ((if y then M fi)l+1~ y => ~ y ). {fl}
Hence by the principle of induction
Z b- ((if y then M fi)l ~ y => ~ y ) for every / € N.
Thus by rule r6,
Z h- (while y do M od true => ~ y),
Z b- (y => ~ while y do M od true). □
_________ /___________
^ } ~ while 7 do M od true
The proof follows immediately from rule (14). □
( 1 7 ) _______________________________________________
(while y' do M od true => while y do M o d true)
P ro o f .
(fl) Z \- (y => y'), {assumption}
Z b- ( ~ y => while y do M od true). {A x23}
Suppose that for the natural number /,
Z b- ((if y' then M f i ) ' ~ y ' => while y do M od true),
{inductive assumption}
Z b- ((if y' then M fi)I+1 ~ 7 ' => if y* then M fi (while y
do M od true)). {r2, inductive assumption}
(f2) Z b- ((if y' then M fi)l+1 ~ y' => ((7 ' a M (while y do M od
true))v ( ~ y* a while y do M od true))), {A x 22}
Z b- ( ( ^ y ' A whUe y do M od true) => ^ 7), {A x23, f l }
i - ( ( ( / a M while y do M od true)v ~ y )
=> ( ~ y v ( 7 ' a 7 a M (while 7 do M od true)) v ( 7 ' a ~ 7 a
A M (w hile 7 do M od tru e )))), {A x l-A x ll}
Z b- (( 7 ' a M (while 7 do M od true) v ~ 7 )
=> ( 7 A M (w hile 7 do M od tru e)v ^ 7 ) ) ,
z 1- ( (if 7' then M f i)l+1 ^ 7 ' => ( 7 A M (w hile 7 do M od
true) v ~y))» {f2}
z 1- (O f / then M fi)i+1^ 7 ' =>while 7 do M od true),
{Ax23 }
z i- ( ( if y' then M f i) £^ 7 ' =>while 7 do M od true)
for every i e N, {principle of induction}
Z h- (while y' do M od true =^> while 7 do A f od true).
{r6} □
(18) If V(M)nV(oc) = 0 , then b -( A f true =^> (Moc = a.))
The formal proof of (18) is very long. It goes by induction on the com
plexity of the expressions M and a. Another proof which is of semantic
character will be given in the following chapter. □
AT' true
(19)
(while 7 do M od true => while 7 do M ; M ' od true) 5
where K (A /')n F(w h ile 7 do M od) = 0 .
74 II LOGIC OF DETERMINISTIC ITERATIVE PROGRAMS
Proof.
Z b- ( ~ y => while y do M; M ' od true). {Ax23}
Assume (the inductive assumption) that for a natural number /,
Z h- ((if y then M fi)l ~ y => while 7 do M; M ' od true),
Z b- ((if y then M fi)1~ 7 => M '(if 7 then M fi)‘ ~ 7). {(18)}
Thus
Z b- ((if y then M fi)i+1y =>(7 a M (M ' (if y then M fi)l’~ y ) v
v ~ 7 a (if 7 then M fi)* ~7).
By the inductive assumption we have
Z b- ((if 7 then M fi)*+1 - 7 =* (7 a M (M ' while 7 do M; M'
od true) v ~ 7 a while 7 do M; M' od true)).
Hence
Z b- ((if 7 then M fi)l+1 ^ 7 => while 7 do M; M' od true).
{Ax23 }
By the principle of induction, for every i e N
Z h- ((if 7 then M fi)£—7 => while 7 do M; M r od true).
By rule r6
Z h- (while 7 do M od true => while 7 do M; M' od true). □
More strictly we shall prove that the formula (£ => KS) is provable
in the theory of Archimedean fields (cf. Chapter IV).
Let us assume the following abbreviations:
M : begin
x := (a+b)/2;
iff(a) •/(x ) < 0 then b x else a : = x f i
end,
d ,: (f(a) -f(b) ^ 0 A (b -a ) = &/21) for k > 0 and 1 e A.
We shall prove a few lemmas in order to illustrate the role of axioms
and inference rules.
P roof . Observe that the following two formulas are theorems in the
theory of fields:
( (b - a ) = k=>((a + b ) /2 - a = k/2 ab-(a + b)/2 = k/2)),
C*d) ) 'fib) ^ 0 => ( d f( a ) ^ 0 v d f ( a ) > 0 a </•/(£)
< 0 )).
Substitute d — /((fl+ 6 )/2 ). By propositional calculus we have
(d0 => ( ( / 0 + *)/2) -/(fl) $ 0 a ( ( a + i ) / 2 - a ) = A/2) v
v ( f ( (a + b)/2) -f(a) > 0 A f ( ( a + b)j2)-f(b) < Oa
* ( b - ( a + b ) l 2 ) = A/2))).
Applying the axiom of assignment Axl2 twice
(z := r)y = yCz/r),
we obtain
(d0 => ((x := (a+b)/2)(f(x)-f(a) < 0 a (x —a) = A/2) v
v (x := (a + b)/2)(f(x) •f(a) > Oa / ( x) •/(£) Oa
A(fc-x) = A/2))).
By axiom Ax 15
M(ccvfi) = (MxvMfi),
we have
(d0 =* (* := (a+ i)/2)(/(x)-/(a) ^ Oa (x—a) = A/2 v
v/(x) -/(a) > 0 a /(x) -/(A) «S Oa ( b - x ) = k/2)),
which is equivalent by Ax 12 to
(d0 => (x : = (a+b)/2)(f(x)-f(a) Oa (b := x ^ v
v/(x)-/(a) > 0A (a := *)d,)).
By axiom Ax22
if y then M else A fi a = ((7 a Ma) v (~ yA Aa)),
we prove
(30 = (x := (a+b)/2 )(if f{x)-f{a) ^ 0 then b \ — x
else a := x fi e^)).
Hence (<50 => M d f is provable in the theory of ordered fields. □
Lemma 8.3. For every natural number i the following formula is prov
able in the theory o f ordered fields
{d0 => M i61). □
The proof of Theorem 8.1. For every natural number j > 0 we can
prove by Lemma 8.3 the following formula:
(1) ( ( k > e > Oa <50 a e-j = k)
=> M J(f(a)-f(b) ^ 0 a b - a = k/2j a kjj < e)).
By axioms of fields and axioms Ax 12 and Ax23 of algorithmic logic
the following two formulas are provable:
((z := e)(z := z + e)jz ^ k => e 7 ^ k ),
( M J (f(a) f(b) < 0 a b - a = k/2J a k/j < e)
=> while b —a > e do M od <5).
Hence using propositional calculus and (1) we have proved
((z := s){z := z+e)J z ^ k => ((k > e > 0 a <50) => Af<5))
for every j ^ 0. By co-rule r6 of algorithmic logic we obtain
(2) ((z := £) (while z < k do z := z-f e od true)
=>(k > e > 0 a <50 => Kd)).
Making use of the following form of Archimedean axiom:
(k > e > 0 => (z := e) (while z < k do z := z + e od true)),
we obtain, by (2), the following theorem:
((<50 a k > s > 0) => Kd).
Thus the formula (f => Kd) is also provable. □
BIBLIOGRAPHIC REMARKS
1. LINDENBAUM ALGEBRA
Lemma 1.1. For every formulas a, /?, a', /?' and every program M ,
i f /? x P' and oc X a' then
(aV|?) ^ (a 'v /?'), (a => jff) a (a' => /S'),
(a a /?) « (a'a /S'), ~a « ~ a ',
Ma s Afa',
I J M a # (J M a ', f j M a ~ f |M a ',
(3x)a(x) # (3x)a'(x), (Vx)a(x) « (Vx)a'(x).
Proof. The first four equivalences follow by classical propositional
calculus.
The equivalence M a « Afa' follows immediately from the assumption
a « a' by the rule of inference r2.
The equivalences p j M ol x p j M ol' and p ) Ma ~ p) Mcx! follow from
the assumption a s; a' by rules (10) and (11) from Chapter II, § 7.
Let a(x) « a'(x) and let x be an individual variable free in a and a'.
Then by r2,
(x := r)a(x) ~ (x := r)a'(x) for every term r.
Hence by Ax 19,
(x := r)a(x) => (3x)a'(x) and
(x := r)a'(x) => (3x)a(x).
Let us take as r an individual variable y such that y $ V ( ol)\j V{ol).
Then by r3
(3x)a(x) => (3x)a'(x) and (3x)a'(x) => (3x)a(x).
From the above and Ax20 it follows that
(Vx)a(x) = (Vx)a'(x). □
Let F I« be the set of all equivalence classes with respect to the re
lation ^ • By |la|| we shall denote the set of all formulas /S e F such
that a # /?.
As a consequence of Lemma 1.1 we can consider a quotient algebra
1. LINDENBAUM ALGEBRA 81
82 III METAMATHEMATICAL INVESTIGATIONS
Fig. 1.2
Fig. 1.3
of the formula (a =>/9) for every ft e F. Thus ||a|| < \\f}\\ for every
P e F , i.e. ||a|| = 0 . □
((a a /3) => a) {Ax5} {Ax 8 } (((a v/3) =s> a ) => (a =► => a)))
{Ax 9} {Ax 8}
Fig. 1.8
L emma 1.3. For every formula a and all programs M and M ' the follow
ing properties hold'.
(i) \\M'\JM<x.\\ = l.u.b.||M '(M 'a)||,
ie N
(ii) IIM 'fW ail = g.l.b.|iM '(M i«)||,
ieN
(iii) \\M'(lx)<x(x)\\ = l.u.b.||M '(* : = r)a(*)ll,
zeT
(iv) ||M '(V*)a(x)|| = g.l.b.||M '(* : = r)a(x)||.
zeT
P ro o f. By properties (5) and (6) from Chapter II, § 7, it follows
that
H (Af'(M*a) => M 'U M a ) and h- (M'f~)Moc => M '(A f'a))
for every natural number /. Hence, as a result of application of rules
r4 and r5 we have
||M 'iM tyW < ||M 'U M a|| and ||M 'fW * ll < ||M ,(M la)||.
88 III METAMATHEMATICAL INVESTIGATIONS
Let us suppose that there are formulas d, d' such that for every natural
number /,
||M '(M ia)|| ^ ||<5|| and \\d'\\ < \\M\M*a)\\.
By inference rules r4 and r5,
I I M 'U ^ H < \\d\\ and ||d'|| ^ \\M 'PiM a\\.
This implies (i) and (ii).
To prove (iii), note that by Ax 19
\\M'(x := r)a(x)|| ^ ||M '(3x)a(x)||
for every term r e T. Suppose for some /9 e F that
||M \x := r)a(x)\\ < ||/?|| for all r e T.
In particular
A |- (M '(x := j)a (x ) => /?)
for an arbitrary individual variable y occurring neither in M ' ol nor in /?.
Thus by rule r3, A h (M '(3 x) oc(x ) => /?), i.e. ||M '(3*)a(*)|| ^ ||/S||.
Hence (iii) holds.
The analogous proof of (iv) is omitted. □
Lemma 2.2. For every set o f formulas Z there exists a formula a which
is the minimal element in Z with respect to the relation -<.
For the proof see Appendix B. □
P roof of L emma 2.1. Clearly Lemma 2.1 holds for all propositional
variables and for all elementary formulas.
Assume that Lemma 2.1 holds for all formulas which are submitted
to the formula a
(2) 9tr ,*y |=/? iff \\P\ \ e P , for all /? ■< a.
Below we shall consider the different forms of the formula a.
1. Let a be of the form sg(rl9 ..., r„). By Lemma 2.1 in Chapter II
it then follows that
Lemma 2.3. For every valuation v in the data structure and for
every formula a, there exists a program M such that
<**F(*0 = (Moi)nF(Vy).
Proof. Let x l9 . . . 9x n be the sequence of all individual variables
that occur in a and let v be a valuation such that z;(xf) = r i9
for i = 1, n.
Let P i , " - 9pm be the sequence of all propositional variables that
occur in a and let us assume that
_ [true, if v(pj) = 1,
aj (false, if v(pj) = 0 for j = 1, ..., m.
Consider a program M of the form
Theorem 2.6. For every formula oc, |— oc iff (=: a, i.e. the algorithmic
logic is complete.
This theorem follows directly from the previous one. □
Theorem 2.5 indicated that the semantic and the syntactic methods
can be used exchangeably. To prove a theorem we can construct a for
mal proof or discuss its validity. In most examples the second method
is easier than the first.
since the value of a formula depends only on the variables that occur
in it.
Hence for every 91 and v
91, v |=i (M true => (a — Afa))
and, as a consequence of the Completeness Theorem, the formula
(M true => (a — M a)) is a theorem of algorithmic logic. □
D efinition 3.1. We shall say that a formula oc is closed iff the value
o f oc does not depend on any valuation in any data structure. □
Let us note that the Deduction Theorem does not hold if a is not
required to be closed.
In view of Chapter II, § 4, the Upward Skolem-Lowenheim
Theorem of classical logic fails to hold in algorithmic logic. However,
it can be easily proved that the downward theorem holds.
D efinition 4.1. We shall say that the execution method for programs
is proper for AL iff the satisfiability relation which is based on it allows
the soundness o f AL axiomatization to be proved. □
Obviously the standard execution method is proper for AL. The ques
tion naturally arises as to whether there are other different execution
methods proper for AL.
The program execution method is strictly connected to the problem
of implementation. Can we treat our axiomatic system as a criterion
for the correctness of implementation?
The main conclusion of this section is that all conceivable proper
execution methods of programs are similar in the sense that they induce
the same input-output relations.
The completeness theorem can be then interpreted in a way which
shows that the notion of computation is the one natural execution
method for programs.
Now we shall formulate the thesis of this section more strictly.
Lemma 4.1. For every program M, if property (3) holds for. arbitrary
formulas a, ft, where
(3) 911= M(oc A P ) = {M ol a Af/3),
then J{M) is a partial function.
Proof. Suppose 0v, v x) 6 1(M) and (?;, v 2) e I(M ) and v x # v 2.
It follows from assumption (1) that there exists a formula a such that
9 I,^ 1 (=:a and 91, v 2 (zz ~ a . Hence, 9I,^t= A fa and 91,^1—M ~ ol.
However, non 91, v \h M{ ol a ~ a), contrary to (3). □
For any open formula y, let id(y) denote the set {(v , z;):3I, v |= y).
... a — Cffif
where x i 9 ...9x n are all individual variables and ql 9 ...9qm are all
propositional variables occurring in while y do M od a1 and
jtrue iff (qj) = i,
Cj (false iff = 0.
Hence
91, v x (=: while y do M od ax and 91, v 1 ]pPl9 i.e.
non 91 l=i (while y do M od ax => ^jffi).
102 TII METAMATHEMATICAL INVESTIGATIONS
fe □
D efinition 5.2. A sequent A -> F is said to be axiom-sequent
f n A ¥=0.
7B r Au A 2 i s(yAK<x), s{~yA M a)
r - + A l9 s i t y then K else M fi a, A 2 ?
«A {^ 9^2 > y then a) -> A }ieN
A , s while y d o M o d a , f 2 -> /I
r -+ A l9 A 29 s { ~ y a a), s(y a M while y do M od a)
r -+ A l9 s while y do M od a, A 2 ’
OA ( A , r 2,s (M i(x) -» zl }/e TV r A 1, A 2, soc, s \J M ( M oc)
r l9 s \ j M * , r 2 -* a ’ r ^ A , * U ^ a >A ’
1(K A , A , - , , n M ( M a ) - ^ 10R { r -* A l9 A 29s(M i<x)}ieN
r l9 s f \ M * 9r 2 -* a 5 ’
11A ^ 1? A> :== T) a (*)> ^CV-yja -» /I
A , .s(Vx)a(x), A “* A
r ~ * Al 9 A2,s(x := y )«
11B
jT -» Zl j , 5(Vx) a (x ), A2
where j is an individual variable which does not appear in s and a,
A »A A s(Vx) ~ a A *s(Vx)~a -» A , A
12A 12B
A >*s(3x )a, A “* A .T -> A , 5(3x)a? A
In all the above schemes A and A denote sequences of indecom
posable formulas and A ? A > A ^ are arbitrary sequents of formulas;
5 denotes a sequence of assignment instructions; a, /? arbitrary formulas;
y denotes an open formula; M 9M ’ denote arbitrary programs; r is a term.
Observe that the rules of decomposition reflect the axioms and
rules of Hilbert style axiomatization (cf. Chapter II, § 5). Rule rl
(imodus ponens) has no counterpart among decomposition rules.
Lemma 5.2. For every data structure 31 for the language L , for every
valuation v in 31 and for every rule o f decomposition o f the form
{Ej Aj}jeJ
r-> a
the following condition holds
i /\ r = > \ / A ) %(v) = g .ib .( A r j => V ^ M v ) .
jej
The proof follows immediately from Lemma 5.1 of Chapter II. □
Lemma 5.3. I f the diagram o f a formula a is a finite path tree and all
leaf-sequents are axioms, then a is a tautology. □
Lemma 5.5. I f the diagram o f the formula oc0 has an infinite path,
then a0 is not a tautology.
Proof. Let <D, d ) be the diagram of the formula a 0 and let Path
= {Ci}ieN he an infinite path in D. Assume that d{ct) — r t A i9
for i g N.
108 III METAMATHEMATICAL INVESTIGATIONS
The aim of this section is to prove that every program can be trans
formed into a form which contains the single occurrence of the
while-operation.
We shall start with the auxiliary definitions. Let v ,v ' be the two
valuations and let X be a set of variables. We shall say that v = v f off X
if and only if for every z $ X ,v '(z ) = v(z).
The proof follows immediately from the fact that the value of every
formula depends solely on variables which occur in it. □
end
(5) if y then K else M fi ~ M " off ({#}).
M ": begin
q := y\
if q then K x else M t fi;
while (q a y x) v ( ~ q a y2) do
begin begin
j i
Kt q : = true
Fig. 6.1
Fig. 6.2
7. EQUALITY 115
if q then K2 else M 2 fi
od
end
(6) while y do K od - M "' off ({#}).
M " r: begin
q true;
while ((q A y ) v ~ q ) do
if (q a y) then ; q := false else
if y t then K2 else q := true fi
fi
od
end.
Theorem 6.4. For every program M there exists a program M ' in the
normal form such that V{Mf) 3 V(M) and M ~ M ' off (V (M ')—V(M )).
Moreover, all variables from the set V(M ’) —V(M) are inessential for
the program M '. □
7. EQUALITY
In this and the next few sections we shall discuss some extensions of the
algorithmic language introduced in Chapter II. The character of these
extensions will differ. In this section we extend the alphabet by admitting
equality, in § 8 we extend the set of well-formed expressions by gener
alized terms and parallel substitutions, and in § 9 we extend the notion
of data structure in order to discuss partial functions.
In all these extensions the corresponding notion of tautology can
be axiomatized and the Completeness Theorem can be proved.
Let us assume that the alphabet of algorithmic language L contains
the binary predicate of equality = .
By (2)
(4) 21, v\ (=: (while ~ (x = y) do M od true
=> (oc(xjy)A M {x/y) true))
for an arbitrary vector a of elements in 21 which corresponds to j>,
where vi is a natural extension of the denotation vya (cf. Chapter II, § 2).
Let us take as a a sequence ai9 ..., an such that
aj = M k~1(v)( xj ) for j < n.
Thus
21, vt (=: — y)
and therefore 21, v} (=: while ~ (x = do M od true. As a consequence
of (4) we obtain
2I,^| |~M(xly) true, i.e. 21, v juA/1’ true.
Let us take as a a sequence al9 such that
aj = M^{v)(Xj) for all 1 ^ j ^ n.
118 III METAMATHEMATICAL INVESTIGATIONS
Thus
91, v t fn M '(x = y)
and therefore
91, vt |= while ~ (x = y) do M od true.
By (4) we obtain
91, v ia \=zoc(xly), i.e. 91,^ \=zMloc,
a contradiction.
The converse implication can be proved analogously. Hence for
mula (1) is valid for every data structure and every valuation. It fol
lows from the Completeness Theorem that formula (1) is a theorem
of algorithmic logic with identity. □
Lemma 7.3. For all programs M, M ' and every set o f variables VAR
M ~ M ' off VAR iff for every formula a, such that F(a)nVAR = 0 ,
Moc == M'oc is a theorem o f algorithmic logic with identity.
Proof. Assume Moc = M'oc is a theorem of algorithmic logic with
identity for every oc such that F(a)nV AR = 0 . Let 91 be a data struc
ture proper for identity and v a valuation in 91. By the Completeness
Theorem and by the assumption M%(v) is defined iff M%(v) is defined.
Suppose that for some v,M^(v), M^{v) are defined but that there
exists an individual variable x such that x £ VAR and
M%\(v)(x) ^ Mk(v) (x).
Let us consider the formula x = y, where y $ F(M )uF(A f), and let
a = Mn(v)(x). *
It follows from the above that
8. GENERALIZED TERMS
(Mir)i)n(v) = Tw(v), 1^ ^ «,
for every data structure 51 and every valuation v. Hence
•••, r«h(v) = i»?)a(®)> •••>
8. GENERALIZED TERMS 121
is in the normal form and for every data structure 21 and valuation v9
r a (z>) = <pu(rm (v), ..., T„a (©)).
It remains to consider a generalized term of the form M r. By the
inductive assumption there exists a normalized term Kr\ for r such that
(Krj)u(v) = r%(v)
for all 21 and v.
Thus begin M; K end rj is a generalized term in the normal form
such that for all 21 and v 9
(begin M \ K end rj)%(v) = (Mr)%(v). □
Lemma 8.3. For every formula o f the form (1) there exists a program
K and terms rjl9 ...9rjn such that
f=eOi> •••> r») = K q ( tji,
The result of Lemma 8.3 can be generalized to the set of all formulas.
L emma 8.4. For every formula a o f the language L' there exists a for
mula %(cc) o f the language L such that
t= a = *(«)•
The details of mapping % can be found in Mirkowska, 1975. □
T heorem 8.5. For every set o f formulas A and every formula a o f the
language L f the following conditions are equivalent:
(i) a is valid in every model o f the set A;
(ii) a has a formal proof from the set A extended by the formulas
o f the form
Mo{ t 1# . . . , r„) = q ( M r l9 . . . , M r„ ),
e ( r £, r j == •••> *„)),
9. PARTIAL FUNCTIONS
such that
(i) for every me-argument predicate q of L, ^ is an /^-argument
relation in A,
9. PARTIAL FUNCTIONS 123
Lemma 9.1. For every program K o f the language L there exists a for
mula fail(AT) o f L such that for every data structure 91 and every valuation v
91, v |=pf fail (A) iff there exists an unsuccessful computa
tion o f K from v in 91.
P roof. Let us consider the following recursive definition
fail(x := w) ^ ~ E ( w) ,
fail (begin X ; M end) = fail (K) v K fail(M),
fail(if y then M else K fi)
= (E(y)=> ( y A f a i l ( M ) v a fail(A)))
fail (while y do M od)
= ( J i f 7 then M fi (E(y) => (yAfail(M ))).
The lemma follows immediately from the definition of semantics and the
construction of the formula fail(Af). □
T heorem 9.4.
(i) I f a theory <L, Cpf, A) is consistent, then it has a model.
(ii) For every consistent theory T = <L, CPf, A ) and for every for
mula oc o f L
A 1—Pfa iff 9t (=Pf oc fo r the arbitrary partial data struc
ture 91 which is a model o f A. □
10. MANY SORTED STRUCTURES 127
D efinition 10.1. The set o f all terms Tm is the least set o f expressions
such that:
(i) i f x e Vj for j e SR , then x is a term o f type j 9
(ii) i f <p is an n-argument functor o f type (j^ x ... x j n -> j ) and
is a term o f type j ( for i ^ n9 then cp(r1, ..., rn) is a term o f type j. □
D efinition 10.2. The set o f all elementary formulas is the least set
o f expressions such that i f q is an n-argument predicate o f type (j\ x ... x j n)
and r L, ..., r„ are terms whose types are j i9 respectively, then the
expression q{xx, ..., r„) is an elementary formula. □
128 III METAMATHEMATICAL INVESTIGATIONS
For the rest of this section let L m be a fixed many sorted algorithmic
language and let Lpf be a fixed partial function language based on the
same alphabet (cf. Chapter III, § 9). It may be easily observed that Lpf
is an extension of Lm.
It follows from the last definition that every partial data structure
for the language Lpf can be considered as a many sorted data structure
for the corresponding many sorted language L m (cf. Chapter III, § 9).
If 9tpf = <>l, {v%f} We<P, teaPf W > is a data structure for Lpf,
then the following structure
(4) = <U
j e SR
A J> (W }y>e<P, {Q % } q e p }
data structure for the language Lm, then we can define a corresponding
partial data structure
(5)
such that:
(a) A = U ^
j e SR
Let 2Imbe a many sorted data structure for L mand 21 the corresponding
data structure for the language Lpf as defined in (5).
L emma 10.2. For every formula a o f L rn and for every valuation v which
satisfies condition (6) the following equivalence holds
<
%m,v\=zmoc iff 21, v j=pf a.
P roof. It suffices to determine whether the lemma holds for ele
mentary formulas.
Let ip be an ^-argument functor of the type ( jt x ... x j n -» j) and let
Xi e Vj. for i ^ n. y (x l9 ..., x n)vm(v) is then defined iff V%m(al9 ...,a n)
is defined for at = v(xt), where i ^ n. Hence by assumption (3) and
Definition 10.4, (ax, ..., an) e gm and v ( x i) e A Jr This is equivalent
by (5) to (al9 ...,a „ )e g m and therefore y>(xi9 is defined.
Thus by induction on the length of term r we can prove that r%m{v)
is defined if and only if is defined and, moreover
(7) r * jv ) = tk(v).
Let q be a predicate of type ( j\ x ... x /„) and let r l9 ..., r„ be terms
whose types of results are j \ , ... 9j„9 respectively. 2lm, v \=mq (r t , ..., rn)
if (al9 ...,a„) for r /9T (v) defined and equal to ai9 i < n, where
at e A j.. Hence by (7) and the definition of the structure 21 we obtain
rm(v) is defined, at = r^fv ) e AJt and (at ,..., an) e q<&.
This last property is equivalent to 2t, v |=pf q( t x, ..., r„). Hence
W m , V \ = m Q ( r i 9 — 9 *n) iff 2 1 , ^ ^=pf o ( r t , . . . , T„). □
Example 11.2.
A. The formula
begin y := x; while y ^ z do y := y • x od end true
defines the relation r in the data structure of real numbers such that
(x, z) e r iff (3ft e N )xn — z.
B. Every recursive relation is strongly programmable in the data
structure of natural numbers. □
in 31. Making use of the normal form theorem for programs (cf. The
orem 6.4) we can assume that the relations are definable by formulas
Koc and Mfi of the form:
begin K 1 ; while yt do K2 od end a,
begin M t ; while y 2 do M 2 od end /?,
Example 11.3.
A. Let K be the following program
K: begin
y : — 0; z := 0;
while z ^ x 2 do
u 0;
while u ^ do
y := y + 1;
u := u + 1
od;
z := z + 1
od
end.
The term Ky defines, in the data structure of natural numbers 51, the
function f ( x l9 x 2) = x x *x2, since for every valuation v in 5i we have
( 1) X n) = x (x t , x„)
a definition o f the predicate £>a.
In algorithmic theories formula (1) usually has the form
ga(xl9 ...9x„) = Kocf
where K is a program, a' is an open formula and a = Kor! .
136 III METAMATHEMATICAL INVESTIGATIONS
V r m 0* 1 , Jn) = T anfa),
BIBLIOGRAPHIC REMARKS
2. DICTIONARIES
A dictionary is a data structure for finite sets with the operations: insert,
delete, member. Dictionaries are important, being one of the most
frequently found data structures. They are used whenever we are
going to:
—ask whether an element of the universe is in a given finite set,
—increase a given finite set by insertion of an element, or
—delete an element from a finite set.
There are numerous examples of applications of dictionaries, e.g. in
library systems, control of contents of stores, etc. Later we shall also
see other examples of structures which are extensions of dictionaries.
Dictionaries form an abstract data type since they can be implemented
in various ways. Here we shall describe the algebraic structure of diction
aries. In the next section we shall develop the algorithmic formalized
theory of the structure.
3. THEORY OF DICTIONARIES
Now, making use of the rule -- - - - -Ue we can precede the last for*
M
mula by the assignments
si := s; bool := false;
and applying the logical axiom
begin K\ M end a = K(Moc)
we obtain the desired result:
begin
si : = s; bool := false;
while ~em (sl) a ~ bool do
el := amb(sl);
144 IV ALGORITHMIC PROPERTIES OF DATA STRUCTURES
P ro po sitio n 3.2.
ATD h- (~em(V) => (3e)(e = amb(y))),
This is an immediate consequence of axiom A5. □
Proposition 3.4.
ATD h- (em(j) => (\fe) ~m b(e, .?)).
The proof is by easy verification. Observe that the precondition
em(s) causes the formula m b(e9s) to be equivalent to
begin si := s; bool := false end bool,
i.e. to false, independently of the choice of e. □
P ro po sitio n 3.6.
ATD {- eq(s, s') = (V<?)(mb(e, s) = mb(e, j ;))-
P roof . We shall prove the implication from left to right. It will
suffice to prove
(1) ATD h- eqO, s') => (Ve)(mb(>, s) = mb(e, s')).
Let us assume the following abbreviations:
y: (boo A~em (sl) A~em(s2)),
a: (booAem(sl)Aem(s2)),
M: begin
el := amb(sl); boo := boo a m b(el, s2);
if boo then
si := del(el, s \ );
s i := del(el, s2)
fi
end,
/: begin si := s; s2 := s'; boo := true end.
With these abbreviations we can rewrite Definition 3.1 as
eq(s, s') = /(while y do M od a).
Observe that
h- ( ~ 7 A a) = a.
We shall prove the following claim: for every i e N
(2) ATD h- (/(if 7 then M fi)*(~7 a a) => (Ve) mb(e, s)
= m b(e,s')).
The implication (1) follows from claim (2) by the co-rule.
The proof of (2) will proceed by induction on /. For / = 0 we have
for every s,
ATD h- (em(s) => (mb(e, s) == false))
3. THEORY OF DICTIONARIES 147
and
ATD h- (/(em(sl)Aem(>2)) = (mb(e, s) = mb(e, s')))
hence
ATD h- (foe => (Ve)(mb(c, s) = mb(e, s'))).
Now assume that (2) holds for all j < i and consider the formula
(3) /(if y then M fi)1+1( ~ y a a ).
then M fi)'a)).
Formula (6) can be transformed to
(8) (~em(y) a ~em (s') a m b(am b(j), s') a
a begin s 1 := del(amb(.y), .y);s2 := (del(amb(s), j ');
boo true end (if y then M fi)la).
Making use of the induction assumption we obtain that (8) implies
the following formula:
(9) (^ e m (s) A ^em (ly ')A m b(am b(4 s') a
a (Ve) (mb(e, del(ambCs), s)) = mb (c, del(amb(s), s '))))-
148 IV ALGORITHMIC PROPERTIES OF DATA STRUCTURES
By axiom A4 we have
(y e amb(j))mb(e, del(amb(j), j ) ) = mb(e, s) and
(y e 7^ am b(j))m b(e, del(amb(.s), s ') ) = mb(e, s')
and therefore (4) implies
(11) (em(j) a ~ e m (/) a (Ve)mb(e, s) = mb(s,s')).
Now consider (5), the second part of the disjunction (3). By the
inductive assumption it follows that (5) implies
(12) ((em(,y)vem(/))A (Ve)mb(e, s) = mb(e, s')).
Finally, from (11) and (12) we have that (3) implies
(\fe)m b(e9s) == m b(e9s').
This ends the inductive proof of claim (2). □
Making use of the facts observed earlier we shall prove that every
model of ATD is isomorphic with another standard, set-theoretical
model. In this way we show that our choice of specific axioms of ATD
was right.
T heorem 4.1. For every model A = ( E v S , in, del, amb, mb, em,
= £> o f ATD, proper for identity, there exists an ST model B o f ATD
with the same set E o f elements. The systems A and B are isomorphic
modulo amb operation, i.e. the reducts A f and B f
A' = (E\ j S, in, del, mb, em, = £>,
B' = <£uFin(iT), inB, del*, mb*, emB, = £>
are isomorphic.
P roof. We shall first construct the system B' and prove its properties.
Next, we shall discuss the possibility of extension of B by a proper
operation amb to a model of ATD.
With every j e S we associate the set h(s)
h(s) = {e e E: m b(e9.9)}.
The set h(s) is finite by the axioms A1 and A4, since the sequence {£*}
defined below contains all elements of h(s) without repetition.
The sequence is defined by the following algorithm:
Initialization: Put / = 0 and seq = empty sequence.
WHILE the set s is not empty REPEAT the following
instructions
PUT ei+1 = amb(V),
ADJOIN the element ei+l to the sequence seq,
REPLACE s by del (amb(s), s).
The mapping
h: S -> Fin(is)
is onto, since for a given set {el9 ..., en} we can consider the element
defined by the following term:
begin while ~em(s) do s := del(amb(tf), od;
S := in(e1(5); ... ; 5 := info.s')
end s.
The mapping h is a one-to-one mapping. For th eproof use Proposition
3.6. Suppose ~ e q (s9s') then (3^)mb(e 9s) a ~m b(e, s') or, symmetric
ally, (3 e)(~ mb(e, j)A m b(e, / ) ) .
It is easy to verify that
h(in(e95)) = h(s)u {e} by axiom A3 and Proposition 3.6,
h del(e, s) = h(s)~ {e} by axiom A4 and Proposition 3.6,
5. COMPLEXITY OF ATD 151
Note that in frequently occurring cases there is no need for the appli
cation of AC, e.g. in the situation where the set E is linearly ordered,
or if there exists an enumeration of the elements of E.
The assumption that a model of ATD is proper for identity is im
portant. Without it one can construct a counter example such that
the set h{s) is infinite.
On the other hand, it is not difficult to prove that for every model 9ft
of ATD one can construct an equivalent model 9ft' = 9ft/(= , eq) proper
for identity.
5. ON COMPLEXITY OF ATD
The structure
= <A, 0, s, =>
of natural numbers with C—a ze 0-argument operation, s—a one-
-argument operation and identity is axiomatized by the following
axioms AxAr:
(Vx) ~ s(x) = 0,
(V x, y) (s(x) = s ( » => x = y ),
(Vy)(x := 0)(while = y do x := od (x = >'))•
Theorem 7.1. Every model 9JZ o f AxAr is isomorphic with the stan
dard model o f Peano axioms, i.e. the algorithmic theory o f natural num
bers is categorical {cf Chapter II, Theorem 4.2). □
(Vx)a(x) = (x := 0 ) P ( x := ^(x))a(x),
(3x)a(x) = (x := 0 )(J (x := j(x))a(x),
assuming that x is free in a and never occurs on the left-hand side of
an assignment in a .
In the case where a is an open formula we can prove that
(3x)a(x) = (x :== 0) (while a( x) do x : = s ( x) od true).
All three equivalences can be proved formally from AxAr axioms.
Indeed, all the equivalences are valid in the standard model of AxAr
axioms. By categoricity they are valid in every model of AxAr hence
they are provable from AxAr (by completeness of AL).
Now, let us recall that every formula of the following scheme
(OfAnK(P=>w)=>nw)
is a theorem of algorithmic logic (cf. Chapter II, § 7).
By the rule
a , K true
Koc
we have
(x := 0)((a(x)A Q ( x := s(x))(a(x) => (x := j(x ))a (x )))
=> P l( x := s(x))x(x)).
Distributing the assignment x := 0 over implication and conjunction
we obtain
((x := 0)a(x)A (x := 0) P | (x := •s,(x))(a(x)
=> (x := 1y (x))a(x)) => (x := 0 ) P ( x := j(x))a(x))
which is equivalent to the scheme of induction
(a(x/0)A (Vx)(a(x) => a(x/.S'(x))) => (Vx)a(x)).
Hence we have proved the following proposition:
8. STACKS
Fig. 8.1
Fig. 8.2
L emma 9.1. The program in axiom A6 always halts, i.e. the rela
tion = s is strongly programmable in terms o f the remaining relations
and notions. □
L emma 9.2. For every s, s', s" e S and for every e, e' e E
(a) s = s s,
(b) (s = s s' => s' = a s),
(c) (s = s s ' a s ' = s s" => s = s s"),
(d) (e —E e' a s —As') = push(^, s) ~ s push(^', s')
(c) ( s = s s' a ~empty(s)) = (pop(s) = s pop(s') a top(s) = E top(s')),
(0 (s = s s ' => (empty (s) = empty (s'))).
(g) (empty(V) a empty(V) => s = s s').
P roof .
(a) The reflexivity of = s follows immediately from A6.
(d) The formula
push(e, s) = s push(e', s')
is equivalent to
begin sx := push(<?, s); s2 : = push(e', s'); bool : = true,
while bool a ~ empty ( s x) a ~ empty ( s 2) do
9. THEORY OF STACKS 163
when after the execution of the program ~bool holds. In both cases
seq(s) / seq(s'), i.e. the mapping seq is one-to-one.
It is easy to verify that
seq (p o p (s)) — delete-first (seq(s)),
top(s) = first (seq(5 )),
se q (p u sh (e, s )) = p reced e(e, seq(s)),
em pty (s) = seq(s) = 0 .
Dictionaries
In this case we implement the following “vocabulary” of notions:
amember(s) == top(s),
insert(e, s) = if ~ member(e, s) then s : = push(e, s) fi s,
12. THEORY OF LINKS AND STACKS—ATSL 167
Notation
1. We shall use a postfix notation for tops, elem, and prev functors,
i.e. instead of prev(/) we shall write /.prev.
2. Without loss of generality we can assume that functors topsa,
elema and prevap will appear in the following context only:
s := topsa^s, r L), where L is the type of r L,
/ := elema(/, rE), where E is the type of rE,
l : = prevap(/, r L).
This allows us to use the following shortened forms below:
s.tops := r L,
/.elem rE,
/.prev := rL.
Axioms
Asl isnone(none),
As2 isnone(newL(e).prev),
As3 e = £ newL(e).elem,
As4 while ~isnone(/) do / := /.prev od true,
As5 (sTops := l)(sXops —L /),
As6 ap(/, /') = (3/")/" = L prevap(/, /'),
As7 (ap(/, /') a e —E /.elem)
=> (/.prev := l')(e = E /.elem a /.prev = L l' a ~isnone(/)),
170 IV ALGORITHMIC PROPERTIES OF DATA STRUCTURES
elem prev
e
Fig. 12.1
and a similar, even simpler structure will have objects from S, as shown
in Figure 12.2.
•v: tops
Fig. 12.2
Fig. 12.3
new S : | tops
172 IV ALGORITHMIC PROPERTIES OF DATA STRUCTURES
Consider the system described by the tree SL and observe the following.
The results of the previous section justify the introduction of the fol
lowing program constituent. Its orthography is taken from the LOGLAN
programming language designed at the University of Warsaw.
174 IV ALGORITHMIC PROPERTIES OF DATA STRUCTURES
elem prev
e /
Fig. 13.1
tops
/
Fig. 13.2
end.
14. QUEUES
We are now going to interpret dictionaries within queues, so we must
introduce the algorithmic theory of queues ATQ. ATQ is a two-sorted
theory. Let E and Q denote its two sorts.
Variables of sort E will be denoted by e , e', etc.; variables of sort Q
will be denoted by q, q', q \, etc. The specific signs of the theory are
listed below;
em: Q -> B0,
put: E x Q - * Q ,
out: Q -> Q,
fr: Q - E,
—e : E x E —> B0,
=<*: 2 x 2 -> B0.
14. QUEUES 177
Axioms of queues.
Aql while ~em (q) do q := out(q) od true,
Aq2 (em(tf) => (q = Q out (put (e, q )))),
Aq3 ( ~ e m (q) => put (e, out(q)) = Q out (put(<?, c/))),
Aq4 (em(#) => (e = E fr(put(e, # )))),
Aq5 (~em (g) => fr(put(e, q)) = £ fr(g)),
Aq6 ~em(put(<?, q)),
Aq7 q = Qq' = begin q\ := q\ q2 := q'\ bool := true;
while ~ em(gl) a ~ em(#2) a bool do
if fr(gl) ^ fr{ql) then bool := false fi;
ql := out(gl); q2 := out(#2);
od
end (boolAem(^l) Aem(^r2)).
D efinition 14.1.
mb(e, q) = begin ql := q; bool := false;
while ~em (#l) a ~bool do
el := fr(ql);
if e = E el then bool := true fi;
ql := out(gl)
od
end bool. □
178 IV ALGORITHMIC PROPERTIES OF DATA STRUCTURES
D efinition 14.2.
in(>, q) = Qbegin q\ : = q;
if ~ m b (e ,q l) then ql := put(V, #l)fi
end ql. □
D efinition 14.3.
del(>, q) = Qbegin ql := q\
if mb(e, ql) then
while ^em(^2) do q l := o\xt(ql) od;
while r s j em(gl) do
el := fr(^l);
if e ^ el then q l := put(el, ql) fi;
ql out(gl)
od;
ql := q l
fi
end ql. □
D efinition 14.4.
stmb(q) = fr(^) □
Let A be a set whose elements will be called atoms. We shall give a spec
ification of the structure of binary trees with atoms associated to leaves.
The structure has two sorts:
A—the sort of atoms,
T—the sort of trees.
The sorts A and T are not disjoint; we assume A a T.
The operations of the structure are as follows:
c: T xT ~ > T,
e: T -* B0,
a: T B0,
!: T -* T,
r: T-+ T,
/, r are partial operations, not defined if the argument is an atom.
The axioms of binary trees are:
TR1 { \!te T ){ a ( t) v e { t) \/t = c (/(*), r(/)));
TR2 ( y t1}t2 e T )l(c(tl , t2)) = t t ;
TR3 (V ti, t2 e T )r(c (tl , t2)) =t 2 ;
TR4 (Vf1; t2 e T) ~ e {c (tl y t2) ) a ~ a ( c ( /1; t2));
TR5 ( y t e T ) while ~ e {t)A ~ a (t) do
if e(l(t)) v a(1(f)') then t: = r(t)
else r: = c (/(/(0 ), c(r(l(t)),r{t)))
fi
od true;
TR6 (V7,/, 6 r)((e (/j)A e fe ))= > = t2).
A standard model for these axioms is the set of ^-expressions, ^-ex
pressions constitute the semantic basis for “pure” LTSP programming
language.
D efinition 15.1. The set o f S-expressions over the set A is the least
set o f expressions such that:
1° it contains the set ^u {n il};
2° for every two S-expressions r l and t 2 the expression (r t *r 2)
is also in the set o f S-expressions. □
T heorem 15.1. Every model o f the axioms listed above proper for
identity is isomorphic with a model in the set o f S-expressions.
180 IV ALGORITHMIC PROPERTIES OF DATA STRUCTURES
The program in TR5 will not terminate on this input. Our axioms
do accept directed acyclic graphs (dags). One can say that dags appear
when we identify the subtrees of a given tree which have the same
structure. In this way we have touched on the problem of identification
of objects in a data structure. Our axiomatic theory deals with an ab
straction of the notion of binary tree. For a more realistic treatment,
the notion of reference should be included. This allows us to explain
why two objects of the same structure are treated as though they are
different although they are in fact basically the same. □
The axiom given above rejects dags and other graphs. One does not
meet this specification on its own very frequently in computer science
literature. In practical applications it should be combined with the
previous definition of binary trees.
16. BINARY SEARCH TREES 181
r n2
Fig. 16.1
{for every element n, n is the root of the finite binary tree (cf. Defi
nition 15.1)).
B7 ((n.r = n” a n.v — e a
(begin
n2 := r i ;
while ~ isnone(«2.r) do n l := nl.r od;
if nl.v < n.v then bool := true else
bool := false fi
end bool) v isnone(rc'))
=> (n.l := n')(n.r — n" a n.v = e a n.l — «'))
{if the greatest element in the tree n' is less than n.v or isnone (nr)
then the assignment associating n' as the left son of n is well defined
and the remaining attributes of n are untouched}.
B8 {(n.l — nn a n.v — e a
begin
n l := n while ~isnone(n.2/) do n l := n l.l od;
if nl.v > n.v then bool := true else bool := false fi
end bool v isnone(w'))
=>(n.r :== n’){n.l = n,r a n.v = eA n.r = n'))
{if the least element in the tree n is greater than n.v or isnone fra') then
the assignment associating n as the left son of n is well defined and the
remaining attributes of n are untouched }
B9 The set E is linearly ordered by the relation ^ .
The set of axioms B1-B9 is consistent due to the following theorem:
D e f in it io n 17.1.
min(w) = if isnone(fl) then ALARM else n\ := n fi
(while ~isnone(«l./)do?zl := n \J od nl.v). □
17. PRIORITY QUEUES INTERPRETATION 185
else n 1 := n\.r fi
fi
od
end result. □
L emma 17.4. Let M denote the program in Definition 17.3. For every
e e E, for every n e N :
186 IV ALGORITHMIC PROPERTIES OF DATA STRUCTURES
L emma 17.5. Let K denote the program sketched above. For every
e e E and for every n e N:
(i) K ~ member(e, «3),
(ii) for every er ^ e, m em ber^', n) = K m e m b e r n3). □
This means that given a model of the theory of binary search trees
we can define a model of the theory of priority queues. Moreover,
since all definitions are algorithmic we can construct such a model
18. IMPLEMENTATION OF PRIORITY QUEUES 187
n2 :— n 1;
if e = nl.v then bool : = true else
if e < nl.v then nl := n l.l else
nl : = n 1 .r fi
fi
od;
if ^ b o o l then
if none = n3 then n3 : = newN(e) else
if e < nl.v then n2A newN(e) else
n2,r := newA^(^) f i
fi
f i;
result := n3
end insert;
unit delete: function (e:E, «:node): node;
variable n\, n2, n3, n4, n5: node, bool, leftson:
Boolean;
begin
n\ := n; ri3 := n\ bool := false;
while ~none = n\ a ^ bool do
n2 : — n\ ;
if e = nl.v then bool := true else
if e < nl.v then nl n l.l else nl := nl.r f i
fi
19. ARRAYS
20. HASHTABLES
N , £ , Q, Ar, HT.
Theorem 21.1. For every ordered field 2r, If 5 a model for the for
mula
(Euc) (Vx, y)((x > Oa t > 0) => E true)
then F is isomorphic to Q.
P roof. Every ordered field contains a subalgebra isomorphic with
the field of rational numbers Q. Hence it is sufficient to prove that
every element e of the Euclidean ordered field $ is of the form kjm
where k and m are integers. Consider two arbitrary positive elements
x0, v0 of g. By the (Euc) axiom we know that the computation of Euclid’s
algorithm is finite. The sequence of consecutive values of the vari
ables x, y is finite. Let us denote it by
(x0, y 0), (xn, y n).
All values x i9y t are positive and xn = yn. There exist positive integers
kn and m such that x0 = k • x n and y 0 = m • xn. Hence x • y~ l
= {k • 1) -(m • l)-1, i.e. every element of the field g can be represented
as a rational number.
computes the value of the z-th polynomial in the sequence {/l (x , y t , ...
...,}>„)} and assigns it to the variable z. Consider the following algo
rithmic formula <pn( x ,y l9 ..., j n):
begin
z := 1; / := 0;
while z ^ 0 do i := i + 1 ; K{i9z) od
end true.
It defines the property: “x is algebraic with respect to y l 9 ...,y n”.
To the set A' we add formulas
(VVi, ..., yn) (3x) ~ <p„(x, , ..., y„) for every natural n
The resulting set will be denoted by A . It is easily seen that the class X
is characterized by the set A of axioms and that A is a recursive set.
196 IV ALGORITHMIC PROPERTIES OF DATA STRUCTURES
T heorem 22.1. (Vaught, 1973). Let 5 i , 2r2 be two fields o f the class j f .
The algorithmic theories o f $ i and $2 are equal, i.e. fields 5 i and $ 2
are algorithmically equivalent.
P roof. Suppose the contrary; then there is a sentence a such that
0Ti 1= a and $2 |=: - a .
Consequently A u {a} and ,4 u {~a} are consistent sets. By the Down
ward Skolem-Lowenheim Theorem (Theorem 3.3, Chapter III) there
exist enumerable fields 5 i and which are models for Au{oc} and
Av a} respectively. 5? and $ e2 are fields of characteristic zero, alge
braically closed and with an infinite degree of transcendency. By Steinitz’s
Theorem (Vaught, 1973) they are isomorphic. This is a contradiction. □
From Theorem 22.1 above we see that the set of theorems of the algo
rithmic theory of the field of complex numbers, i.e., theory Th(£) forms
an analytical set. In fact, by the Completeness Theorem Aj=a iff A b- a.
Hence, A (— a iff for every enumerable set D such that A u A x cr D
(here A x denotes the set of logical axioms of AL) and D is closed under
the inference rules, the formula a is in D.
The theory Th((£) of complex numbers is not arithmetical since
for every arithmetical property p it is possible to construct an appro
priate formula in the language of the field C which defines p. Natural
numbers are definable in (£, hence we can relativize each occurrence
of an individual bounded variable to natural numbers. This transform
ation in effective, hence we have proved that the set of first order sentences
valid in the standard model of arithmetics is recursively reducible
to Th(£).
To estimate the location of Th(£) in the analytical hierarchy we first
observe that it is either hyperarithmetical or TI\ .
there exists a polynomial f e Q[x9x l9 ..., x„] such th at/(x , ax, a2, ..., an)
= 0. By a diagonalization argument we shall prove that there exist
recursive numbers x such that for every polynomial/ , /(x , al9 ..., an) + 0.
We begin with an effective enumeration of all polynomials from
Q[x, Xj, ..., x n], A polynom ial/(x, al9 ..., an) can be treated as a poly
nomial of single variable x with coefficients determined by al9 ...,a n.
These coefficients are effectively enumerable. Each coefficient is a recursive
number and a limit of a recursive sequence which is recursively con
vergent. By Rice’s theorem at least one complex number which is the
root of a polynomial with recursive coefficients is the recursive limit
of an effectively given recursive sequence. In order to obtain other roots
of the polynomial in a uniform way we uniformly and effectively gener
ate the coefficients of the quotient polynomial. Now we can effectively
enumerate all these numbers which are roots of polynomials from the
sequence defined above. Let us denote this sequence of recursive complex
numbers by cl9 c2, ... There is a uniform algorithm of the generation
of the subsequent approximation of the z-th number so defined. The
construction of the necessary recursive real number x is easy. Ensure
that the z-th decimal digit of the real part of ct differs from the z-th
decimal digit of x. We compute ct with accuracy 10_I+1. If the two
last digits of the real part of this approximation are not 00 or 99, then
we define the z-th decimal digit of x simply to be different from the
z-th digit of ct . If these two digits are 9 or 0 then we put the z-th decimal
digit of x equal to 5. □
The proof makes use of two facts and the following definition:
A field 5 satisfies the finite covering condition iff for every algebraic
variety A and every enumerable set {B( }ieo) of algebraic varieties over
5 , if A a ( J Bh there exists a finite subset / c: co such that A a \
ieco i el
(By-an algebraic variety we mean the set of zeros of a finite set of poly
nomials).
to an open formula oc(z) of one variable. But this means that the
set defined by a is finite or cofinite. The straight line of reals is neither
finite nor cofinite in the field (L Hence the relation r(z) is not pro
grammable in (L
In this section we shall study a few theories of real numbers. The lan
guages used may be classified as follows:
E—we admit only Boolean combinations of formulas Koc,, no classical
quantifiers;
££A—iteration quantifiers admitted, no classical quantifiers;
—no restrictions.
Let 91 = (R, + , —, •, / , 0, 1, = ) be the field of real numbers. By
9ID we shall denote the ordered field of reals. Observe that in STF there
exists a formula defining the ordering relation
x < y = (3z)(x + z 2 = y).
For S£e and A the cases of 9? and 910 should be discussed separately.
In a manner similar to that of the preceding section we can prove
the following:
D efinition 23.1. A field $ is called formally real iff for every natural
number n
x \ + ... +x„ 7 ^ - 1 . □
iff
23. REAL NUMBERS 201
The above theorems do not hold in the ordered field of reals 910.
Making use of the fact that every Archimedean ordered field is embed
dable in 910, together with the observation that the Archimedean axiom
is a universally quantified formula, we obtain the next theorem.
1
x = a0 + ------------ --------
begin
z := x; i := 0;
while i ^ j do
a := entier(z);
if z / a then z := \/(z —a) else z : — 0 fi;
/ : = i+ l
od
end.
Now, observe that every recursive relation is programmable in 910.
Let us assume that a program T ( z ,y ,x ) and an open formula a are
so defined that Toe computes the Kleene predicate T*t l ( z ,y ,x ) (cf.
Rogers, 1967). The formula;
(Vx) begin w := 0; p := true; while p do w := w+1;
K (x ,w ,a ); T(n, a, n); p := oc od end true,
where p is a propositional variable and n denotes the constant (1 + ... + 1),
w-times, defines then in 9^0 a ill-complete set is1 (Rogers, 1967). □
The map of data structures shown in Figure 24.1 summarizes the dis
cussion of this chapter. Implementability relations are represented
by arrows.
Obviously, many interesting and important structures have been left
out of the map. Moreover, the map can be enriched by the information
about the costs of implementation treated as quasi distances associated
with arrows.
Observe that the formulas
(if a then K fi)1a ((if a then K fi)* ~ a)
24. CONCLUDING REMARKS 203
Dictionaries
BIBLIOGRAPHIC REMARKS
However, we shall see that (*) is not always valid, it holds in certain
cases and not in others. This is the source of our greatest difficulties.
The following question remains unanswered: what are the nesessary
any sufficient conditions for equivalence (*)?
We introduce an assumption of a finite degree of non-determinism
of the interpretation of program variables. Under this assumption,
(*) holds and we can prove the soundness of the infinitary rule of in
ference. However, this property of a finite degree of non-determinism
is not expressible in PAL, although for every n we can express that the
degree of non-determinism is at most n.
208 V PROPOSITIONAL ALGORITHMIC LOGIC
J : V p -+2SxS and J ( U ) = { ( s ,s ) : s e S )
and w is a function which assigns to every state a valuation o f proposi
tional variables
w:S-+ o.
For a given structure 9Jt = < S ,*/, w} and a given state s e S the
Boolean value of the formula oc is denoted by a^O ) and is defined for
classical connectives as follows:
falser (V) = 0, tineas) = 1.
Pm(s) = w(.y)(/?), p e V 09
(<xv = ocwi(s)vfiwi(s\
(oc => P)m(s) = aan(^)-> AmC?),
(a a B)m(s) = ocm(s)nfim(s\ = -asmCO-
Now we are ready to define the value of the formulas QMoc and
§Mcc in a given structure 501 at a given initial state s.
(§Mcx)m(s) = 1 iff there exists a successful computation of the
program M at the initial state ^ in 501 such that its resulting state sat
isfies oc.
212 V PROPOSITIONAL ALGORITHMIC LOGIC
(if y then M fi)M whose result satisfies the formula ~ y 9 then, we can
similarly construct a computation of the program while y do M od.
The following facts are immediate consequences of the above ob
servations.
Fact 1. If there exists a successful computation of the program
while y do M od, then there exists an i such that the program (if y then
M f i) f has a successful computation with the same result.
Fact 2. If there exists a successful computation of the program
(if y then M f i) 1 for a certain i such that its result satisfies the formula - y,
then there is a successful computation of the program while y do M od
with the same result.
Fact 3. If the program (if y then M f i) 1 has an unsuccessful com
putation (or infinite computation), then for every j > i the programs
(if y then M fi) J and while y do M od have an unsuccessful (or infinite)
computation.
For a given program scheme and a given semantic structure 9JI the set
of all results of the program can be characterized as follows:
In connection with the last equality in the above lemma let us con
sider the following example.
such that
5 = {(/,/): U = 0, 1,2,
J ( K ’) = {((0,0), ( i,0 ) : i = 1 , 2 , 3 ,
J ( K ) = {((i.y+l), (i , j )): i , j = 0, 1,2,
= 0 iff y=l,
w(i',./)(?) = 1 iff 7 = 0.
The tree of all possible computations of the program M x in the
semantic structure 9JI at the initial state (0, 0) is described below
(Figure 2.1).
< (0,0); M y >
]
< (0,0); M,M\ >
J
<(0,0); K ', M O
<(3, 3); K, M O
1
<(3, 2); M O
1
<(3,2); M , M O
1
<(3,2); A', M O
1
<(3, i);m o
I
<(3,i); >
Fig. 2.1
2. SEMANTIC PROPERTIES OF PROGRAM SHEMES 215
L emma 2.2. For any state s in the structure SCR and for arbitrary y e F0,
oceF,, M e / / the following equality holds:
(Awhile y do M od oc)%i(s)
= l.u.b <>(if y then M fi)* (~ y A a)aji(.y).
ieN
(if y then M fi)j, j > /, such that its result satisfies ~ y , or (b) there
is no such extension.
Tn case (a), by (5), the result of the extended computation does sat
isfy ~ a. In case (b), we can construct an infinite computation of the
program scheme while y do M od. Thus
(Awhile y do M od a)gji(s) = 0,
which contradicts (1).
Conversely, suppose that
l.u.b 0(if y then M fi^ ^ y A a)an(.y) = 1.
ie N
Hence, for a certain i0, 9K, s |=: <>(if y then M fi)io(~ y A a). Consider
a successful computation of the program (if y then M fi)*0 with a result
satisfying ( ~ / a a). After a simple transformation we shall obtain
a successful computation of while y do M od such that its result satis
fies a. Thus 9JI, s |= 0 while y do M od a. □
D efinition 2.1. We shall say that a structure 9JI = <S, J , w> has the
property o f finite degree o f non-determinism (FDN property) iff for
every program variable K and every state s e S, the set K$ji(f) is finite. □
The structure with FDN property we shall call simply FDN structure.
2. SEMANTIC PROPERTIES OF PROGRAM SCHEMES 217
Lemma 2.3. For every structure 9JI = <5, w) with the FDN prop
erty, and for every state s e S and y e F0, a e F, M e I I the following
equality holds:
□ (while y do M od a)sjjt(.s)
= l.u.b. D (if y then M fi)4 ( ~ y a oc)m(s)-
ieN
It appears that for structures with the FDN property the above results
can be made even stronger. To simplify future considerations let us
first prove an auxiliary lemma.
By assumption (i)
aan(.s') = 0 for all s'
and therefore
($Kot)wi(s) = 0, contradiction!
Conversely, suppose that
(12) l.u.b.(QKoii)m(s) = 1.
ieN
By assumption (i), SCR, s' |= a for some s' e K^i(s), and hence (^ATa)an(.v)
= 1, and the proof of (iii) is finished.
To prove (iv), assume that SCR|= (otj => af) and suppose that for
some state s
m 9s\=:{JKoCj.
Then
Km(s) # 0 and for all s' e K%i(s), SR, s' [= ocj.
220 V PROPOSITIONAL ALGORITHMIC LOGIC
Lemma 2.5. Let 9JI be a structure with the FDN property. In that case
pref (O while y do M od a)® ^)
= l.u.b. pref O (if y then M i\)'(~ y a a)gn(.s),
ieN
In the sequel we shall study different semantic structures. The aim of this
section is to present several definitions and some of their properties.
W *(\S\) = w(s).
Notice that w* is a well-defined function
w*:S* -»
since if 5', 5" e |s|, then w (/) = w(s").
In several proofs we shall make use of the following definition of
ordering in the set of all formulas F:
D efinition 3.3. We shall say that the formula oc' is submitted to the
formula ft', oc' -< /?', iff the pair {oc', /S') belongs to the transitive closure
o f the relation -<, which is a set o f the following pairs:
(a, OKoc) fo r K e V p,
(a, aV/S), (a, aA|S), {oc, ~ a),
(O M 1(OM2a), O begin ; M2 end a),
(O M ^, O either or M2 ro a),
( O M 2oc, O either Mi or M 2 ro oc),
(0 ( if 7 then M fi)1( ~ y a oc), O while 7 do M od oc)
fo r i e N ,
((7 a OMxOc), O if 7 then else M 2 fi oc),
( ( ^ 7 a O M 2cc), O if 7 then M 1 else M 2 fi a),
wAere M v, M 2 are any program schemes, 7 is a classical formula, oc, fi are
formulas and O denotes □ or □
Lemma 3.2. For every formula oc e F and for every state s in the struc
ture 9JI,
asm*(1$I) = a®i(5).
Proof. (By induction w.r.t. the ordering relation -< defined above).
It is obvious that for every propositional variable p e V0 and for
every state s e S,
Pm*Qs\) = pm(s).
3. PROPERTIES OF SEMANTIC STRUCTURES 223
Assume that Lemma 3.2 holds for all formulas which are sub
mitted to a formula a.
A. Consider the formula a = QKoc, K e V p.
Let s e S and SCR, ^ §Koc. Then (3^ e ASmC5)) SCR, f= oc. By the
definition of the structure SR* we have
AwOi) ^
Hence, SR, s ^AT/S and non SR, s |= DAT/?, a contradiction.
The proof of the second property can be found in Lemma 10.1.
The proof of the third property is left to the reader. □
3. PROPERTIES OF SEMANTIC STRUCTURES 225
L emma 3.5. Let 93X be a normalized FDN semantic structure. The fol
lowing equivalences then hold:
(i) 931 [={(/? => $Kft)}(jeF iff Km is a reflexive relation,
(ii) 93? \={($K(~QK(}) => ^^)}/5e f iff Km is a symmetric relation,
(iii) 931 ^=.{($K($K/3) => 0 K@)}peF iff Km is a transitive relation,
(iv) 9[ K M ( 0 ^ ( ~ 0 ^ ) = > ~ £ ) a ( 0 ~ p )} PeF iff rela
tions Mm and Km are mutually inverse.
P ro o f . All four properties have similar proofs. We shall illustrate
the method of proving showing the second equivalence, as follows.
Ad (ii). Let 931 be a normalized FDN semantic structure and
(1) 931 j= (0 A( ~ §Koc) => ~ a ) for every formula a.
Suppose s, s' are two fixed states such that
( 2) (s ,s ' ) e K m
and let {sl9 ...,s n} be the set of all states such that ( s ',^ ) for
/ ^ n. Suppose st ^ s for all i < n. Since 331 is a normalized structure,
for every / < n there exists a formula oct such that
931,^1=^ and 931, ^ —af.
Let a = (oct A a2A ... a a„). Thus
(3) 931, a and 931, sf (=: ~$Koc.
By (2) 33t, s $K(~$Koc) and as a consequence of (1) 931, s (= ~cc,
contrary to (3). Thus (2) implies (s', s) e Km.
Conversely, assume that for all s, s'
(4) if (s, s') e Km, then (s', s) e Km.
Suppose that
(5) 931, s\= ocand 331, a (= $K(~$Koc).
Thus there exists a state s', (s, s') e Km such that non 931, s' $Koc.
By assumption (4) (s',,?) e Km and furthermore non 9)1, s\=zoc, which
contradicts (5). □
T heorem 3.6. There exists no formula a such that for every semantic
structure sr
SR |= a iff SR has the FDN property.
P roof. Suppose, on the contrary, that there exists a formula a0
such that for every SR
(6) SR \=z oc0 iff SR has FDN property.
Let us consider the family of structures (SR/}/e;V such that SR/
= <S i, J>i, wf->, where S tn S j = 0 for i ^ j and S t = {si9 sil9 ..., su }9
J'iiK) = {(si9 Sij): j ^ i}9 *fi(K') = 0 for all program variables K'
different from K9 SRf, W/fo) q iff q = p-x and SR/, w/foj) [n q iff
q - qj.
The family {SR/}/eiV can be described more intuitively by the graphs
shown in Figure 3.1.
SR,: 2R 2 : 3W ,:
Fig. 3.1
As an immediate consequence we have the following:
(7) SR/ has the FDN property for every i e N.
Let 3* be the maximal extension of the Frechet filter in the set of
natural numbers N (cf. Malcev, 1970).
=> {X a N : N —X is a finite set}.
Let us denote by SR* = <5*, */*, w*> the product of all structures
{SR/}/eiV modulo filter 3F (cf. Malcev, 1970)
SR* =
ieN
For every w e ) ( SR/ let W/ denote the f-th clement of u and let \u\ = \ur:
ieN
{/: Ui — ul} e#*}.
Hence 5* = (|w|: w e ) ( SR/} and
i eN
(M , \u'\) iff {/: (ui9u\) e J t(K)} s ^ 9
SR*, w*(|w|) \=. q iff {/: SR/, W/(w/) jn q } e ^ .
3. PROPERTIES OF SEMANTIC STRUCTURES 227
T heorem 3.7. The FDN property is not expressible in PAL, i.e., the
following property does not hold: there exists a set o f formulas Z such
that for every semantic structure 931,
93\\=.Z iff 931 has the FDN property. □
R e m a r k . Theorem 3.6 can be strenghtened. Namely, FDN property
is not expressible in PAL in the class of all normalized structures.
L emma 4.1. There exists a set o f formulas Z and a formula oc such that
Z\noc and such that for every finite subset Z 0 o f Z there exists a model
o f Z 0 which is not a model o f oc.
P roof. Consider the following example. Assume that
Z = {□ begin K t ; K[ end q0 }ieN,
where Kt , K2 are program variables and q0—a propositional variable,
and oc = ~ (<> begin K x ; while q0 do K 2 od end true). It is easy to show
that a is a semantic consequence of the set Z.
If < S ,«/, w> is a model of Z, then for every state s e S and for each
natural number /, every computation of the program begin K x; K\ end
is successful and all results satisfy the formula q0. Hence, there exists
no finite computation of the program
begin K t ; while q0 do K 2 od end.
This implies that < £ ,./, w} is a model for oc.
Now, assume that V0 = {qi}ieN. For every finite subset X of TV, let us
construct an interpretation </ in the following way: For every valu
5. SYNTACTIC CONSEQUENCE OPERATION 229
O while y do M y od a
— ( ( ~ y a a) v ( y a O M f O while y do M x od a))),
0 either M t or M 2 ro a = ( O ^ i a v <>M2 a),
□ either M 1 or M 2 ro a = (D M 1<
x a C\M2 oc),
□ Af( aA/S) = ( □ M a A Q M /S ) ,
<>M(av/S) == (<>A/a
( □ M ~ a => —QMoc),
( □ A f true =>(~§Moc => □ M ~ a )),
~ O M false.
O ld a = a.
We assume the following rules of inference:
a, (a => /?) (a => /?)
"■j5 5 lO M ^ ~ O M P )9
{ (pref(Q (if y then M fi)*(aA ~ y)) => p )}£ejv_
(pref (O while y do M od a) => /S)
In all the above schemes K denotes a program variable, A f, M r , Af2
denote schemes of programs, y is a classical propositional formula
and a, are arbitrary formulas from F. All occurrences of O in a
formula must be understood either as 0 throughout or as □ through
out; pref is an arbitrary prefix (see § 2 of this chapter).
The set of all axioms and inference rules defines the syntactic con
sequence operation C in the usual way. For any set Z of formulas,
C(Z) is the least set which contains Z and all axioms of PAL and is
closed under the rules of inference. System <L0, C> will be called the
propositional algorithmic logic PAL.
A formula a is called a theorem of PAL iff a is an element of C (0), 1- a
for short.
By a formal proof o f a formula a from the set o f formulas Z we shall
understand a finite path tree labelled by formulas such that its root
is a formula a, all leaves are axioms and every vertex is obtained from
the set of predecessors by one of the inference rules (cf. Chapter II, § 5).
We shall write Z |— a, a e C(Z) iff a has a formal proof from the set Z.
L emma 5.2. The set o f all formulas valid in all FDN semantic struc
tures is closed under all rules o f inference mentioned above.
P ro o f . Let SR be an FDN semantic structure. We shall prove that
for any inference rule, if all premises are valid in SR then the con
clusion is valid in SR.
Consider the rule -7-—^ — --”^ - ^ • Assume that SR hr (a B)
(□A fa => U M f ) ^
and SR, s DA/a for some state s. Thus all computations of the pro
gram M in the structure SR at the initial state s are successful and all
results s' satisfy the formula a, i.e. SR, s' f=:a. By assumption
SR, s' (=:/? and therefore SR,^j=DA//3. As a consequence we have
SIR, s fn (QAfa => □ Mfi). Hence (QAfa => DA//3) is valid in SR.
{(pref D(if y then M fiy(~yA «) =>
Consider the rule
(pref □ while y do M od a => /S)
Assume that for all i e N the formula
(pref □ (if y then M fi)*(~yA a) => /?)
is valid in an FDN structure SR.
Suppose that for a fixed state s in a structure SR
(pref □ while y do M od a)^(^) = 1 and pw(s) = 0.
This means that for all i e N ,
(pref □ (if y then M K f { ~ y * oc))m(s) = 0.
232 V PROPOSITIONAL ALGORITHMIC LOGIC
T hus
l.u.b. pref D (if y then M fi)* ( ~ y A oc)wi(s) = 0.
ieN
Thus the states sx, s2 satisfy exactly the same formulas and therefore
s x = s2, a contradiction with (2).
Hence in every normalized model 9JZ of Axar there is exactly one
state which satisfies z.
Since Nm and are functions, the only possible situation is de
scribed by Figure 6.1.
^ buttons
lamp- z N P
Fig. 6.2
® o o ® o o ® o o
2, Pi z2 N 2 P2 *3 N 3 p 3
Fig. 6.3
Ill
•••
211
•••
112
•••
212
Fig. 6.4
7. LINDENBAUM ALGEBRA
T heorem 7.2. For the arbitrary formulas oce F, y e F0 and for any
program scheme M, the following equalities hold:
11pref □ while y do M od a| |
= l.u.b.|| pref (D (if y then M fi)l(~ yA a))|j,
ieN
11pref 0 while y do M od a||
= l.u.b. || pref (0(if y then M fi)*(~y a a))||,
ieN
Let us note that the set of all theorems in PAL/ is closed under the
generalization rule
a
for KeV„
□ *a
C orollary 8.1. There are formulas which are functionally valid and
which are not valid in every structure. □
T heorem 8.7. For any consistent theory Tf based on PAL/, the fol
lowing conditions are equivalent:
(i) a is a theorem o f T;
(ii) a is valid in every proper functional model o f T f
9. PARTIAL FUNCTIONAL INTERPRETATIONS 243
9. P A R T IA L F U N C T IO N A L IN T E R P R E T A T IO N S
First of all, let us note that in every structure 9Jlpf the formula
($Koc => QA^a)
is valid for every K e V p and oceF (cf. Lemma 3.4).
As an immediate consequence of Lemma 5.2 and the above obser
vation we obtain the following lemma.
Lemma 9.1. For every theory T based on PALpf and every formula a,
i f r h pfa, then T |npfa. □
P roof. We shall prove that the canonical structure 93l0 of the theory
Tb( is a model of A.
If we let j3 e A, then ||/?|| g for every Q-filter By Lemma 9.2,
9Jl0, 3F \—ji. Thus 9Jt0 ls a model of the set A. □
which contains | | ~ a||. From Theorem 9.3 the canonical structure SR0
is a model of A and from Lemma 9.2 formula oc is not valid in Thus
SCR0 is not a model of oc. □
Lemma 10.1. Let SCR be a normalized structure SCR = <5, */, w>.
7/SR |n A x2 then for all s e S, card( / ( K ) (s)) ^ 2.
Proof. Let SR be a fixed normalized structure and
( V a j G f ) SCR1= A x2 .
Suppose that
card («/(£)($)) > 2 for some state 5.
Let sl9 s2, s3 e and st # s2, s 2 ^ s3, s x ^ s3. There then exist
formulas oc, /? such that
^ ( ^ i ) ^ a^(^2), = aan(y3),
i) /
Let y denote y or ~ y depending on its value in the structure SR and
state sl9
_ j y if SR, sx |=y,
y l ~ y if SR, s1 [= ~ y.
We now have
SR, Si |= (oca/?) and SR, s3 |= (a a ~/?).
10. COMPLETENESS THEOREM 249
Hence,
SCR, 5 \= ( $ K ( olA 0) A $ K ( ola ~ 0 )),
and at the same time
$DM2 t=~ot, i.e. a r t,J t= ~ n * a -
Thus
SCR, ^ 1= ~ ( ( ^ ( oca/?)a <>Z(oca~/?))=> □ * £ ) ,
a contradiction. □
Consider case A.
If IID^ajl e iF , then || a|| G # '1n ^ 2 by the definition of the inter
pretation J ' q. This contradicts our assumptions. Thus, \\[JK oc\\
Since is a maximal filter, we have || ~ □ Abc|| e .
By A x2 and the maximality of
(1) |i /?)|| g or
(2) ||-0 ^ (a A -/?)|| e^F.
Assuming (1), we have
11(~ □ K true v □ K ~ (a a /5))l | e
Thus \\U K ~(aA /?)|| e ^ and in consequence
(3) 1\~( oca{})\\ e # rl n,?r2n # r3.
10. COMPLETENESS THEOREM 251
We denote the antecedent by while for short and the succedent by if.
Suppose that for every i
(4) 11(while => i f l)\\ $ Z 3rK.
By the definition of Z ^ K
11- UK{while => i / 1) 11 e ^ for all /.
252 V PROPOSITIONAL ALGORITHMIC LOGIC
and consequently
0 * ~ G M - A ft)).
Since ||0 ^ a || e we have
||0*~G & i A ... a ^ ) || e#\
Thus || ~ i a ... Aj8B)|| e ^ in contradiction to ||& || e Z& k -
C. We can hence construct a proper filter which contains
L emma 10.8. Let m be a fixed natural number and let A xm be the set
o f all formulas o f the following fo rm :
m -\ f . m —1 . .
n A ... a a;*) =9. D t f O j ... A a*"*))
;=o i=o
10. COMPLETENESS THEOREM 255
No two formulas di9 8j, i ^ j 9 can be satisfied by the same state. Hence
m —1
for every s' e Km(s) there exists z, such that $01, s' <5/. Thus [JK 8t
1=0
11. E L IM IN A T IO N O F B O U N D E D N O N -D E T E R M IN IS T IC P R O G R A M
V A R IA B L E S
either Kx or
either K2 or
either or Km ro
ro
ro.
For short, (Kx or K2 or ... or Km).
Let 9JI be a semantic ra-non-deterministic structure
m = <*s, s 9 wy
for the language L 0. We shall construct a new structure 9Jt'—a partial
function structure —for the language L'0 in the following way:
K .*
Fig. 11.1
From the Model Existence Theorem for TP( and Tm we infer that
an w-non-deterministic theory Tm = <L0, Cm, A) is consistent iff the
corresponding partial function theory T* = <L0? Cpf, A') is consistent.
Analogously, by the Completeness Theorems for TPr and Tm we
have the following theorem:
n « j,A ... aA
Lemma 12.1.
(i) Every semantic proper structure with a Yanov interpretation is
a model o f Yax.
(ii) I j \ f is an interpretation o f program variables such that 9Jl — (IV, J)>
is a proper model for Yax, then J is a Yanov interpretation.
Proof.
(i) Let us consider a proper semantic structure 9K = (W , Y), where Y
is a Yanov interpretation of program variables.
The first two axioms are valid since by the definition of Ay, $01, ^[=<7
iff 9JI, v ’ (= q for all q $ Car(A), all v' e K Y(v) and for every valuation
v e IV. The third axiom is also valid for every v e W since all possible
changes of the values of variables from Car(A) are admissible as a re
sult of Ky .
(ii) Suppose 9Jl = is a model of Yax. If (v, v f) e K%i,
13. APPLICATION OF PAL IN MICROPROGRAMMING 263
Fig. 13.1
shift Acc and M to left (to right), check whether the last bit of M is 0,
check if Acc and M contains only zeros, subtract 1 from the counter,
add 1 to the counter, test if counter contains 0, etc.
This physical model gives us an insight into the formal theory pre
sented below. We shall imagine a collection of registers. Each register
can contain an infinite sequence of bits (binary digits)
... ^3 (I2 do d_ j d_ 2d_ 3 ...
The set of program variables will represent microoperations on reg
isters; for every i , j we have the following program variables:
au—add the content of the register R ( to the register Rj,
Rj := Rj + Rj,
lt —shift R t to the left, R t : = 2 x R t,
rt —shift R t to the right, R ( := Rtl2,
Oi —put 0 into Ri, R t: = 0,
Si —add 1 to R i, R t := R t + 1,
P i—subtract 1 from R t, R t := R i— 1.
For every i we have the two propositional variables:
Zi—check if Rt contains only zeros,
et—check if R t contains zeros on all non-positive positions.
The schemes of programs can in these circumstances be interpreted
as microprograms. The algorithmic formulas need not contain the
modality signs □ and 0 since we assume that the actions are deter
ministic, i.e. instead of □ M ol or $ M ol we shall simply write M ol. We shall
operate with axioms having the form of equalities of microprograms.
The equality M = M ' should be conceived as the scheme M ol = M ' ol
for every formula a.
Below we present the schemes of axioms of our theory T of registers:
lidij = afjli, afjrj = rjdij, Sipt = PiSt = Id,
auh = hafj, a.-y/'i = r,afj, h r; = r j i ,
h$i $ih> hPi P ih >
nsi = sfr-„ pf r t = rtpi,
r%°i = hoi = stOi = PiOi = ot = ajiOi,
h^i — ~ f i%i 5
while ~ z t do p t od true =s> ~ si zt,
et = while ~ z t do p f od true.
13. APPLICATION OF PAL IN MICROPROGRAMMING 265
P roof . By axiom
if ~ z 3 then K x else Id fi fi == (z3A K 1 fiv ~ z 3/\fi),
we have
K {(z3A 0 l 0 3^)
= ( ~ ^3 A 2 />3 ^ 2 i/ 2 J ( z 3 A 0 ! 0 3 /?) V / sT ^ , 2 J ( z 3 A 0 t 0 3 / ? ) ) .
Let us multiply the right hand-side of the above formula by (e3 v ~ e 3).
Applying (2) and the following ample facts:
( ~ z3a ~ e 3) = ~ e 3,
((if ~ z 3 then a\ 2 ; p\ fi)u/2J(z3a oto3P) => e3),
(012p3(if ~ z 3 then a\2\p\ fi)u/2J(z3a Oj o3fi) => ~ e 3)
we obtain
(4) K {( z 3 a o 1 o 3{}) = if ~ 03 then «12; p3 fi K 2LJI21(z3A o i o3j3).
while ~ z 3 do
if ~ e 3 then al 2 ; p 3 fi;
h ; ^3
od;
° i ; 03
end.
It is not difficult to observe by (5) that the complexity of the last
microprogram is much better than the original one (the obtained micro
program is frequently implemented in computers). It requires [logA3J+ 1
steps in comparison with the R 3 steps of the original algorithm.
268 V PROPOSITIONAL ALGORITHMIC LOGIC
BIBLIOGRAPHIC REMARKS
Let us remark that the set of all finite computations of the program M
determines a binary relation M<& in the set of all valuations of a data
structure 31 such that
(v , v') e M% iff v' is a result of a computation of M from
the valuation v in the structure 31.
The relation M% is called the interpretation of a program M in the
structure 31.
Hence, the interpretation of a program begin K ; M end is a compo
sition of the interpretations of K and of M; the interpretation of a pro
gram either K or M ro is the set-theoretical sum of the interpretations
of K and M and the interpretation of while y do M od in 31 is
U (if 7 then M fi)!fto {(^?v): 31, v |= ~y}.
ieN
Let K%(v) denote the set of all results of the program K at the valu
ation v in the structure 31, K%(v) = {vf: (v,v') eKy}. The following
lemma gives a characterization of this set according to the structure
of the program.
\K%{v) i f % v \ p y,
(if y then K else M fiM®) = ,r Qr , A,
v ' [Mn(v) if % ©|= ~ y ,
(either K or M ro)»(©) = K<n(v) u
(while y do M od)ai(©)
= (if y then M fi)a(©) n {©': 31, v ’ \=~y}.
ieN
For the proof see the similar considerations which have been pre
sented in PAL (cf. Chapter V, § 2). □
2. PROPERTIES OF NON-DETERMINISTIC PROGRAMS 273
The set of all formulas will be denoted by F. The sets of terms, for
mulas, and non-deterministic programs determine the non-determin
istic algorithmic language L.
We shall define below the semantics of the language under con
sideration.
Let 51 be a fixed data structure for L. The semantics of non-deter
ministic programs has been defined in § 1 of this chapter. Hence it
remains to define the semantics of formulas. However, the formulas
constructed by means of the classical connectives a , v , ~ , =>, and
quantifiers 3, V are interpreted in the usual way (see Chapter II, § 1)
and therefore need not be mentioned here.
Thus for an arbitrary valuation v in the data structure 51 we assume
51, ^ i= <>Ma iff (3w' e M<u(v)) 31, v' )=: a,
51, © [= Q M a iff (Vz>' g M<u(v)) 31, v' |= a and all com
putations of M at the valuation v in
31 are finite,
51, v |= ]_\Mot iff (3/ e N) 31, ©(= n M ‘a,
51, v [= r\Moc iff (V/ b N) 31, v (= Q M 'a,
51, v |= \ J Moc iff (3/ g N) 31, ©1=0M la,
51, v |= f\M cc iff (Vi e N ) 3t, v |= OM'a.
274 VI NON-DETERMINISM IN ALGORITHMIC LOGIC
VsWvifli) l 1, ...,n,
L emma 3.1. For every substitution s o f the form (1), every data struc
ture 31 o f non-deterministic algorithmic language, every valuation o f
individual variables v, every formula a and program scheme M o f PALpf,
if is a well-formed formula and sM is a well-formed program o f
sol
Inductive assumption: Lemma 3.1 holds for all formulas that are
submitted to the formula a' and all program schemes that are of less
complexity than M'.
Let 31 and s be a fixed data structure of NAL and a fixed substi
tution of the form (1) respectively. We shall discuss different forms
of the formula a' and the program M ' such that ' and sM ' are a well-
so l
Hence
v f e sM%(y) iff vMv e (either M x or M 2 ro)m(vs%v).
4p. Consider the program scheme M = while y do M od. By the
semantic properties of non-deterministic algorithmic logic NAL we have
v' e sM%(v) iff there exists an iQe N such that
v' e (if y then M fi)*$(V).
By the inductive assumption this is equivalent to the statement that
there exists an i0 such that e (if y then M fi)^ (©,*„) and therefore
vs%v>e (while y do M o d ) ^ ^ ) .
Now let us consider the formulas.
If. Let us assume that ex is of the form <>ATa, where K e V p. By the
definition of semantics
s 0 Kex%(v) = 1 iff there exists a finite computation of the
program sK<& at the initial valuation v
such that its result v' esK^(p) satisfies
sex.
By the inductive hypothesis, there exists a successful computation
of the program K such that
vs%v’ g Kwi(vsftv) and 2R, vs%v>f= ex.
Hence
% ,v \n s § Kex iff SUt, vs%v [=: §Kex.
2f. Consider the formula ex' of the form QATa, where K e V p. By the
definition of a semantic we have
31, v\=is[!]Kex iff all computations of the program sK%
are finite and for all v ’ esK%(v)y 31,
v'^zsoc.
By the inductive assumption for the program variable K and for the
formula a we have
31, v\=zsQKoc iff all computations of the program
scheme K are successful and for all
*>Mv' e ATanfosu,) we have 9JI, vs%v |=a.
3. SUBSTITUTION THEOREM 281
Qsy = Osy, = sy
0 M(a v 0) = (QMa v 0 Af/?), □ Af(a a ff) = (D M a a □ Af$),
\ f M a s (a v \/A f(0 M a)), UAfa = (a v uAf(DAfa)),
/\Moc = ( a a /\A f(0A fa)), nAfa = (aA nA f(D M a)),
.y((3x)a(x)) = (3t)^(( x := T)a(x)),
where y is an individual variable not occurring in sy
(~ § M a => O A f~ a), □ M true => (<>Af ~ a = ~ □ Afa'),
$(x := r)a(x) = (3x)a(x) for every term r,
(Vx)a(x) = ~(3x)a(x),
<> begin Af; Af' end a = <>Af(<)Af'a),
□ begin Af; Af' end a = □Af(DAf'a),
0 if y then Af else Af' fi a = ((7 a <>Afa) v ( ^ 7 a $M'oc))y
□ if 7 then M else Aff fi a = ((7 a QM a) v ( - 7 a □ Af'a)),
0 while 7 do Af od a
— ( ( - 7 A a ) v ( 7 A<)M(0 while 7 do A fo d a ))),
□ while 7 do Af od a
= ((~ y A a )v (7 a D A f(n while 7 do Af od a ))),
<>either Af or Af' ro a = (^Afa v $ Af'a),
□either Af or Af' ro a = (QAfaA DAf'a).
In the above schemes of formulas a, /? are arbitrary formulas, 7 is an
open formula, Af and Af' are arbitrary programs and s is an assignment
instruction.
The set of inference rules contains all rules of PAL and some rules
which characterize the classical and iteration quantifiers.
4. NON-DETERMINISTIC ALGORITHMIC LOGIC 283
Rules
—— modus ponens,
P
((x := y)a(x) =>18) where y is an individual variable
((3x)a(x) => /?) ’ occurring neither in a nor in /?,
(«=» P)
(OMa => $Af0) 5 (□Afa => DJIf/J) 5
a) => i8)},6/v { (O M ^ D ^ a ) => j8)}/e*
( O M '( V ^ ) => /») ’ (O M '(uM a) => /?)
( 0 M r(U M a)=>j5)'" *
Assume that SCR is a model of T and that all formulas (0 M '([ jM loc)
=> /?) are valid in SCR. Suppose that for some valuation v
SCR, €? |=: $M'(uMoc) and 9ft, v [=
Hence there exists a finite computation of M ’ such that its result sat
isfies the formula \jMoc. By the definition of semantics it follows that
9ft, v |= DAToc for a certain i e N and a certain valuation v e M%{v).
Thus non 9ft, v |z: (OAf^DAf'a) => /S) contrary to the assumption. □
(3) Let Q denote the set of all infinite operations mentioned in (2).
By the Rasiowa-Sikorski Lemma (Rasiowa and Sikorski, 1968) for every
non-zero element a of the Lindenbaum algebra there exists a g-filter
V such that a e V (see Appendix A).
(4) Let 9Ji be a data structure in the set of all terms of the language L
such that
("Ti , . . . , T„) G iff | | ^ ( T j , . . . , T,,) j | G L >
5. C E R T A IN M E T A M A T H E M A T IC A L R E S U L T S
L e m m a 5.3 For an arbitrary formula < x which does not contain any
whil^-instruction or quantifiers there exists an open formula y such that
(1) 91,v\=:y iff 9 l,flf= a
for an arbitrary valuation v and an arbitrary data structure 91.
P roof . The lemma holds trivially for open formulas. Let us assume
that (1) holds for all formulas which are submitted to the formula a
(see Appendix B) and let us consider the formula a = DAf/?.
If M is an assignment instruction (x w), then by the induction
hypothesis there exists an open formula p such that for an arbitrary
data structure 91
a i=G5' = /?).
(a =s> p )
Hence bv the rule-, we have 91 }= (DM/?' = DM/?)-
( □ M a => U M p )
Theorem we have
31 h: □ either M i or M 2 ro /? = ( C W ^ a □ M 2jS).
By the induction hypothesis there exist open formulas y 1 and y 2 such
that for an arbitrary data structure 3t,
W ^ n M lp = yl and M 2fi = y 2.
Hence
3t \=z □ either M t or M 2 ro ft = (yt a y 2).
We shall omit the easy next steps of induction. □
P roof . Since the proofs in cases (i) and (ii) are essentially the same
we shall discuss case (ii) only. Moreover one implication is obvious
by the definition of semantics.
Let Hmdenotes the formula \ / □ and suppose Hm is not a taut-
i^ m
ology for arbitrary m e N. For arbitrary natural number /, the formula
□ Ar*y is equivalent to an open formula, say cf. Lemma 5.3. Let us
put H'm = V ft, Hence for an arbitrary data structure 31
i^m
from the construction that, if n > m then for every v e W" there exists
a valuation v' e W m such that v — ©' off(F —V{H”)), i.e. v(z) = v'(z)
for z e V ( H The set ( J W"‘ creates a tree such that the elements
meN
of Wm are on the (m + 1) level of the tree and a valuation v on the
(m + 1) level is a son of the valuation v on the m level if and only if
v = i off(F—V(H„)).
Since the degree of any vertex in the tree is finite (the set Wmis finite
for every m e N), then by Konig’s Lemma (cf. Kuratowski and
Mostowski, 1967) there exists an infinite path 0 , v o, v l9 ... such
that Vj e WJ, j e N. Let us denote by v ^ a valuation such that
v ^ = v moff (V —V(H")) for every m e N .
Thus for every natural number m, H 'Jfvf) = 0.
Let 91 be a data structure in the set of all terms such that
(t i , tw) e iff ®oo($Q(Tt 0rt)
i ? •••> r B) tyfai ? •••?
for an arbitrary ^-argument predicate q and an arbitrary ^-argument
functor y).
Let v be a valuation in 91 such that
v(x) = x for all individual variables x,
v(q) = v^(q) for all propositional variables q.
From the above construction we have
non 91, v |n H'm for every m e N
and therefore
non 91, F [~ H m for all m e N .
By the definition of semantics.
l.u.b = 0.
ieN
L emma 6.1. I f h is an is o m o r p h is m o f 31 a n d ©, th en f o r e v e r y te r m r,
e v e r y o p e n f o r m u la y a n d an a r b itr a r y v a lu a tio n v in th e s tr u c tu r e 31
(3) h (T n { v j) = r* {h v ),
D efinition 6.1. We shall say that the two data structures 21 and 23
are algorithmically equivalent ifffor every formula a
2I[=: a iff SBt=a. □
00
either K : begin
begin K M ' end either K' or K" ro;
or Mf
begin K" \ M ' end end.
ro, □
From the practical point of view the above definition is not very
useful, since two programs which in fact compute the same function
are not equivalent if they make use of different auxiliary variables.
E xample 7.2. The following programs are not equivalent in the sense
of Definition 7.1:
M : either
while y do K od
or
while y' do K' od
ro,
M ' : begin
either q := true or q :— false ro;
while ( y A q ) v (y' v ~ q) do
if q then K else K' fi
od
end,
where q is a propositional variable not occurring in K, K' and y.
Moreover, let us note that Definition 7.1 does not capture the differ
ence if one program has infinite computation and the other has not.
The programs
K: x: = 1;
M : either
x := 1
or
while x > 1 do x := x + 1 od
ro
are equivalent in the sense of relation ~ although M has an infinite
computation, while the unique computation of K is finite. □
7. EQUIVALENCE OF PROGRAMS 293
D efinition 7.2. The two programs K and M are equivalent up to the set
o f variables X, K ~ M off X for short, iff for an arbitrary data structure
31 and an arbitrary valuation v:
(i) there exists an infinite computation o f Kfrom the valuation v in 31 iff
there exists an infinite computation o f M from the valuation v in 31.
(ii) K% = M% off X , i.e.,
(v, v') e K% implies
(3v")(v,v") g M% and v' = v ” off X
and
(v, v') e M% implies
(lv)(v, v) g Kw and v' = v off X. □
exists a valuation such that v' = v i off X and (v, v t) e K2% or there
exists a valuation v 2 such that v 2 = v f off 7 and (v , ?;2) e Hence
there exists a z/' e(either K2 or M 2 ro)^ (v) and v" = z;' off (Xu 7).
The converse implications are abviously true also. □
b e g in
Mx;
w h ile yi do M2 od
en d
or
b e g in
Kt ;
w h ile y2 do K2 od
en d
ro,
7. EQUIVALENCE OF PROGRAMS 295
M': begin
either q := true or q := false ro;
if q then M x else K x fi;
while (q/\yx) v ( ^ ^ A y 2) do
if q then M 2 else K2 fi
od
end. □
Let I b e a set of variables inessential for K and for M and let Fx
denote the set of all formulas a such that V(oc)nX = 0 .
For any program K, let PC*(iT) denote the partial correctness theory
of K such that
PCX(K) = {(oc, (S) e F2: b- ((a a 0 ^ true) => OAJS)}.
As the next consequence of Lemma 7.4 we find that if two programs
are equivalent then their partial correctness theories are equivalent.
296 VI NON-DETERMINISM IN ALGORITHMIC LOGIC
This implies by the completeness theorem that there exists a data struc
ture 21 and a valuation © such that
non 21,© |= ( ( oca tru e) =>
Hence
(2) |= oc and 21,© [n (^ M tr u e a ~ QM/?).
Thus, by the Completeness Theorem and Lemma 7.4, 21, v t= ~ o w ,
and therefore, by (2) non 21,^ |= ((a a t r u e ) => Hence
((a a t r u e ) =^> QM/?) is not a theorem of NAL and moreover
(a, /?) £ PC*(X). As a consequence PC*(X) cz PC*(M).
Analogously it can be proved that PCX(M) c PCX(K), □
Assume that V(K) = {zt , ..., zn, qt , ..., qm}, V(M) = V(K)uX and
Xc\V(K) = 0 , where zf is an individual variable for / ^ « and qj is
a propositional variable for j ^ ra. Let K{yp) be a copy of the program K
which is obtained by the simultaneous replacement of all occurrences
of Zj by j; for i ^ n and all occurrences of by p} for j ^ m. Moreover, let
{yi — y n> P i , ..., p m}r\X = 0 .
BIBLIOGRAPHIC REMARKS
1. CONCURRENT PROGRAMS
is then a program. □
2. MAX SEMANTICS
Table 2.1
5. Mark out all empty instructions, i.e., all occurrences o f begin * end,
cobegin *|| ... ||* coend, replace by *. □
Let us recall that a direct successor of a configuration (v\ M ) is
any configuration <V; M 'y which can be obtained by the following
operations:
(1) moving marks * inside,
(2) choosing a maximal non-conflict subset J of instructions (which
retains a remainder of previous choices),
(3) choosing a subset / ' c= J of instructions that are to be com
pleted in this step,
(4) execution of instructions from
(5) deleting empty instructions.
v : —--------- ; * cobegin x : = r\ \ y : = rj \ \
v v x iv v
Let us assume that the variable x does not occur in the expression
rj and that the variable y occurs neither in the term r nor in the formula y.
Suppose that 31, v 1= y.
This configuration has six different successors:
/X V
( .., — ; cobegin * ||* if y(x) then M 1 else M 2 fi H
2. MAX SEMANTICS 303
* c o e n d ),
/x_
c o b e g in °x :== r || * if y(x) th e n e ls e M2
\ v x n(v)
fill * coend
\
/’
( v ; c o b e g in * x : = r || * f| o y : = rj c o e n d ),
y
( - r){v) ; c o b e g in * x : = r 11 o i f y (x) t h e n A fj e l s e M2 fi |
* c o e n d ^ ),
/_x
; c o b e g in *x := r|| || * coen d ) • □
rj(v)
In this way the semantics MAX is defined. The conflicts are ascer
tained at the level of instructions and a maximal non-conflict set of
instructions is initialized at every step.
(ii) The maximal set of non-conflict actions are taken into consid
eration in each step (we do not admit lazy processors).
Let us now call the reader’s attention to the second non-determin-
istic choice in the definition of MAX semantics. One may think that
this choice is not essntial; however, this is not the case. We shall discuss
this problem briefly below.
Let us consider a modification of MAX semantics which is obtained
by omitting step (3) of the definition (cf. Definition 2.2), i.e., all in
structions chosen for execution will finish in this step (observe that
marks are not necessary in this case). Thus, the relation of direct suc-
cessorship is determined by the following steps:
(1) putting marks * inside,
(2) choosing a maximal non-conflict set J of instructions,
(3) execution of all instructions from /,
(4) deleting empty instructions.
Let us call a semantics with the above direct successorship relation
simple MAX semantics, or SMAX semantics for short. Below we shall
indicate the difference between MAX and SMAX semantics.
/*_ L . *\
\ 4 4 5 */*
One of the possible computations in MAX semantics is the following:
( v ; cobegin * x := 1; x := 2; x := y || * y := 3; y := 4
coend),
3. OTHER CONCEPTS 305
H JL_ ; cobegin *x := 2; x : = y ° y := 3; J := 4
\ 1 j *;<>)
coend ^,
/_x J
; cobegin : = y || : = 4 coend\/
\ 2 3'
J . cobegin * |l :== 4 coend
\ 3
/x ^ y_
\ 3 4 7-
As a conclusion from the above we can observe the different algo
rithmic properties of program M in MAX and in SMAX semantics.
!■—s m a x D M (x = y) and ^RS^max §M( x ^ j). D
In Figures 3.1 and 3.2 we present the set of all possible computations
of K in MAX semantics and in ARB semantics.
ARB semantics
( v x: ^ J'- : cobegin * || * q:
l
r, . p q . \
3' T F ’ V
4 :- j - ; c o b e g in * /? : = fa ls e || * p : — q coen d \
l
<a3; *>
I
<v2\ *>
Fig. 3.1
I^arb ( a <>K~p).
In MAX semantics, however, it is necessary that after every execution
of K the formula p holds, i.e.,
{—■MAX U\Kp. C
3. OTHER CONCEPTS 307
MAX semantics
1*> I
<V2\ *>
I
<^3; * >
Fig. 3.2
In all the semantics discussed above we have not assumed any restric
tions on the set of processors, i.e., the number of processors was po
tentially infinite. Obviously in practice any computer has a bounded
308 VII PROBLEMS INSPIRED BY LOGLAN
<w; M'>-
ARB(l) = ARB(/),
Thus the semantics ARB(l) also called multiplexing and ARB sem
antics are not essentially different.
3. OTHER CONCEPTS 309
Observe that
ARB(l) = MAX(l) = SMAX(l).
The same problem has a different solution for SMAX(n) semantics
from the one it has for MAX(«) semantics.
SM A X f/i+n semantics
IP Xn .
M)
\\ 0_ 0 ;
/P X X \
\0 1 ’ cobegin * while ... || ... || * while ... coend^},
/ P X l ••• . \
No t ~ Y 9 */•
Let v be a valuation in such that v(xD = 1 for / ^ n. Hence we have
the following properties: for every / ^ n>
V f~~SMAX(n + 1 ) n \ M ( X i = 1)
and
|—
-smax(/i+ i> O M true.
SMAX(«) semantics
One of the possible computation of the program M in the data struc
ture is as follows:
/ D X X
(n T T ™ ? ’ cobegin * p : = false j|
o x x := Xj +1; while ... ||
* x2 : = x2+ 1; while ... || ... ||
* xn := x n+ 1; whUe ... coend^
\ f ~ i ; cobegin * p : = fa,se 11
* while/? do x x := x x-f 1 od|| ...||
* whilep do x : — x + 1 odcoend^},
The conclusion is
MAX(«) ^ SMAX(«) and MAXfo) ¥> MAX(n+\),
SMAX(n) # SM AX(/i+l).
4. MAX VERSUS ARB 311
The previous section has indicated the differences between MAX and
ARB semantics. Now we shall discuss the same problem on the basis
of Petri nets, to show that the distinction is deeper than could be seen
from the examples given. We shall start with the necessary definitions.
Example 4.1. The graph shown in Figure 4.1 (p. 312) is a Petri net
in which p u .. . , p 5 are places and tu ..., tA are transitions. The initial
marking is described by dots at the corresponding places and the values
of functions BACK and FOR are indicated on the arcs.
Jf the condition does not hold, then we say that transitions {tl9 ..., tn}
are in conflict at the marking m. □
E xam ple 4.2. Let us return to Figure 4.1. Let m0 be the initial mark
ing described on the graph. There are three possible non-conflict sets
of transitions in marking m0 :
{t2}9 {t3} and {t2, t 3}.
Observe that the transitions tx and /4 cannot be fired at m0.
4. MAX VERSUS ARB 313
/P i P i P i Pa P ± . u A
\0 2 2 0 1 ’ i h } / ’
/Pi Pi P 3 P a Ps . ft A
\0 1 T O 1 ' * ^ 2V ’
(Pi Pi Pi P a P s . \
X T O' 0 0 1 ’ / '
Clearly, after two repetitive firings of the transition t2 the net is dead—no
transition can be fired.
The second example shows an infinite firing sequence such that the
values of the marking functions are not bounded
< m 0 , {ti}>, < « ! , {*a < m 3 , { '* } > , •••
m . Pi Pl_ P3 Pa P s
2 i ' 0 i+ 2 i+ 2 0 l ’
where i is an arbitrary non-negative integer.
The third example presents an infinite cyclic firing sequence
( m 0,{t2, t3}>, {m0,{t2, t 3}'), / m 1, {U}}, ■■■,
where
^ . P i PiP s Pa P s |—i
m‘ ' n ' D
tics, describes the set X presented in Figure 4.4. This example is very
important since, by the Pumping Lemma (cf. Burkhard, 1981b), any set
computable by a Petri net in ARB semantics contains an infinite linear
subset. Obviously, the set described in Figure 4.4 does not contain an
infinite line.
E xam ple 5.1. Consider the following program in the data structure
of natural numbers 9t:
K : begin
p : = true;
cobegin while p do x x+ 1 od || p false coend
end.
Considered within ARB semantics, the program has the following
properties:
! = a r b (Vfc 6 to) (§K(x > k) a ~ [JK true).
316 VII PROBLEMS INSPIRED BY LOGLAN
One can compare this example with the remarks of Dijkstra and
Lamport (1980) that the termination of the program K means exactly
the fairness property of the semantics.
Phi
Five philosophers are sitting around the table. There are five forks
and a fish. Each philosopher alternately ‘thinks’ or ‘eats’. We assume
that eating is possible only when the philosopher has involved two forks.
When passing from thinking to eating each philosopher must synchron
ize his actions with his two neighbours since the forks are shared.
318 VII PROBLEMS INSPIRED BY LOGLAN
6. LIBERAL SEMANTICS
result is then undefined, i.e. the processes put a value in the shared
variable but we do not know which value.
F ig. 6.1
D efinition 6.3. We shall say that the configuration (v'; M'} is a di
rect successor o f a configuration ( v ; M } in LIBERAL semantics iff
<V; M 'y is obtained by means o f the following non-deterministic al
gorithm :
1. Each mark * moves inside the program as long as it precedes the
basic instructions according to the rules mentioned in Definition 2.2.
Let L be the set o f all instructions marked with *, but not control
actions; Let IC* be the set o f all control actions marked with * and let /_
be the set o f all instructions marked with o. I f the set I^.kjIC*\j I 0 is empty
then the configuration (v; M y does not have any direct successor.
6. LIBERAL SEMANTICS 321
2. Change the marks o f all instructions from the set I* into °; {all
instructions, except control actions, star? execution). For every SEM e Sem
take from the set IC* only one instruction lock(SEM) or unlock(SEM)
and change its mark into o . Let / ' be the set o f all control instructions
marked with o .
3. Choose an arbitrary subset /" o f the set /* u /0 {the set o f instructions
which will finish execution).
4. Execute all instructions from the set F and I".
The resulting configuration (v'\ M ') is obtained by the simultaneous
execution o f all modifications displayed in Table 6.1 {p. 322). □
t/(S E M ) = open
II II
*£
.V) £
%"§
Is replaced by
s*
o g5 1V ^
13
§ JL ■a ^
*
Q - *> II II
>1 S
i-i
C ^ *
^ -a -5 £S mS
o o
and replace it by *
§ ^ i 't »
* ■» 3
^ ®§ ll * *
$=5 S3 * w
cft
=
n a £
S5 s *
! !g J? £* 1 ^* *£ * s1
1 * *
|
j «*H j1 1
j
j j ss
>
instruction
0
I ifi 1 o
11
! ii i *3 1! v«
^
H
^ i £ © 1
c ■° |
a ^ 1 W
w
a O
o
*
! o
°
6. LIBERAL SEMANTICS 323
(i) c0 = <v0; *M}9 where v 0(x) = z;(x) for x e V ivV 0 and z;(SEM)
= open for SEM e Sem;
(ii) for all /, ci+1 is a direct successor o f ct or ct has no direct successor. □
/ SEM p x y
; cohegin * p := false; unlock(SEM)||
\closedT 10" ’
* lock(SEM); while... ||
o y : — y+ 1; lock (SEM); while ...
/ SEM p x y
; cohegin * unlock(SEM)||
\ closed 0 1 1 ?
0 lock(SEM); while ... ||
* lock(SEM); while ... coend),
/ SEM p x y m
; cohegin * unlock(SEM)!|
\ closed O i l ’
0 lock(SEM); while ...||
lock(SEM); while ... coend),
/ SEM p x y
; cobegin * j| ❖ lock (SEM); while ... ||
\ open O i l ’
0 lock(SEM); while ... coend) ,
SEM p x v
; cobegin * 11 * while p do x : = x+ 1 od;
closed O i l ’
unlock (SEM) | i
0 lock (SEM); while ... coend),
324 VII PROBLEMS INSPIRED BY LOGLAN
/ SEM p x y
cobegin * || * unlock(SEM)||
\ closed 0 1 I
0 lock (SEM); while p do
y := y + l od ... coend^},
/ SEM p x y
cobegin * || * || * lock(SEM); while p do
\ open O i l
y : = y + 1 od ... coend
/ SEM p x y
cobegin * || * || * while p do y : = y + 1 od;
\ closed 0 1 1
unlock(SEM) coend^,
SEM p x y \
( open O i l ’ / * □
/v ; ;cobegin
cobegin**lock
lock(SEM);
(SEM);xx : =
: = xx++1;1;
\ 1 1 open
unlock (SEM) while x > 0 ... ||
* lock(SEM); x := 0 \ y : = 0;
unlock(SEM) 11
*lock(SEM); y := y + 1;
unlock(SEM); while y > 0... coendy,
/ x y SEM
; cobegin * unlock(SEM); while x > 0 ...
\2 1 closed ’
0 lock(SEM); x : = 0; ...||
326 VII PROBLEMS INSPIRED BY LOGLAN
® lock(SEM); y := y + l ;
unlock(SEM); while y > 0... coend/,
/ x y SEM
; cobegin * while x > 0 do lock(SEM); ...||
^2 1 open
® lock(SEM );x : = 0; ...||
* lock (SEM); y := y + 1; ... coend^,
/ x y SEM ^
cobegin * while x > 0 do...||
\ / + 1 i open ’
® lock(SEM); x := 0; ...|!
* lock(SEM); y := y + 1;.. coend
6. LIBERAL SEMANTICS 327
/ x y SEM
; cobegin <g>lock(SEM); x : = x + \ ; . . . \ \
\ / + l i+1 d o sed ’
<g>lock(SEM); x := 0; ...||
* unlock(SEM); while y > 0
do ... coend^,
/ x y SEM
; cobegin * lock (SEM); x: = x~b 1; ... j|
\ / +1 / + 1 open
<g> lock(SEM); x := 0; ... ||
Lemma 6.1. Trees o f all computations o f program K' from the initial
valuation v in MAX and in LIBERAL semantics are equal.
Proof. Every MAX computation of K' is equal to a LIBERAL
computation of K f. Consider a configuration c of the form
(v \ m ia1R l i! ... jjmnanRn},
328 VII PROBLEMS INSPIRED BY LOGLAN
Postulates
Theorem 7.2. For every non-empty frame f ^ none there exists a state
s such that newfr(s) = f i.e. the formula
D efinition 7.1.
/1 < f 2 = (fi = none v
begin s : = allfree; bool : = false; rel : = false;
if f 2 ^ none then
while bool do
/ := newfr(^);
if/ = f i then rel : = bool : = true else
if / = f i then bool : = true else
s insert (f, s) fi
fi
od
fi
end rel). □
(3/ ^ 0) (s := allfree)
(.y := insert (newfr(.s), .s))l(newfr(.y) = f 0).
C o r o lla r y . For every model o f ATR theory the ordered set (Fr, ^ )
is isomorphic with (N , ^ ). □
as described in the previous section (p. 330) which can differ in the
interpretation o f an nfr operation. □
The question of reducts may seem strange. First of all let us remark
that there are other standard models, e.g. the one in which operation
newfr is defined as follows
newfr (,s) = m ax(j)+ l.
The standard model defined above and the standard model of the pre-
ceeding section are not isomorphic. On the other hand it is hard to
argue about the advantages of one model as compared to the other.
One can observe a similarity between the theory of references and the
theory of dictionaries. Our remarks concerning the effectiveness of the
amember operation of dictionaries may be repeated here. Operation
newfr is a selector and in general proofs of the existence of this selector
are not constructive. All of them have to use the axiom of choice.
The theory described above can be used to explain the semantics of those
programming languages whose frames are reusable and where at the
same time the construction of a language assures safety, e.g. no attempt
will be made to access a variable local for a block when the block itself
is closed. Moreover for languages like PASCAL, SIMULA, ADA,
334 VII PROBLEMS INSPIRED BY LOGLAN
E xample . For nodes of binary trees (cf. Chapter IV, §15) we have
static objects as triples
v \l \r
e j nx ' n2
/ / v | / Ir \ \
and dynamic objects in pairs ^ref, □
containing a type declaration for these objects. For these languages the
theory of references is adequate, and the treatment of objects is safe.
In languages of the second group there exist instructions disposing
an object like kill(x) in LOGLAN. The effect of the kill instruction
is to delete the frame associated with an object from the set of occupied
frames. Consequently, such a frame can be allocated for another object.
This situation is not safe. Let us consider the following example:
block
unit A: class . . . ;
unit B: class . . . ;
variable ,41, A2: A, B 1: B ;
begin
01) A 1 : = new A ;
(i2) A2 := A 1;
03) kill(^l);
04) Bi := new B;
end.
Let us try to interpret this piece of program in ATR theory. Execution
of instruction (il) results in: finding a free frame / i n memory (newfr),
reservation of this frame for the object new ,4 (insert), assigning the
frame / to the variable A 1. The second instruction (i2) assigns the
f ra m e / to the variable ,42. The situation might look like Figure 8.1.
Fig. 8.2
336 VII PROBLEMS INSPIRED BY LOGLAN
Fig. 8.4
8. REPRESENTATION THEOREM FOR ATR THEORY 337
Fig. 8.6
338 VII PROBLEMS INSPIRED BY LOG LAN
D efinition 9.1.
u < uf == begin h empty H ; bool := false; rel := false;
while ~ bool do un : = newu(/z);
if u" = u then rel := bool := true else
if u” = u' then bool := true else
h into(u"9 h)
fi
fi
od
end rel). □
o: v:
0,
in the following way:
1° Variables x l9 ..., of the object o are formal parameters a1, ..., an
(we simplify considerations by assuming that all formal parameters
are variables).
2° Variables x n+l9 ...9x t are local attributes atl9 ...9atk of T.
3° The object o arises from the initial proto-object o',
*>. A
b e g in
; retu rn ;
/ 2 ; in n e r ;
Jz
en d r.
This definition should be viewed as an abbreviation of the full concat
enated declaration:
unit T : class (m1a1 : Tl9 ...,m nan \ Tn, mn+1an + l: r„ +1, ...
...,m rar : Tr);
a ? ! , + 1 5
begin
hi
hi
J x ; return;
J2 ; inner;
hi
end r .
Product
Subset
The next step in the construction is to define a subset of proper pairs
unit properpair : pair class
begin if M = 0 then E R R O R f i
end properpair.
The set |properpair| is a subset of |pair| set. ERROR denotes a
never-terminating program, e.g. while true do od.
Quotient structure
unit rational: properpair class
variable gcd, auxl, aux2 : integer;
begin auxl := abs(L); aux2 := abs(Af);
while auxl ^ aux2 do
if auxl > aux2 then auxl := auxl —aux2
else aux2 := aux2 —auxl f i
od;
gcd := auxl;
L := Z ^ g c d ; M := M-Fgcd;
end rational.
The set |rational] corresponds to irreducible fractions.
Extension
unit R A T IO N A L S : class
unit rational: properpair class ... end rational;
346 VII PROBLEMS INSPIRED BY LOGLAN
BIBLIOGRAPHIC REMARKS
B O O LEA N A LG E B R A S
E xamples .
A. The two-element Boolean algebra B0 = <{0, 1}, u , n , —).
B. Field of subsets of a set A" 0>(X) = <2*, u , n , —>.
C. The Lindenbaum algebra of a theory T (cf. Chapter III, § 1). □
A t - {®t,s}sGS*
If the least upper bound of the set At exists then we shall denote it by
l.u.b. (attJ.
seS
a0 $a i , a2? •••
The set C is defined by induction, on t e {0}uT.
a0 g C. (We recall that a0 ^ 0).
Let c be an g.l.b. of all elements already included in C, c ^ 0.
Consider at = l.u.b. (attS), t g T. We shall prove that there exists s0 e S
seS
such that
cn(a, => a,.So) # 0.
APPENDIX A 351
/ ( ~ a ) =/(<*)+1,
/ ( a v P) =f(ocAfi) = /(a= > )9) = max (/( a ),/(£ ))+ 1 ,
/(M a) = f(oc) +f(K),
/(if y then K else M fi) = m ax(/(y),/(X ),/(M ))*3 + l,
/(begin K; M end) = m a x (/(M ),/(X ))-2 + l,
/(while y do K od) = co * m a x (/(y ),/(/0 )+ 1,
f(\JK oc) = f(P\Koc) = max ( /( a ) ,/(£ ) )+ 1 ,
/((V x)a(x)) = /((3*)a(x)) = / ( a ) + 2.
Observe that for every classical formula a of the language L ,/(a ) < a>.
Let us put /(a ) = /(a ) for every classical formula of the language
L (i.e., for every formula in which programs do not appear) and /(a )
= co+/(a) for any other formula.
It follows that
f ( s ( y a K(3)) < f(s ( if y then K else M fi /?))
and
f(s (~ y A M P )) < / ( j ( i f y then K else M fi 0)).
An analogous proof of the remaining cases is omitted.
6. Let us denote max (f(y ), f(K )) by a. By the definition of the
function/ we have:
/(^(while y do A^od /S)) = /(/?)+ co *<z+ 2
and, for every natural number /,
f ( s (if y then K fi)l(J3a ~ y )) = (a •3 + 1) •/+1 < co •a -f 2.
Consider two cases:
(a) a < ay. In this case it is obvious that {a *3+1) */+1 <oo-a + 2.
(b) a ^ co. By the definition of the function f a is less than cow.
So, there exists n < co and bt < oo for j = 1 ,2 , ...,« such that a
= f t A ^ + CO"- 1 ... + 6 0 -
Since i is a finite ordinal number, we have
(a •3 -j-1) *i +1
= (on -(bn -O+ft)"-1 •/)+ ... + (V *'+ 1).
As a consequence
(a *3 +1) */+1 ^ <on+1 + 1 = o) •con+1.
However, con ^ a and thus co *0)"+ 1 ^ co -a+ 1 and finally
(cz *3+ 1) • /+1 < co -a-f 2.
It follows from (a) and (b) that for every natural number /,
f ( s (if y then K fi)l(~yA /?)) < /(^(while y do K od /?)).
7. Consider the pair (s a(r), j(3x)a(x)):
/ (.S'((3x) a(x)) ) = f(sa) + 2 = /(a ) + 3,
/ ( i ’~ a (r ) ) = / ( ~ a ( r ) ) + l = / ( a ) + 2.
T hus,/(«) + 2 < /( a ) + 3. □
ABBREVIATIONS
Aho A., Hopcroft J., Ullman J. (1974), The Design and Analysis o f Computer Algo
rithms,, Addison-Wesley, Reading, Massachusetts.
Andreka H., Nemeti I. (1981), A Characterization of Floyd Provable Programs,
Proc. Mathematical Logic in Computer Science, Salgotarian 1978, in: Colloquia
Mathematica Societatis Janos Bolyai 26, North-Holland.
Andreka H., Nemeti I., Sain I. (1979), Completeness Problem in Verification of Pro
grams and Program Schemes, in: Proc. MFCS'19 (J. Becvar ed.), LNCS 74, Springer
Verlag, Berlin, 208-218.
Andreka H., Nemeti I., Sain I. (1979b), Henkin-Type Semantics for Program
Schemes to Turn Negative Results to Positive, in: Proc. FCT'19 (L. Budach ed.),
Akademie Verlag, Berlin, Band 2,18-24.
Andreka H. (1983), Sharpening the Characterization of the Power of Floyd Method,
in: Proc. Logics o f Programs and Their Applications, Poznan 1980 (A. Salwicki ed.),
LNCS 148, Springer Verlag, Berlin, 1-26.
Apt K.R. (1979), Ten Years of Hoare’s Logic: A Survey—Part 1, TO PLAS3,431-483.
Apt K. R., Olderog E.-R. (1982), Proof Rules Dealing with Fairness in Logics o f
Programs (D. Kozen ed.), LNCS 131, Springer Verlag, Berlin, 1-8.
de Bakker J. W. (1976), Semantics and Termination of Non-deterministic Recursive
Programs, in: Automata Languages and Programming, Edinburgh, 435-477.
BIBLIOGRAPHY 357
de Bakker J. W. (1977), A Sound and Complete Proof System for Partial Program
Correctness, in: Proc. MFCS'79 Olomouc (J. Becvar ed.), LNCS 74, 1-12.
de Bakker J. W. (1979), A Sound and Complete Proof System for Partial Program
Correctness, in: Proc. MFCS'79 (J. Becvar ed.), LNCS 74, Springer Verlag, Ber
lin, 1-12.
de Bakker J. W. (1980), Mathematical Theory o f Program Correctness, Prentice
Hall, Englewood Cliffs.
Banachowski L. (1975), Modelar Approach to the Logical Theory of Programs,
in: Proc. MFCS'74, LNCS 28, Springer Verlag, Berlin.
Banachowski L. (1975b), An Axiomatic Approach to the Theory of Data Structures,
Bull. PAS 23, 315-323.
Banachowski L. (1977), Investigations of Properties of Programs by Means of the
Extended Algorithmic Logic, Fundamenta Jnformaticae 1, 93-119, 167-193.
Banachowski L. (1983), On Proving Program Correctness by Means of Stepwise
Refinement Method, in: Proc. Logics o f Programs and Their Applications, Poznan
1980 (A. Salwicki ed.), LNCS 148, Springer Verlag, Berlin, 27-45.
Banachowski L., Kreczmar A., Mirkowska G., Rasiowa H., Salwicki A. (1977),
An introduction to Algorithmic Logic, Mathematical Investigations in the Theory
of Programs, in: Math. Foundations o f Computer Science (A. Mazurkiewicz and
Z. Pawlak eds.), Banach Center Publications, PWN, Warsaw, 7-99.
Bartol W. M. (1981), Application o f Static Structure o f Type Declarations and the
System o f Dynamic Configurations in a Definition o f Semantics o f a Universal Pro
gramming Language (in Polish), Doct. Diss., Dept. Math. Inform., University
of Warsaw.
Bartol W. M., Kreczmar A., Litwiniuk A. I., Oktaba H. (1983), Semantics and Imple
mentation of Prefixing at Many Levels, in: Proc. Logics o f Programs and Their
Applications, Poznan 1980 (A. Salwicki ed.), LNCS 148, Springer Verlag, Ber
lin, 45-80.
Bartol W. M. et al. (1983b), Raport o f LOGLAN Programming Language, PWN,
Warsaw.
Barzdin J. M. (1979), The Problem of Reachability and Verification of Programs,
in: Proc. MFCS'79 (J. Becvar ed.), LNCS 74, Springer Verlag, Berlin, 13-26.
Bergstra J., Tiuryn J., Tucker J. (1982), Floyd’s Principle Correctness Theories and
Program Equivalence, TCS 17, 113-149.
Bergstra J., Tiuryn J. (1981), Implicit Definability of Algebraic Structures by Means
of Program Properties, Fundamenta Informaticae 4, 661-674.
Bergstra, J., Tiuryn J. (1981b), Algorithmic Degrees of Algebraic Structures, Fun
damenta Informaticae 4, 851-863.
Bergstra J., Tucker J. V. (1982), The Refinement of Specifications and the Stability
of Hoare’s Logic, in: Logics o f programs 1981 (D. Kozen ed.), LNCS 131, Sprin
ger Verlag, Berlin, 24-36.
Bergstra J., Tucker J. V., (1984) Hoare’s Logic for Programming Languages with
Two Data Types, TCS 28, 215-222.
358 BIBLIOGRAPHY
Kotov V. E. (1978), An Algebra for Parallelism Based on Petri Nets, in: Proc.
MFCS'78 (J. Winkowski ed.), LNCS 64, Springer Verlag, 39-56.
Kozen D. (1980), A Representation Theorem for Models of *-Free PDL, in: Proc.
7th ICALP (J. de Bakker, J. van Leeuwen eds.), LNCS 85, Springer Verlag, Ber
lin, 351-362.
Kozen D. (1981), On the Duality of Dynamic Algebras and Kripke Models in Logics
of Programs (E. Engeler ed.), LNCS 125, Springer Verlag, Berlin, 1-11.
Kozen D., Parikh R. (1981b), An Elementary Completeness Proof for PDL, TCS 14,
113-118.
Kozen D. (1982), On Induction Versus—Continuity in Logics of Programs, in: Proc.
Logics o f Programs 1981 (D. Kozen ed.), LNCS 131, Springer Verlag, Berlin,
167-176.
Krause M., Kreczmar A., Langmaack H., Salwicki A. (1984), Specification and Imple
mentation Problems o f Programming Languages Proper for Hierarchical Data
Types, Raport no. 8410, Institut fur Informatik Christian Albrecht Universitat Kiel.
Kreczmar A. (1972), Degree of Recursive Unsolvability of Algorithmic Logic, Bull.
PAS 20, 615-617.
Kreczmar A. (1974), Effectivity Problems of Algorithmic Logic, in: ICALP'74
(J. Loeckx ed.), LNCS 14, Springer Verlag, Berlin, 584-600.
Kreczmar A. (1977), Effectivity Problems of Algorithmic Logic, Fundamenta In-
formaticae 1, 19-32.
Kreczmar A. (1977b), Programmability in fields, Fundamenta Informaticae 1, 195-230.
Kreczmar A., Miildner T. (1983), Coroutines and Processes in Block Structured
Languages, in: Proc. 6 GIDortmund, Jan. 1983, LNCS 145, Springer Verlag, Berlin,
231-243.
Kroger F. (1976), Logical Rules for Natural Reasoning about Programs, in: ICALP'76
(S. Michaelson, R. Milner eds.), Edinburgh, 87-98.
Kroger F. (1977), A Logic of Algorithmic Reasoning, Acta Informatica 8, 243-266.
Kroger F. (1978), A Uniform Logical Basis for the Description, Specification and
Verification of Programs, in : Formal Description o f Programming Concepts
(E. J. Neuhold ed.), North Holland, Amsterdam, 441-459.,
Kuratowski K., Mostowski A. (1967), Set Theory, North Holland, Amsterdam,
PWN, Warsaw.
Lamport L. (1980), “Sometimes” is sometimes “not never”, in: Proc. 7th A C M PO P L,
Las Vegas, 174-185.
Lamport L. (1984), Using Time instead of Timeout for Foult Tolerant Distributed
Systems, TOPLAS 6, 254-280.
Lamport L., Scheider F. (1984), The “Hoare Logic” of CSP and All That, TOPLAS 6,
281-295.
Langmaack H. (1979); On Termination Problems for Finitely Interpreted ALGOL-like
Programs, Rep. 7904, Institut fur Informatik und Praktische Mathematik,
Christian Albrechts Universitat Kiel, Sept. 1979.
Langmaack H. (1982), On Termination Problems for Finitely Interpreted ALGOL-
-like Programs, Acta Informatica 18, 79-108.
Lipton R. J. (1977), A Necessary and Sufficient Condition for the Existence of Hoare
Logics, in: Proc. 18th FOCS'77.
BIBLIOGRAPHY 363
Mirkowska G. (1980b), Model Existence Theorem for Algorithmic Logic with Non-
deterministic Programs, Fundamenta Informaticae 3, 157-170.
Mirkowska G. (1980c), Complete Axiomatization of Algorithmic Properties of Pro
gram Schemes with Bounded Non-deterministic Interpretations, in: Proc. 12th
STOC, Los Angeles 1980, 14-21.
Mirkowska G. (1981), PAL-Propositional Algorithmic Logic, in: Logics o f Pro
grams, Zurich 1979 (E. Engeler ed.), LNCS 125, Springer Verlag, Berlin, 12-22,
Fundamenta Informaticae 4, 675-757.
Mirkowska G. (1982), The Representation Theorem for Algorithmic Algebras,
in: Proc. Logics of Programs, Yorktown Heights 1981 (D. Kozen ed.), LNCS 131,
Springer Verlag, Berlin, 300-310.
Mirkowska G. (1983), On the Algorithmic Theory of Arithmetic, in: Proc. Logics
o f Programs and Their Applications, Poznan 1980 (A. Salwicki ed.), LNCS 148,
Springer Verlag, Berlin, 166-185.
Mostowski A. (1948), Mathematical Logic (in Polish), Mathematical Monographs
Series, no 18, Warszawa—Wroclaw.
Miildner T., Salwicki A. (1978), Computational Processes Generated by Programs
with Recursive Procedures and Block Structures, Fundamenta Informaticae 1,
305-323.
Miildner T. (1981), On the Synchronizing Tools for Parallel Programs, Fundamenta
Informaticae 4, 95-134.
Miildner T. (1981b), On Semantics of Parallel Programs, Fundamenta Informaticae 4,
35-82.
Naur P. (1966), Proof of Algorithms by General Snapshots, BIT 6, 310-316.
Nemeti I. (1982), Non-standard Dynamic Logic, in: Proc. Logics o f Programs, York
town Heights 1981 (D. Kozen ed.), LNCS 131, Springer Verlag, Berlin, 311-348.
Nemeti I. (1983), Non-standard Runs of Floyd-Provable Programs, in : Proc. Logics
o f Programs and Their Applications, LOGLAN 77, Poznan 1980 (A. Salwicki ed.),
LNCS 148, Springer Verlag, Berlin, 186-204.
Nishimura H. (1979), Sequential Method in Propositional Dynamic Logic, Acta
Informatica 12, 377-400.
Nishimura H. (1980), Descriptively Complete Process Logic, Acta Informatica 14,
359-369.
O’Donnell M. J. (1982), A Critique of the Foundations of Hoare-Style Programming
Logics, in: Proc. Logics o f Programs 1981 (D. Kozen ed.), LNCS 131, Springer
Verlag, Berlin, 349-374.
Oktaba H. (1981), Formalization o f the Notion o f Reference and Its Applications
in Theory o f Data Structures (in Polish), Doct. Diss., Univ. of Warsaw.
Orlowska E. (1983), Program Logic with Quantifiable Propositional Variables,
in: Proc. Logics o f Programs and Their Applications, Poznan 1980 (A. Salwicki
ed.), LNCS 148, Springer Verlag, Berlin, 205-212.
Owicki S., Gries D. (1976), Verifying Properties of Parallel Programs: An Axio
matic Approach, CACM 19, No 5, 279-285.
Parikh R. (1978), A Completeness Result for PDL, in: Proc. MFCS'78 (J. Win-
kowski ed.), LNCS 64, Springer Verlag, Berlin, 403-416.
BIBLIOGRAPHY 365
Reif H. J. (1980b), Logics for Probabilistic Programming, in: Proc. 12th STOC,
Los Angeles, 8-13.
Reiterman J., Trnkova V. (1980), Dynamic Algebras which are not Kripke Struc
tures, in: Proc, MFCS'80 (P. Dembinski ed.), LNCS 88, Springer Verlag, Berlin,
528-538.
Rice H. G. (1954), Recursive Real Numbers, Proc. Amer. Math. Soc. 5, 784-791.
Rogers H., Jr. (1967), Theory o f Recursive Functions and Effective Computability,
McGraw-Hill, New York.
Salwicki A. (1970), Formalized Algorithmic Languages. Bull. PAS 18, 227-232.
Salwicki A. (1975), Procedures, Formal Computations and Models, in: Proc. MFCS'74
(A. Blikle ed.), LNCS 28, Springer Verlag, Berlin, 464-484.
Salwicki A. (1977), Applied Algorithmic Logic, in: Proc. MFCS'77, (J. Gruska ed.),
LNCS 53, Springer Verlag, Berlin, 122-134.
Salwicki A. (1977b); An Algorithmic Approach to Set Theory, in: Proc. FCT'77
(M. Karpinski ed.), LNCS 56, Springer Verlag, Berlin, 499-510.
Salwicki A. (1977c), Algorithmic Logic, a Tool for Investigation of Programs, in:
Logic, Foundations o f Mathematics and Computability Theory, Part One o f the
Proceedings o f the Fifth International Congress o f Logic, Methodology and Philo
sophy o f Science, London, Ontario, 1975 (R. E. Butts, J. Hintikka eds.), D. Reidel
Publ., Dordrecht, 281-295.
Salwicki A. (1980), On Algorithmic Theory of Stacks, Fundamenta Informaticae 3,
311-332.
Salwicki A. (1981), On the Algorithmic Theory of Dictionaries, in: Logics o f Pro
grams, Zurich 1979 (E. Engeler ed.), LNCS 125, Springer Verlag, Berlin, 145-168.
Salwicki A., Muldner T. (1981b), On the Algorithmic Properties of Concurrent
Programs, in: Logics o f Programs, Zurich 1979 (E. Engeler ed.), LNCS 125, Sprin
ger Verlag, Berlin, 169-197.
Salwicki A. (1982), Algorithmic Theories of Data Structures, in: Proc. ICALP'82
Aarhus (M. Nielsen, E. Schmidt eds.), LNCS 140, Springer Verlag, Berlin, 458-472.
Salwicki A. (1982b), Critical Remarks on MAX Model of Concurrency, in: Proc.
Logics o f Programs, Yorktown Heights 1981 (D. Kozen ed.), LNCS 131, Springer
Verlag, Berlin, 397-405.
Scott D. (1970), Outline o f a Mathematical Theory o f Computation, Oxford Mono
graphs PRG-2, Oxford University Press.
Scott O. (1976), Data Types as Lattices, SIAM J. Comput. 5, 522-587.
Scott D. (1982), Domains For Denotational Semantics, in: Proc. ICALP'82, Aarhus
(M. Nielsen, E. Schmidt eds.), LNCS 140, Springer Verlag, Berlin, 577-613.
Scott D., Strachey C. (1971), Towards a Mathematical Semantics for Computer
Languages, Technical Monograph PRG 6, Oxford University.
Segerberg K. (1982), A Completeness Theorem in the Modal Logic of Programs,
in: Universal Algebra and Applications (T. Traczyk ed.), PWN, Warszawa, 31-46.
Shepherdson J. C., Sturgis H. E. (1963), Computability of Recursive Functions,
JACM 10, 217-255.
Shoenfield J. R. (1967), Mathematical Logic, Addison-Wesley, Reading, Massa
chusetts.
BIBLIOGRAPHY 367
Skowron A. (1983), Concurrent Programs, in: Proc. Logics o f Programs and Their
Applications, Poznan 1980 (A. Salwicki ed.), LNCS 148, Springer Verlag, 258-270.
Skowron A., Radev S., Vakarelov D. (1980), Propositional Computational Logic,
Reports o f the Institute o f Computer Science o f the Polish Academy o f Sciences,
no. 411, Warsaw, 64-66.
Spitzen J., Wegbreit B. (1975), The Verification and Synthesis of Data Structures,
Acta Informatica 4.
Szczerba L. W. (1977), interpretability of Elementary Theories, in: Logic, Foun
dations o f Mathematics and Computability Theory, Part One o f the Proceedings
of the Fifth International Congress o f Logie, Methodology and Philosophy o f Science,
London, Ontario 1975 (R. E. Butts, J. Hintikka eds.), D. Reidel, Dordrecht.
Thiele H. (1966), Wissenschaftstheoretische Unitersuchungen in algor ithmischen Spra-
chen. VEB Deutscher Verlag der WissenschaLen, Berlin.
Tiuryn J. (1981), Unbounded Program Memory Adds to Expressive Power of First-
-Order Dynamic Logic, in: Proc. 22nd FOCS'81, Nashville, 335-339.
Tiuryn J, (1981b), Logic of Effective Definitions, Fundamenta Informaticae 4, 629-660.
Tiuryn J. (1981c), A Survey of the Logic of Effective Definitions, in: Logics o f Pro
grams 1979 (E. Engeler ed.), LNCS 125, Springer Verlag Berlin, 198-245.
Trakhtenbrot B. A. (1979), On Relaxation Rules in Algorithmic Logic, in: Proc.
MFCS'19 (J. Becvar ed.), LNCS 74, Springer Verlag, Berlin, 453-462.
Urzyczyn P. (1981), Algorithmically Triviality of Abstract Structures, Fundamenta
Informaticae 4, 819-849.
Urzyczyn P. (1982), On the Unwinding of Flow-Charts with Stacks, Fundamenta
Informaticae 4, 119-126.
Vakarelov D. (1982), Reduction o f Dynamic Logic to Modal Logic, manuscript.
Vakarelov D. (1983), Filtration Theorem for Dynamic Algebras with Tests and In
verse Operator, in: Proc. Logics o f Programs and Their Applications, Poznan 1980
(A. Salwicki ed.), LNCS 148, Springer Verlag, Berlin, 314-324.
Valiev M. K. (1979), On Axiomatization of Deterministic Propositional Dynamic
Logic, in: Proc. MFCS'79 (J. Becvar ed.), LNCS 74, Springer Verlag, Berlin,
482-491.
Valiev M. K. (1980), Decision Complexity of Variants of Propositional Dynamic
Logic, in: Proc. MFCS'80 (P. Dembinski ed.), LNCS 88, Springer Verlag, Berlin,
656-664.
Valiev M. K. (1983), On Axiomatization of Process Logic, in: Proc. Logics o f Pro
grams and Their Applications, Poznan 1980 (A. Salwicki ed.), LNCS 148, Springer
Verlag, Berlin, 304-313.
Vaught R. L. (1973), Some Aspects of the Theory of Models, Amer. Math. Monthly 80,
3-37.
Wand M. (1978), A New Incompleteness Result for Hoare’s Systems, JACM 25,
168-175.
Wegbreit B. (1976), Verifying Program Performance, JACM 23, 691-700.
Winklmann K. (1977), Equivalence o /D L and DL+ for Regular Programs without
Array Assignments but with DL-Formulas in Tests, Manuscript, Lab. for Comp.
Sci. MIT, Dec. 1977.
368 BIBLIOGRAPHY
18, cc(x) ~ a (x )
216 u —y u^ y
351 y m(v) = 0 y<n(v) = 1
6718 M ({x := y) <x=>p) (M ((x := y )a ) => 0 )
C2%
679 v' = Mw(v)
II
91,o, 91g M ' ol M ' P
263s = = v'fei)
11a
ii
£
282,6 ~ (3 * )a (x ) ~ (3 x ) ~ a ( »
3292 / = none 7 V none
3307 s = allfree s ^ allfree
330® f t = newfr(s') / := newfr(s')
In parts o f the text concerning the Boolean algebra the signs v , a , =>, should be re
placed by u , n , - respectively.
Grazyna Mirkowska
Institute of Mathematics, University of Warsaw
"■nd
Andrzej Salwicki
Institute of Informatics, University of Warsaw
The aim o f algorithmic logic (AL) is the study o f the semantic properties o f com
puter programs. AL plays, for computer science, a role similar to that played by
mathematical logic in mathematics. AL studies those properties of programs which
are valid by virtue o f their syntactical structure, independently of any interpreta
tion of functional symbols in programs. This leads to the discovery of algorithmic
tautologies and inference rules enabling algorithmic reasoning. AL is a base for
various algorithmic theories of data structures. The significance o f AL lies in its
applications in: specifications o f systems; verification (analysis) o f programs; and
axiomatic definitions o f semantics o f programming languages. The results and
methods o f AL have numerous applications in software engineering (e.g. in seman
tic problems o f _AN programming language and in systems created in
LOG LAN).
The book offers an original, uniform view on the subject^ studied also in: logics of
partial correctness o f programs, dynamic logic, abstract data types, semantics of
concurrency and denotational semantics.
ISBN 90-277-1928-4