Table Of ContentEATCS
Monographs on Theoretical Computer Science
Volume 24
Editors: W. Brauer G.Rozenberg A.Salomaa
Advisory Board: G.Ausiello M.Broy S.Even
J.Hartmanis N.Jones T.Leighton M.Nivat
C.Papadimitriou D.Scott
Tamäs Gergely LäszlöÜry
First-Order
Programming Theories
With 10 Figures
Springer-Verlag Berlin Heidelberg GmbH
Authors
Prof. Dr. Tamäs Gergely
Applied Logic Laboratory
P. O. Box 675,1539 Budapest ,Hungary
Dr.Läszlö Üry
Applied Logic Laboratory
P. O. Box 675,1539 Budapest, Hungary
Editors
Prof. Dr. Wilfried Brauer
Institut für Informatik, Technische Universität München
Arcisstrasse 21, D-8000 München 2, FRG
Prof. Dr. Grzegorz Rozenberg
Institute of Applied Mathematics and Computer Science
University of Leiden, Niels-Bohr-Weg 1, P. 0. Box 9512
NL-2300 RA Leiden, The Netherlands
Prof. Dr. Arto Salomaa
Department of Mathematics, University of Turku
SF-20500 Turku 50, Finland
ISBN 978-3-642-63503-8 ISBN 978-3-642-58205-9 (eBook)
DOI 10.1007/978-3-642-58205-9
Library of Congress Cataloging-in-Publication Data
Gergely, T. (Tamäs)
First-order programming theories / by Tamäs Gergely and Laszlö Üry. p. cm. - (EATS mono
graphs on theoretical computer science: v. 24) Includes bibliographical references and index.
1. Electronic digital computers - Programming. I. Üry, Läszlö, 1953- . II. Title III. Series.
QA76.6.G4744 1991 005.1-dc20 91-27370
This work is subject to copyright. All rights are reserved, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations,
recitation, broadcasting, reproduction on microfilm or in any other way, and storage in data
banks. Duplication of this publication or parts thereof is permitted only under the provisions
of the German Copyright Law of September 9,1965, in its current version, and a permission
for use must always be obtained from Springer-Verlag. Violations are liable for prosecution
under the German Copyright Law.
© Springer-Verlag Berlin Heidelberg 1991
Softcover reprint of the hardcover 1st edition 1991
The use of general descriptive names, registered names, trademarks, etc. in this publication
does not imply, even in the absence of a specific statement, that such names are exempt from
the relevant protective laws and regulations and therefore free for general use.
Data coversion by authors
45/3140 - 543210 - Printed on acid-free paper
Preface
This work presents a purely classical first-order logical approach to the field of
study in theoretical computer science sometimes referred to as the theory of
programs, or programming theory.
This field essentially attempts to provide a precise mathematical basis for
the common activities involved in reasoning about computer programs and
programming languages, and it also attempts to find practical applications
in the areas of program specification, verification and programming language
design.
Many different approaches with different mathematical frameworks have
been proposed as a basis for programming theory. They differ in the mathe
matical machinery they use to define and investigate programs and program
properties and they also differ in the concepts they deal with to understand
the programming paradigm.
Different approaches use different tools and viewpoints to characterize the
data environment of programs. Most of the approaches are related to mathe
matical logic and they provide their own logic. These logics, however, are very
eclectic since they use special entities to reflect a special world of programs,
and also, they are usually incomparable with each other.
This Babel's mess irritatedus and we decided to peel offthe eclectic com
ponents and try to answer all the questions by using classical first-order logic.
In our opinion, this is the logic even programmers and pragmatically oriented
peoplearefamiliar with, and ifthis logic becomes appropriate to serve as a ba
sis for programming theory, then this theory will satisfy the requirement that
it speak about the world under consideration as simply as Possi9le.
This work reflects our journey from the eclectic programming logics to
the simple classical first-order logic, which furthermore turned out to be more
powerful than the non-classical ones.
Putting this long journey into a book we had B. Mahr's full support and
encouragement, for which we would like to thank him. We also acknowledge
Springer-Verlag for their kind, willing and supportive cooperation and the
unknown referees for their invaluable comments on our book. We are espe
cially grateful to J. A. Ross, Copy Editor, for his scrupulous inspection ofthe
manuscript and whose work hopefully led to a smooth reading ofthis book.
VI Preface
We are indebted to H. Andreka, I. Nemeti and I. Sain for our fruitful
discussions of the subject in the past sixteen years. Special thanks go to our
colleagues M. Erdelyi-Szab6, A. Juhos, A. Kurucz and M. Szots at the Ap
plied Logic Laboratory, Budapest for their helpful comments and criticisms on
reading thepenultimateversionofourmanuscript. Finally, we thank ourwives
Lydia and Agnes for their support and passionate involvement in bringing our
book to this final shape.
Budapest, August 1991 Tamas Gergely, Laszlo Dry
Contents
Introduction 1
Mathematical Background
1. Logic and Model Theory 15
1.1 Basic Mathematical Notions 15
1.2 Derivation Systems 18
1.3 Basic Notions ofMany-Sorted First-Order Language 21
1.4 Relations in Many-Sorted Structures 28
1.5 Ultraproducts 29
1.6 Arithmetic 30
2. Inductive Deflnability 37
Part I
Computability
3. Introduction to Part I 49
4. Main Properties ofProgram Schemas 53
4.1 Basic Definitions ofProgram Schemas 54
4.2 Flowchart Schemas 58
4.3 Main Properties ofO"-type Programs 63
4.4 Canonical Form ofPrograms 70
5. Extension ofProgram Schemas 77
5.1 Main Properties ofExtensions 78
5.2 Set Extension 84
5.3 Halting Problem for Extensions 88
6. Program Schemas with Stacks 91
6.1 On the Number ofStacks 91
6.2 Deterministic Programming Languages 99
7. Computability 103
7.1 Computability on First-Order Structures 103
7.2 Church's Thesis 112
8. On Inductive Deflnability of1- and 2-Computable Relations 119
8.1 Logical Characterization of I-Computable Relations 120
8.2 On the Role of Natural Numbers 127
VIn Contents
Part II
Extended Dynamic Logics
9. Introduction to Part II 135
10. Description ofProgram Properties 139
11. Den-based Descriptive Languages 143
12. The ProblemofCompleteness 155
12.1 Incompleteness Results 156
12.2 On Restricted Partial Correctness Theories 161
12.3 Den-Completeness 165
13. Dynamic Logic Generated by Extension 171
14. Continuous Denotational Semantics 179
14.1 Transitive Extension 180
14.2 Non-standard Dynamic Logic 193
14.3 Axiomatic Calculus for the Extended Dynamic Logic 202
14.4 On Program Equivalence 205
14.5 Constructing Transitive Extensions 206
15. Definable Denotational Semantics 211
Part III
Temporal Characterization of Programs
16. Introduction to Part III 229
17. Temporal Logic 233
18. Temporal Logical Description ofProgram Properties 239
19. Is Temporal Logic Expressible in Dynamic Logic? 243
20. Is Dynamic Logic Expressible in Temporal Logic? 247
21. The Case ofEnumerable Models 263
22. Temporal Axiomatization ofProgramVerification Methods 267
Part IV
Programming Logic with Explicit Time
23. Introduction to Part IV 285
24. Time Logic 289
24.1 Time Extension 289
24.2 On Regular Time Theories 292
25. Definability in Regular Time Theories 297
25.1 Finitary Fixed-Point Theory 298
25.2 Inductive Extensions Generated by Regular Theories 300
25.3 A Non-Finitary Fixed-Point Theory 305
26. Expressive Power ofTime 309
26.1 Embedding Temporal Logic 309
26.2 Embedding Transitive and Inductive Extensions 313
26.3 Description ofProgram Extensions 320
Contents IX
Epilogue 325
References 335
Notations , 341
Subject Index 347
Introduction
Progranuning Theory. The field ofstudy dealing with programs and program
ming languages in theoretical computer science is usually referred to as pro
gramming theory, or the theory of programs. This field essentially deals with
the formal investigation of the world of programs, including characterization
of programs, description of program properties and checking whether a given
program satisfies certainproperties. Inorder tosupport this investigation, pro
gramming theory attempts essentially to provide an appropriate mathematical
foundation. This theory alsoattempts toprovideappropriate, theoretically well
based methods and tools to support practical applications, e.g. in the field of
program specification and verification and also in program design and in pro
gramming language development.
Conditionally we can divide programming theory into two main subfields.
Programming languages and programs play the main role in the first subfield,
while in the second one the languages which describe program properties have
the leading role. We assign to the first area the research that aims to develop
formal tools for the characterization ofprogramming languages and programs
from different aspects. First of all we should provide appropriate formal tools
to define programs as formal objects. These tools consider programs from the
syntacticaspect. Thisaspectdealswiththe "how" specificationofprograms,i.e.
it analyses how a program is to be given, how it is constructed, howoptimalor
complex it is, etc. The programs, however, represent algorithms and areformal
objects of a special kind. Namely, beyond the syntactic aspect they have a
meaningconnectedwiththeirexecution. Executionofrealprogramstakesplace
in real computers and results in changes in the contents of the storage units
(registers) ofthe computers, which, in turn, form the data environment ofthe
program under execution. Programming theory, however, deals with abstract
programminglanguagesand, accordingly, theexecutionofprogramstakesplace
inanappropriate "abstract" dataenvironment whichrepresents thecomputers.
Therefore, the semantics of a programming language is connected with
the characterization ofchanges caused by the program's execution in the data
environment. Thesemanticsofprogramminglanguagesdeals withquestionswe
may call "what"-questions, regarding what a program does or what properties
it has.
Having defined the program semantics we can investigate the computa
tional power ofa programming language. Moreover, it is an important task to
compare different programming languages with respect to their computational
2 Introduction
power. To carryout this task, theformal characterizationofprogramminglan
guages must be continued to the point where purely formal objects can be
introduced to replace programming languages.
The main problems the second subfield deals with are connected with the
selection ofprogram properties that are interesting from theoretical and prag
matical points of view. Having selected the interesting properties, a formal
language must be developed which facilitates the description of these proper
ties and theirinvestigation. Wealsorequireaformal calculusfor thedescriptive
language which allows us to prove whether the program to be considered pos
sesses any interesting properties.
MathematicalFramework.Programmingtheoryshouldpossessappropriatefor
mal methods and tools to deal successfully with the problems arising in both
subfields. Moreover, it would be desirable to have a mathematical foundation
which could provide a unique framework and view for both subfields. Differ
ent approaches with different mathematical frameworks have been proposed as
a basis for programming theory. They differ in the mathematical machinery
they use to define and investigate programs and program properties and in the
concepts they use to understand the programming paradigm.
What mathematical framework will be adequate to characterize programs
and programming languages and to reason about them from both syntactic
and semantic perspectives? Mathematical logic iJ the only diJcipline which haJ
a well developed culture to deal with the Jyntax and JemanticJ ofJome formally
defined languageJ. However,inmathematicallogicthe meaningofa formal sen
tence is characterized by its interpretation in the appropriate models and by
analysing its validity with respect to these models. Logic systems by nature
are Jtatic, while the meaningofalgorithms and so ofprograms connected with
execution require dynamic consideration. Therefore, if we intend to use logic
for developing a programming theory we have to find a solution for this con
tradictory situation which provides appropriate logical tools to represent the
dynamic aspect ofprograms, namely their execution. While we are looking for
the required solution the following questions about the handling of program
meaning should be answered:
• What does a logic formulation characterize if it speaks about program
execution?
• What computationprocessesappearintheselectedlogicduringtheformal
characterization?
• Does program execution coincide with these computational processes?
Thesequestionsshould beansweredwhile dealingwith thefirst subfieldof
programming theory when we intend to represent and characterize programs
in the scope of mathematical logic and to develop a corresponding theory of
computation. Ofcourse,consideringthesecondsubfieldofprogrammingtheory,
above all program properties should be selected which are interesting from a
theoretical or pragmatic point ofview, and an appropriate language should be
developed to describe and, possibly, to prove them. Ifwe wish to develop this