Top Banner

Click here to load reader

Formal definitions of programming languages as a · PDF fileFormal definitions of programming languages as a basis ... On formal definitions of programming languages 8 ... Derivation

Aug 28, 2018

ReportDownload

Documents

trinhphuc

  • Formal definitions of programming languages as a basisfor compiler constructionHemerik, C.

    DOI:10.6100/IR55705

    Published: 01/01/1984

    Document VersionPublishers PDF, also known as Version of Record (includes final page, issue and volume numbers)

    Please check the document version of this publication:

    A submitted manuscript is the author's version of the article upon submission and before peer-review. There can be important differencesbetween the submitted version and the official published version of record. People interested in the research are advised to contact theauthor for the final version of the publication, or visit the DOI to the publisher's website. The final author version and the galley proof are versions of the publication after peer review. The final published version features the final layout of the paper including the volume, issue and page numbers.

    Link to publication

    General rightsCopyright and moral rights for the publications made accessible in the public portal are retained by the authors and/or other copyright ownersand it is a condition of accessing publications that users recognise and abide by the legal requirements associated with these rights.

    Users may download and print one copy of any publication from the public portal for the purpose of private study or research. You may not further distribute the material or use it for any profit-making activity or commercial gain You may freely distribute the URL identifying the publication in the public portal ?

    Take down policyIf you believe that this document breaches copyright please contact us providing details, and we will remove access to the work immediatelyand investigate your claim.

    Download date: 28. Aug. 2018

    https://doi.org/10.6100/IR55705https://research.tue.nl/en/publications/formal-definitions-of-programming-languages-as-a-basis-for-compiler-construction(ced9de3f-9d2b-4289-9691-52b47e715452).html

  • FORMAL DEFINITIONS OF PROGRAMMING LANGUAGES

    AS A BASIS FOR COMPILER CONSTRUCTION

    C. HEMERIK

  • FORMAL DEFINITIONS OF PROGRAMMING LANGUAGES

    AS A BASIS FOR COMPILER CONSTRUCTION

  • Druk: Dissertatie Drukkerij Wibro, Helmond. Telefoon .04920-23981.

  • FORMAL DEFINITIONS OF PROGRAMMING LANGUAGES

    AS A BASIS FOR COMPILER CONSTRUCTION

    PROEFSCHRIFT

    TER VERKRIJGING VAN DE GRAAD VAN DOCTOR IN DE

    TECHNISCHE WETENSCHAPPEN AAN DE TECHNISCHE

    HOGESCHOOL EINDHOVEN, OP GEZAG VAN DE RECTOR

    MAGNIFICUS, PROF.DR. S.T.M. ACKERMANS, VOOR

    EEN COMMISSIE AANGEWEZEN DOOR HET COLLEGE

    VAN DEKANEN IN HET OPENBAAR TE VERDEDIGEN OP

    DINSDAG 15 MEI 1984 TE 16.00 UUR

    DOOR

    CORNELIS HEMERI K

    GEBOREN TE LEIDEN

  • Dit proefschrift is goedgekeurd

    door de promotoren

    prof.dr. F.E.J. Kruseman Aretz

    en

    prof. dr. E.W. Dijkstra

  • CONTENTS

    0. Introduetion

    0. I. Background

    0.2. Subject of the thesis 3

    0.3. Some notational conventions 6

    I. On formal definitions of programming languages 8

    2. Formal syntax and the kernel language 13

    2.0. Introduetion 13

    2.1. Context-free grammars 14

    2.1.1. Definition of context-free grammar and related notions 14

    2.1.2. Presentation 16

    2.1.3. Implementation concerns 18

    2.2. Attribute grammars 21

    2.2.0. Introduetion 21

    2.2.1. Definition of attribute grammar and related notions 23

    2.2.2. Presentation 30

    2.2.3. Example: Satisfiable Boolean Expressions 32

    2.2.4. Implementation concerns 37

    2.3. Formal syntax of the kernel language 40

    2.3.1. A context-free grammar for the kernel language 40

    2.3.2. An attribute grammar for the kernel language 43

    3. Predicate transfarmer semantics for the kernel language 50

    3.0. Introduetion 50

    3.1. Some lattice theory 54

    3.1.1. General definitions 54

    3.1.2. Strictness 60

    3.1.3. Monotoniity 61

    3.1.4. Conjunctivity and disjunctivity 62

    3.1.5. Continuity 63

    3.1.6. Fixed points 70

    3.1.7. Fixed point induction 72

  • 3.2. The condition transfermers wp and wlp 74

    3.2.0. Introduetion 74

    3. 2. I. Conditions 75

    3.2.2. The logic D 79

    3.2.3. The ccl's of conditions and condition transfermers 82

    3.2.4. Definitions and some properties of wp and wlp 84,

    3.3. Logies for partial and total correctness 100

    4. Blocks and procedures

    4.0. Introduetion 107

    4.1. Blocks 109

    4.1.0. Introduetion 109

    4. l.I. Blocks without redeclaration 109

    4.1.2. Substitution in statements 114

    4.1.3. Blocks with the possibility of redeclaration 117

    4.1.4. Proof rules 118

    4.2. Abstraction and application 121

    4.2.0. Introduetion 121

    4. 2. I. Syntax 121

    4.2.2. Semantics 124

    4.2.3. Proof rules 126

    4.3. Parameterless recursive procedures 131

    4.3.0. Introduetion 131

    4.3. I. Semantics 131

    4.3.2. Proof rules 140

    4.3.2.1. Proof rules for partial correctness 141

    4.3.2.2. Proof rules for total correctness 144

    4.3.2.3. A note on the induction rules and their proofs 148

    4.4. Recursive procedures with parameters 150

    4.4.0. Introduetion 150

    4.4. I. Syntax 150

    4.4.2. Semantics 153

    4.4.3. Proof rules 157

    4.4.3.1. Proof rules for partial correctness 157

    4.4.3.2. Proof rules for total correctness 163

  • 5. Some aspeets of the definition of the target language

    5.0. Introduetion

    5. I. Informal deseription of TL

    5.2. Version I : Condition transfarmer semantics of TL

    5.3. Version 2: Introduetion of program store

    5.4. Version 3: Introduetion of return stack

    5.5. Version 4: Derivation of an interprete.r

    6. Epilogue

    Appendix A. Proofs of some lemmas

    Appendix B. Collected definition of the souree language

    Index of definitions

    References

    Samenvatting

    Curriculum vitae

    167

    167

    169

    17 I

    182

    185

    188

    193

    195

    199

    212

    215

    220

    223

  • 0. I Background

    CHAPTER 0

    INTRODUClON

    I

    In order to place the subject of this thesis in the proper perspective we

    shall first devote a few words to the research project of which it is a part.

    The aim of the latter project is the systematic construction of correct

    compilers based on formal definitions of both souree and' target language.

    Let us make this more precise:

    If we want to construct a compiler from a souree language SL to a target

    language TL we have to take into account at least the following aspects:

    1. The definition of SL.

    2. The definition of TL.

    3. The construction of a "meaning preserving" mapping from SL to TL.

    4. The construction of a program that realizes that mapping.

    To a mathematically inclined person the dependencies between these aspects

    are obvious: 3 depends on I and 2, and the specifications used in 4 are

    based on 3. It is also clear that the correctness concerns of 3 and 4 can

    be separated and that the reliability of the resulting compiler ultimately

    depends on the rigour of I and 2. In practice, mainly due to bistorical

    causes, the situation is different.however:

    Compiler construction is a relatively old branch of computing science~

    whereas the mathematica! theory of programming and programming lan-

    guages bas not matured until the last decade. Consequently the formal-

    ization of many programming concepts has lagged far bebind their

    implementation. To implementers (and many others) the operational view

    still prevails and formal definitions have been considered, in the

    terminology of [Ashcroft], descriptive rather than prescriptive.

    The few research efforts in compiler correctness have concentrated on

    formal roodels of translatars that have been used in elaborate proofs

    of completely trivial language mappings. Attention has been paid to

  • 2.

    correctness proofs of given mappings rather than to the construction

    of correct mappings. Moreover, the conneetion between such an abstract

    mapping and a concrete compiler has not always been clear.

    At present compiler construction often proceeds by the construction of

    a parser which is subsequently augmented with various symbol table

    manipulation and code generation routines. Thus the language mapping

    realized by such a compiler is only specified implicitly. Explicit

    compiler specifications are rare and as a consequence the programming

    discipline where program and correctness proof are developed hand in

    hand is seldom applied to compilers.

    We are convineed that at present forml language theory and programming

    methodology have developed sufficiently to make an intellectually more

    satisfying approach to compiler construction feasible. To turn that convic-

    tion into fact we have set as our goal the construction of a compiler along

    the lines of points 1-4 above. More specifically, this includes the follow-

    ing tasks:

    Design and formal definition of a souree language SL and a target

    language TL. This task involves the development of formal definition

    methods to the extent that languages can be defined completely, i.e.

    that both language-theoretical results, implementations, and program-

    mer-oriented aspects such as proof rules may be derived from the

    formal definition.

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.