Vo (LI..

;'.1

e ::.C-

**Brian Cantwell Smith
**

B.S., Massachusetts Institule ofTechnology (1914) M.S., Massachusetts Institute ofTechnology (1978)

Submitted in partial fulfillment

**of the requireme'nts for the Degree of Doctor ofPhilosophy
**

at the

**Massachusetts Institute ofTcchnology
**

Febnlary 1982

©

Massachusetts Institute ofTechnology 1982

**Signatu~ofAutllor ~~~~~~~~~_~~_.~_.~~_~~~,_~~~~~~~~~~~
**

Department of [~lcctrical Engineering an

Ccrti!icd by

~

Eng.

MASSACHUSETTS INSTITUTE

**Peter Szolovits 11lcsis Sl..pervisor
**

Arthur C. Smith Chainnan, Departmental Graduate Committee

Accepted by

OF TECHNOLOGY

MAY 201982

LIBRARIES

Preliminaries

Procedural Reflection

2

Abstract

We show how a computational system can be constructed to "reason", effectively and consequentially, about its own inferential processes. l11C analysis proceeds in two parts. First, we consider the general question of cOlnputational selnantics, rejecting traditional approaches, and arguing tllat the declarative and procedural aspects of computational symbols (what they stand ~or, and what behaviour they engender) should be analysed independently, in order that they may be coherently related. Second, we investigate selfreferelllial behaviour in cOlnputational processes, and SllOW how to clnbed an effective procedural model of a computativnal calculus within tllat calculus (a Inodcl not unlike a Illeta-circular interpreter, but connected to the fundamental operations of the machine in such a way as to provide, at any point in a computation, fully articulated descriptions of the state of that computation, for inspection and possible modification). In tenns of tlle tllcOriCS that result from these investigations, we prescnt a general architecture for procedurally reflective processes, able to shift smoothly between dealing with a given subject domain, and dealing with their own reasoning processes over that domain. An instance of the general solution is worked out in the context of an applicative language. Specifically, we prescnt three successive dialects of LISP: 1-l1 SP, a distillation of current practice, for comparison purposes; 2-LISP, a dialect constructed in terms of our rationalised semantics, in which the concept of evaluation is rejected in favour of independent notio~s of silnplificatioll and reference, and in which 'lhe respective categoric~ of notation, stnlcture, semantics, and behaviour arc strictly aligned; and 3-LISP, an extension of 2-lISP endowed with reflective powers.

This research was supported (in part) by the National Institutes of llcalth Grant No. 1 POl I~M 03374 from the National l..lbrary of Medicine.

Preliminaries

Procedural Reflection

3

Extended Abstract

We show how a computational system can be constructed to "reason" effectively and consequentially about its o\vn inference processes. Our approach is to analyse selfreferential behc:viour in computational systems, and to propose a theory of procedural reflection that enables any programming language to be extended in such a way as to support programs able to access and manipulate structur31 descriptions of their own operations and structures. In particular, one must encode an explicit theory of such a system within the structures of the system, and then connect tllat theory to the fundamental operations of the system in such a v/ay as to support three primitive behaviours. First, at any point in the course of a computation fully articulated descriptions of the state of the r~asoning process must be available for inspection and modification. Second, it must be possible at any point to resume an arbitrary computation in accord with suel1 (possibly modified) theory-relative descriptions. Third, procedures that reason with descriptions of the processor state must themselves be subject to description und review, to arbitrary depth. Such reflective abilities allow a process to shift smootllly between dealing with a given subject domain, and dealing with its own reasoning processes over that domain. Crucial in the development of this theory is a comparison of the respective semantics of programming languages (such as LISP and ALGOL) and declarative languages (such as logic and the A-calculus); we argue that unifying these traditionally separate disciplines clarifies both, and suggests a simple and natural approach to the question of procedural reflection. More specifically, the scmantical analysis of computational systems should comprise independ~nt formulations of declarative inlporl (what SyDlbols stand for) and procedural consequence (what effects and results arc engendered by processing them), although the two scnlantical treatments may, because of side-effect interactions, have to be formulated in conjunction. When this approach is applied to a functional language it is shown that the traditional notion of evaluation is confusing and confused, and must be rejected in favour of independent notions of reference and Sil11plijicatioll. In addition, we defend a standard of category aliglllllent: tllcre should be a systematic correspondence between the respective categories of notation, abstract structure, declarative semantics, and procedural consequence (a mandate satisificd by no CX~1nt procedural formalisln). It is shown how a clarification of these pt;or sClTlantical and aestllctic issues enables a procedurally reflective dialect to be clearly defined and readily constructed. An instance of the general solution is worked Ollt in the context of an applicative language, where the question reduces to one of defining an interpreted calculus able to inspect and affect its own interpretation. In particular, we consider three successive dialects of LISP: I-lISP, a distillation of current practice for comparison purposes, 2-lISP, a dialect categorically and selllQlltically rationalised with respect to an explicit theory of declarative semantics for s-exprcssions, and 3-l.ISP, a derivative of 2-LISP endowed \vith fun reflective powers. I-LISP, like all LISP dialects in current usc, is at heart a first-order language, employing meta-syntactic facilities and dynamic variable scoping protocols to partially mimic higher-order functionality. 2-LISP, like SCHEr~E and the A-calculus, is higher-order: it supports arbitrary function designators in argument position, is lexically scoped, and treats

Preliminaries

Procedural Reflection

4

the function position of an application in a standard extensional manner. Unlike SCHEME, however, the 2-lJSP processor is based on a regimen of nomlalisatioll, taking each expression into a normal-form co-designator of its rcfcren~ where the notion of normal[unn is in part defined with respect to that referent's semantic type, not (as in the case of the A-calculus) solely in terms of the further non-applicability of a set of syntactic reduction rules. 2-LISP normal-fonn designators are environment-independent and side-effect free; thus the concept of a closure can be reconstructed as a normal-fonn junction designator. In addition, sinc~ normalisation is a form of simplification, and is therefore designationpreserving, meta-structural expressions are not dc-referenced upon nonnalisation, as they are when evaluated. TI1US we say that the 2- LISP processor is semantically j1a~ since it stays at a semantically fixed level (although explicit referencing and dc-referencing primitives arc also provided, to facilitate explicit level shifts). Finally, because of its category alignment, argulnent objectification (the ability to apply functions to a sequence of arguments designated collectively by a single tenn) can be treated in the 2-LISP base-level language, without requiring resort to meta-structural machinery. 3-LISP is straightforwardly defined as an extension of 2-lISP, with respect to an explicitly articulated procedural theory of 3-LISP embedded in 3-LISP structures. TIl is embedded theory. called the reflective lnodel, though superficially resembling a meta-circular interpreter, is causally connected to the work.ings of the underlying calculus :11 crucial and primitive ways. Specifically, reflective proce,1ures are supported that bind as arguments (designators of) the continuation and environment structure of the processor that would have been in effect at the moment the reflective procedure was called, had the machine been running all along in virtue of the explicit processing of that reflective nIode!. Because reflection may recursc arbitrarily, 3-LISP is most simply defined as an infinite tower of 3LISP processes, each engendering the process inlmediatcly below it. Under sue11 an account, the use of reflective procedures amounts to running programs at arbitrary levels in tllis reOcctive hierarchy. Both a straightforward implementation and a conceptual analysis are provided to denlonstrate that such a nlachine is nevertl1cless finite. The 3-LISP reflective nlodel unifies three programming language concepts that have formerly been viewed as independent: meta-circular interpreters, explicit natncs for the primitive interpretive procedures (EVAl and APPLY in standard LISP dialects), and procedures that access the state of the irnplemcntation (typically provided, as part of a programming environment, for debugging purposes). \Ve sho\v how all such behaviours can be defined within a pure version of 3-lISP (Le., independent of implementation). since all aspects of the state of any 3-LISP process arc available, with sufficient reflection, as objectified entities within the 3 -lISP structural field.

Preliminaries

Procedural Reflection

5

Summary Contents

Abstract Extended Abstract

Page 2

3

5 6

**Summary Contents Contents
**

Preface and Acknowledgements

10

Prologue

13

26

1.

2. 3.

Introduction

I-LISP: A Basis Dialect

103

122

253

Semantic Rationalisation

2- LIS P: A Rationalised Dialect

4.

5.

6.

Procedural Reflection and 3-LISP Conclusion

571

700 707

752

Appendix: A MACLISP Inlplcmentation of 3-l ISP Notes and References

Preliminaries

Procedural Reflection

6

Contents

Preliminaries

Abstract

Page

2

**Extended Abstract Summary Contents Contents Preface and Acknowledgments Prologue
**

Chapter 1. Introduction

2 3 5

6

10

13

26

**Introduction 1.a. General Overview I.b. The Concept ofReflection
**

l.b.i. The Reflection and Representation Hypotheses I.b.li. Reflection in Computational FonnaUsms l.b.iii. Six General Properties of Reflection l.b.iv. Reflection andSclf-Referen\:e A Process Reduction Model of Computation The Rationalisation of Computational Semantics 1.d.i. Pre-rTheoretic Assumptions l.d.ii. Semantics in a Computational Setting l.d.iii. Recursive and Compositional Fonnulations l.d.iv. The Ro!~ ofa Declarative Semantics Procedural Reflection l.e.i. A First Sketch I.cJL Meta-Circular Processors l.e.iii. Procedural Reflection Models 1.e.iv. Two Views of Reflection l.e.v. Some General Comments The Usc of IISP as an Explanatory Vehicle 1.f.i. I-LISP as a Distillation of Current Practice 1.t:ii. Tile Design Of2-lISP l.f.iii. 111C Procedurally Reflective 3-lISP 1.f.iv. Reconstruction Rather 11tao Design

26 27 35

35

38

42

l.c. l.d.

47 50 59 59

61

67 69 70 70 72 75

I.e.

18

80 82 83 86

l.f.

91 93

Preliminaries 1.g. Remarks l.g.i. Comparison with Other Work l.g.ii. The Mathematical Meta-Language l.g.iii. Examples and Implementation

1-LISP: A Basis Dialect Semantic Rationalisation

Procedural Reflection

7

95 95 101 102

Chapter 2. Chapter 3.

103 122

122 124 124 127 129

Introduction 3.a. The Semantics ofTraditional Systems 3.a.i. Logic 3.a.ii. The A-Calculus 3.a.iii. PROLOG 3.a.iv. CommolJcdities 3.b. The Semantics of Computational Calculi 3.b.L Standard Programming Language Semantics 3.b.ii. Declarative Semantics in LISP 3.bJii. Summary 3.c. Preparations for I-lISP and 1.7-LISP Semantics 3.c.i. Local and Full Procedural Consequence 3.c.ii. Declarative Semantics for Data Structures 3.c.iii. Recursive Compositionality, Extensionality, and Accessibility 3.c.iv. Structure vs. Notation 3.c.v. Context Relativity 3.c.vi. '1 erminology and Standard Models 3.c. vii. Declarative Semantics and Asscrtional Force 3.d. The Semantics of I-LISP: First Attempt 3.d.i. Declarative Selnantics (c) 3.d.ii. Local Procedural Semantics ('1') 3.d.iii. Full Procecuial Semantics (r) 3.c. The Semantics of I-LISP: Second Attempt 3.e.i. The Pervasive Influence of Evaluation 3.e.ii. The Temporal Context of Designation

**130 134 134 143 148
**

150 150 153 155

**158 160 166 168
**

170 111 190 199 205 205

3.f.

3.e.iii. ~"ull Computational Significance (~) 3.e.iv. An Example 3.e.v. 11le Evaluation Theorem Towards a Rationalised Design 3.fJ. Evaluation Considered Harmful 3.f.ii. Normal Fonn I)csignators 3.f.iii. L.cssons and Observations 3.f.iv. Declarative Inlport, Ilnplementation, and Dala Abstraction

207 211 218 225 228 230 237 243 246

Preliminaries

Chapter 4. 2-LISP: A Rationalised Dialect Introduction 4.a. The 2-LISP Structural Field 4.a.i. Numerals and Numbers 4.a.ii Booleans and Truth-values

4.a.iii Atoms

Procedural Reflection

8

253 253 257

257

259 260 261 265 286 291 292 297 298 301 302 314 321 330 335 342 350 356 360 377 377 393 401 412 427 461

4.b.

4.a.iv. Pairs and Reductions 4.a.v. Rails and Sequences 4.a. vi. Handles 4.a.vii. Category Summary 4.a.viii. Normal-fonn Designators 4.a.ix. Accessibility 4.a.x. Graphical Notation Simple 2-LISP Primitives 4.b.i. Arithmetic Primitives 4.b.ii. Selectors on Pairs 4.bJii. Typing and Identity 4.b.iv. Selectors on Rails and Sequences 4.b.v. The Creation of New Structure 4.b.vi. Vector Generalisations

4.b.vii. Structural Field Side Effects

4.c.

4.d.

4.b.viii. Input/Output 4.b.ix. Control Methods of Composition and Abstraction 4.c.i. Lambda Abstraction and Procedural Intension 4.c.ii. Closures: Normal FOIID Function Designators 4.c.iii. Patterns and Parameter Binding 4.c.iv. The Semantics of LAMBDA, EXPR, and IMPR 4.c.v. Recursion 4.c.vi. Environments and the Setting of Variables Meta-Structural Capabilities

4.d.i.

NAME

481

481

493 505 512

and REFERENT

4.e.

4.d.ii. NORMALISE and REDUCE 4.d.iii. Intensional Procedures 4.d.iv. The "Up-Down" Theorem 4.d.v. Macros and Dackquote 4.d.vi. The Normalisation ("Flat") and Type Theorems 4.d.vii. The 2-lISP Meta-Circular Processor Conclusion

522

544

550 565

Preliminaries

Chapter 5. Procedural Reflection and 3-LISP Introduction

5.a. The Architecture of Reflection

Procedural Reflection

9

571 571

576 576 583

595

5.a.i. S.a.ii. S.a.iii. 5.a.iv.

S.b.

The Limitations Of2-LISP

Some Untenable Proposals Reflective Code in the Processor Four Grades of Reflective Involvement

600

606 608 614

An Introduction to 3-LISP 5.b.i. Reflective Procedures and Reflective Levels

S.c.

S.d.

S.c.

Chapter 6.

Appendix.

S.b.ii. Some Elementary Examples 5.b.iii. LAMBDA, and Simple and Reflective Closures S.b.iv. The Structure of Environments S.b.v. Simple Debugging 5.b.vi. REFERENT 5.b.vii. The Conditional 5.b.viii. Review and Comparision with 2-lISP The Reflective Processor 5.c.i. The Integration of Reflective Procedures S.c.ii. The Treatment ofPrimitives S.c.iii. Levels of READ-NORMA lISE-PRINT 5.c.iv. Control Flow in the Reflective Processor S.c.v. The Implementation ora Reflective Dialect Reflection in Practice S.d.i. Continuations wi~ a Variable Number of Arguments 5.d.ii. Macros 5.d.iii. Pointers to Further Exmnples The Mathematical Characterisation of Reflection

621

626

633 638

641 645

648 649

652 656 661

671

679 679 688 695 699 700

Conclusion

A MACLISP Ilnplemcntation of 3-LISP

707 752 756

Notes References

Preliminaries

Procedural Reflection

10

Preface and Acknowledgements

**The possibility of constructing a reflective calculus first struck me in June 1976, at
**

the Xerox Palo Alto Research Center, where I was spending a summer ,'Vorking with the

KRL representation larlguage of Bobrow and Winograd. 1

As an exercise to learn th~

**language, I had embarked on the project cf representing KRL in KRl; it. seemed to me that
**

this "double-barrelled" approach, in which I would have both to use and to mention the

language, would be a particularly efficient way to unravel its intricacies.

Though that

exercise was ultimately abanc\oned, I stayed with it long enough to become intrigued by the th.Jught that one might build a system that' was self-descriptive in an important way (certainly in a way in which my KRl project was not). More specifically, I could dimly

envisage a computational system in which what happened took effect in virtue of

declarative descriptions of what was to happen, and in which the internal structural

**conditions were represented in declarative descriptions of those internal structural
**

conditions. In such a system a .program could with equal ease access all the basic operations and structures eithei directly or in terms of completely (and automatically)

articulated descriptions of them. The idea seemed to me rather simple (as it still does);

furthennore, for a variety of reasons· I thought that such. a reflective calculus could itseJfbe rather simple - in some important ways simpler than a non-reflective fonnatism (this too I still believe). Designing such a fonnalism, however, no longer seems as straightforward as I

thought at the time; this dissertation should be viewed as the first report emerging from tile

research project that ensued.

**Most of the five years since 1976 have been devoted to initial versions of my
**

specification of suell a language, called

MANTIQ,

**based on these original hunches.
**

.:1

As

mentioned in the first paragraph of chapter 1, there are various non-trivial goals that ,nust be met by the designer of any such formalism, including at least tentative solution to tlle

MANTIQ

knowledge representation problem. Furthcnnore, in the course of its development,

has come to rest on some additional hypotheses above and beyond those mentioned above (including, for example, a sense that it will be possible within a computational setting to construct a fonnaHsm in which syntactic identity and intensional identity can be identified,

given some appropriate, but independently specified, theory of intensionality).

Probably

Preliminaries

Procedural Reflection

11

**the major portion of my attention to date has focused on these intensional aspects of the
**

MANTIQ

**architecture. It was clear from the outset that no dialect of
**

LISP

**(or of any other purely
**

In February of 1981, would

procedural calculus) could serve as a full reflective fonnalism; purely declarative languages like logic or the A-calculus were dismissed for similar reason.<;. however, I decided that it would be worth focusing on

LISP,

**by way of an example, in
**

MANTIQ

order to work out the details of a specific subset of the issues with which

have to contend. In particular, I recognised that many of the questions of reflection could be profitably studied in a (limited) procedural dialect, in ways that would ultimately illuminate the larger programme. Furthennore, to the extent that IISP could serve as a theoretical vehicle, it seemed a good project; it would be much casier to develop, and even more so to communicate, solutions in a fonnalism at least partially understood.

The time from the original decision to look at procedural reflection (and its

concomitant clnphasis on semantics -

**I realised from investigations of
**

3-LISP

MANT IQ

that

**semantics would come to the fore in all aspects of the overall enterprise), to a working
**

implementation of 3-lISP, was only a few weeks. Articulating why

was, however -

,vas the way it

fonnulating in plain English the concepts and categories on which the

**design was founded - required quite intensive work for the remainder of the year. A first
**

draft. of the dissertation was completed at the end of December 1981; tile implcmentntion

remained essentially unchanged during the course of this writing (the only substantive

alteration was the idea of treating recursion in tenns of explicit Y operators). Thus (and I suspect there is nothing unusual in this experience) fonnulating an idea required approximately ten times more work than embodying it in a machine; perhaps more surprisingly, all of that effort in formulation occurred after the implementation was complete. We sometimes hear that writing computer programs is intellectually hygenic because it requires that we make our ideas completely explicit I have come to disagree rather fundamentally with this view. Certainly writing a program docs not force one to one make one's ideas articulate, although it is a useful first step. More seriously, however, it is often the case that the organising principles and fundatnental insights contributing to the coherence program.

o,~

**a program are not explicitly encoded within the stnlcturcs comprising that
**

a fact perhaps to be expected, since only procedural consequence is

'"[he theory of declarative scnlantics embodied in 3-lISP, for example, was

initially tacit -

Preliminaries

Procedural Reflection

12

explicitly encoded in an implementation. Curiously, this is one of the reasons that building a fully reflective formalism (as opposed to the limited procedurally reflective languages

**considered here) is difficult: in order to build a general reflective calculus, one must embed
**

within it a fully articulated theory of one's understanding of it This will take some time.

An itinerant graduate student career has made me indelibly indebted to more people

**tllan can possibly be named here. It is often pointed out that any ideas or conhlbutions
**

that a person makes arise not from the individual, but from the embedding context and community within which he or she works; this is doubly true when the project - as is the

case here - is one of rational reconstruction. It is the explicit intent of this dissertation to

**articulate the tacit conception of programming that we all share; thus I want first to
**

ackno\vledge the support and contributions of all those attempting to develop and to deploy

the overarching computational metaphor. Particular thanks are due to my committee members: Peter Szolovits, Terry Winograd, and Jon Allen, not only for the time and judgment they gave to this particular dissertation, but also for their sustaining

~'Upport

over many years, through periods when it

was clear to none of us how (or perhaps even wllcther) I would be nble to delineate and concentrate on any finite part of the encompassing enterprise. I am grateful as well to

Terry Winograd and Danny Bobrow for inviting Inc to participate in the

KRl

project where

**this research began, and to them and to my fellow students in that research group (David
**

Levy, Paul Martin, Mitch Model, and Henry 1l10nlpson) for their original and continued

support Finally, in the years between that seminal summer and the present, any number of

**people have contributed to my understanding and commitment, in ways that they alone know best Let
**

lllC

appreciatively just mention my fronily, and Bob Berwick, Ron

Brachman, John Ilrown, Chip Bruce, I)edre Gentner, Barbara Grosz, Austin lIenderson,

**David Israel, Marcia lJnd, Mitch Marcus, Marilyn Matz, Ray Perrault, Susan Porter, Bruce
**

Roberts, Arnold Stnith, Al Stevens, Hector LeVesque, Sylvia Weir, and again Terry Winograd.

Prologue

Procedural Reflection

13

Prologue

It is a striking fact about human cognition that we can think not only about the world around us, but also about our ideas, our actions, our feelings, our past experience.

**This ability to reflect lies behind much of the subtlety and flexibility with Wl1ich we deal
**

with the world; it is an essential part of mastering new skills, of reacting to unexpected

circumstances, of short-range and long-range planning, of recovering from mistakes, of extrapolating from past experience, and so on and so forth. Reflective thinking

characterises mundane practical matters and delicate theoretical distinctions. We have all

**paused to review past circumstances, such as conversations with guests or strangers, to
**

consider the appropriateness of our behaviour. We can remember times when we stopped and consciously decided to consider a set of options, say when confronted with a fire or other emergency. We understand when someone tells us to believe everything a friend tells

**us, unless we know otherwise. In the course of philosophical discussion we can agree to
**

distinguish views \ve believe to be true from those we have no reason to believe are false. In all these cases the subject matter of our contemplation at the moment of reflection includes our remembered experience, our private thoughts, and our reasoning patterns.

**The power and universality of reflective thinking has caught the attention of the
**

cognitive science community indeed, once alerted to this aspect of human behaviour, theorists find evidence of it almost everywhere. Though no one can yet say just wl1at it

**comes to, crurial ingredients would seem to be the ability to recall memories of a world
**

experienced

ill

the past and of one's own participation in that world, the ability to think

**about a phenomenal world, hypothetical or actual, that is not currently being experienced
**

(an ability presumably mediated by our knowledge and belief}, and a certain kind of true

self-reference: the ability to consider both one's actions and the workings of one's mind. This last aspect the self-referential aspect of reflective thought -

OVln

has sparked

particular interest for cognitive theorists, both in psychology (under the label metacognition), and in artificial intelligence (in the design of computational systems possessing inchoate reflective powers, particularly as evidenced in a collection of ideas loosely allied in

their use of the term "meta": Dleta-Ievel rules, meta-descriptions, and so forth).

Prologue

Procedural Reflection

14

**In artificial intelligence, the focus on computational forms of self-referential
**

reflective reasoning has become particnlarly central.

Although the task of endowing

**computational systems with subtlety atld flexibility has proved difticult, we have had some
**

success in developing systenls with a moderate grasp of certain domains: electronics, bacteremia, simple

m~hanical

systems, etc.

One of the most recalcitrant

problem~

however, has been that of develo.9ing flexibility and modularity (in some cases even simple effectiveness) in the reasoning processes that use this world knowledge. Though it has been

possible to construct programs that perfonn a specific kind of reasoning task (say, checking an circuit or parsing a subset of natural language syntax), there has been less success in simulating "common sense" t or in developing programs able to figure out what to do, and how to do it, in either general or novel situations. If the course of reasoning if tlle

b~

problem solving strategies and the hypothesis fonnation behaviour - could itselfbe treated as a valid subject domain in its own right, then (at least so the idea goes) it might possible to construct systems that manifested the same modularity about their own thought processes that they manifest about their primary subject domains. A simple example might be an electronics "expert" able to choose an appropriate method of tackling a particular circuit, depending on a variety of questions about the relationship between its own capacities and the

probi~m

**at hand: whether the task was primarily one of design or
**

say, the complexity of the circuit, or

analysis or repair, what strategies and skills it knew it had in such arcaJ, how confident it was in the relevance of specific approaches based

011 t

on how similar it looked compared with circuits its already knew. Expert human problem" solvers clearly demonstrate such reflective abilities, and it appears more and more certain that powerful computational problem

solve~

will have to possess thent as well.

**No one would expect potent skills to arise autolnatically in a reflective system; tlle
**

mere ability to reason about the reasoning process will not magically yield systems able to reflect in powerful and flexible ways. On the other hand, the demonstration of such an ability is clearly a pre-requisite to its effective utilisatiol1. Furthermore, many reasons are

**advanced in sllpport of reflection, as well as the primary one (the hope of building a system
**

able to decide how to structure the pattern of its own reasoning). It has been argtlcd t for example, that it would be easier to construct powerful systems in the first place (it \\'ould seem you could almost lell thenl how to tllink), to interact with tllcm when they fail to

y

trust them if they could report on how they arrive at their decisions. to give them "advice"

Prologue

Procedural Reflection

is

about how to improve or discriminate, as well as to provide them with their own strategies for reacting to their history and experience. There is even, as part of the general excitement, a tentative suggestion on how such a self-referential reflective process might be constructed. argued but clearly in evidence in several recent proposals 'l.is suggestion -

nowhere

is a particular instance of a

general hypothesis, adopted by most A.I. researchers, that we will call the knowledge

representation hypothesis.

It is widely held in computational circles that any process

cap~ble of reasoning intelligently about the world must consist in part of a field of

structures, of a roughly linguistic sort, which in some fashion represent whatever knowledge and beliefs the process may be said to possess. For example, according to this view, since I know that the sun sets each evening, my "mind" must contain (among other things) a language-like or symbolic structure that represents this fact, inscribed in some kind of internal code.

Th~re

are various assumptions that go along with this view: there is for one

thing presu r",led to be an internal process that "runs over" or "computes with" these

representational structures, in such a way that the intelligent behaviour of the whole results from the interaction of parts. In addition, this ingredient process is required to react only to the i'fonn" or "shape" of these mental representations, without regard to \vhat they mean or represent this is the substance of the claim tllat computation involves Jonnal symbol manipulation. Thus my thought that, for exanlple, the sun will soon set, would be taken to emerge from an interaction in my tnind between an ingredient process and the

shape or "spelling" of various internal stnlctures representing my knowledge that the sun

docs regularly set each evening, that it is currently tea time, and so forth. The knowledge representation hypothesis may be summarised as follows:

Any mechallicaliy embodied intelligent process will be conlprised of structural ingredients that a) we a.s external observers naturally take to represent a propositional accoullt of the kllolvledge that the overall process exhibits, and b) independent '0/ sur:h external selnanlica/ attribution, playa Jonna/ but causal and essential role in engendering lhe behaviour that Inani[ests that knowledge.

Thus for example if we felt disposed to say that some process knew that dinosaurs were warm-blooded, then

\VC

**would find (according, presumably, to the best explanation of how
**

di~osaurs

**that process worked) that a certain computational ingredient in that process was understood
**

as representing the (propositional) fact that were warm-blooded, ann. iurtherml.l'C

in approach. they might posit the general fonn in which such beliefs would be "written" (along with other beliefs. this view that knowing is representational is far less evident . etc. by postures it adopted on suggestions as to why they may have become extinct. conclusion or hypothesis. In spite of such differences.v~'\red Presumably we would convinced by the manner in which the process certain questions about their likely habitat. such as that Lasa is in l ibet. is whether they wilt serve to underwrite the construction of demonstrable. and has in particular led researchers in artificial intelligence to propose a spate of computational languages and calculi designed to underwrite such representation. it pClmeates current theories of mind.Prologue Procedural Reflection 16 t11at this very ingredient played a role. is the 110W requirement that they must be able to demonstrate a particular thought could emerge from such representations intelligence research. and in detail. by assumptions it made about other aspects of their existence. Under this general rubric knowledge representation efforts differ markedly in scope. far more interesting than is commonly believed. behaving artefacts. another for verbal. . The common goal is of course not so much to speculate on what is actually represented in any particular sinlation as to uncover the general and categorical form of such representation. and artificial intelligence treatments often lack the theoretical rigour necessary to bring the essence of the idea into plain view. in leading the process to behave in whatever way inspired us to say that it knew that fact ans. in oUlcr words. they differ on such crucial questions as whether or not the mental structure are modality specific (one for visual memory. Nonetheless. they manifest the shared hope that an attainable first step towards a full theory of mind will be the discovery of something like the structure of the "mechanical mentalcse" in which our beliefs are inscribed. Constraining all plausible suggestions. l'hus no one would suggest how anyone actually represents facts about tea and sunsets: rather. for exalnple).and perhaps. therefore. and that II 1 is an irrational number). independent of our understanding of it as representational. however. to the extent that we can make sense of it. A careful analysis will show that. however. To do it justdce requires considerable care: accounts in cognitive psychology and the philosophy of mind tend to founder on simplistic models of computation. this is a crucial meta-theoretic characteri£tic of artificial It is traditionally considered insufficient merely to propose tnle t11eories that do not enable some causally effective mechanical embodiment rrhc standard against which such theories Inust ultimately judged.

Thus the task of building a computationally reflective system is thought to reduce to. and remain skeptical of the weak version as well. there is aInple evidence that researchers arc taken with this view. Doyle's TMS.a concern to make it clear than to defend or deny it The entire present investigation. We would certainly need a definition of the word "represent". and In arc particularly explicit exemplars of just such an approach. Given tl1e current (minimal) state of our understanding. Before it can fairly be asked. or at any rate to include. Hence a system able to imagine a world where unicorns have wings would have to construct formal representations of that fact. about which we will subsequently have a good deal to say. a system considering the adoption of a hypothesis-and-test style of investigation would have to construct fannal structures representing such a inference regime. but merely because' it deserves our 'attention. Given the reprcsention hypothesis. but this is not the place to pursue that difficult question. not because we grant it our allegiance. Hayes' GOLUM. Whatever its merit. the suggestion as to how to build self-reflective systems follows: a suggestion we will call the reflection hypothesis can be summarised as In as much as a computational process can be constructed to reason about an external world in virtue of cOlnprising all ingredient process (interpreter) jOnnally nlQnipulating representations of that world. 2 . therefore. we would have to distinguish a strong version claiming that knowing is necessarily representational from a weaker version claiming merely that it is possible to build a representational knower. Systems such as Weyrauch's Davis' TERESIUS FOl. But one of the most difficult questions is merely to ascertain what the hypothesis is actually saying .Prologue Procedural Reflection 17 It is natural to ask whether the knowledge representation hypothesis deserves our endorsement. so too a computational process could be made to reason about itself in virtue of conlprisillg an ingredient process (interpreter) lonnally manipulating representations of its own operations and structures. We would run straight into all the much-discussed but virtually intractable questions about what would be required to convince us that an artificially constructed process exhibited intelligent behaviour. I myself see 110 reason to subscribe to the strong view.thus my interest in representation is more . will be pursued under this hypothesis. the task of providing a system with fannal representations of its own constitution and behaviour. McCarthy's ADVICE-TAKER.

I bring into view of my mind's eye the self I imagine :hat tomorrow I will be. reflection surely involves representation (although . particularly as exemplified by computational structures representing other computational structures. I-Iowcver . and the ability to re-present a world to itself is undeniably a crucial. 4 The Relationship Be/ween Reflection and Representation The manner in which this discussion has been presented so far would seem to imply that the interest in reflection and the adoption of a representational stance are theoretically independent positions. the use of explicit non-monotonic inference rules. in a recent symposium Brachman reported that the love affair with ". similarly. th~ If we take "representation" to describe an acli"ity. If I reflect on my childhood.3 indefinitely. sentences in first-order logic arc constructed that axiomatize the behaviour of the LISP procedures use in the course of the computation (FOL is a prime example of the dual-calculus approach mentioned earlier).the "representation" . the popularity of meta-level rules in planning systems.Prologue Procedural Reflection 18 Weyhrauch's system. I re-present to myself my school and the rooms of my house. rather than a stnlcture. with reflective abilities. in some sense. In Doyle's systems. There is no a priori reason to believe that even a fully representational system should in any way be reflective or able to make anyt11ing approximating a reference to itself.and this should be kept clearly in mind . related.and tllis is the crux of the matter the reason to raise both issues together is that they are surely. as well as for a variety of other current research. I have argued in this way for a reason: to make clear that the two subjects are not the same. In addition. if not the crucial. the word "representation" comes from "rc" plus "present". Similar remarks hold for the other projects mentioned. If nothing else. ingredient in reflective thought. if I reflect on what I will do tomorrow. explicit representations of the dependencies between beliefs. there is no proof that a powerfully selfreferential system need be constructed of representations. and of the "reasons" the system accepts a conclusion. it turns out on scrutiny that a great deal of current computational practice can be seen as dealing.nela--leveJ reasoning" was the most important theme of knowledge representation research in the last decade. in one way or another. for example. play a causal role in the inferential process. We constantly encounter examples: the wide-spread use of macros in LISP) the use of meta-level structures Such a list can be extended in representation languages.

a procedural approach emerged in which the primary focus was on the manipulation and reasoning about specific problems in simple worlds. Thus the represenlalioll hYPolhesis emerged in the attempt to endow systems with generality. therefore. flexibility. modularity. This inflexibility III reasoning is strikingly paralIel to the inflexibility in knowledge that led to the first round of representational systems. and so forth with respect to the embedding world. In the early days of artificial intelligence. 6 Though the procedural approach in many ways solved the problem of undirected inferential meandcring. in tcnns of our main discussion. However it proved difficult to make such general systems effective in particular cases: so much of the "expertise" involved in problem solving seems domain and task specific. researchers have therefore suggested that we need reflective systems able to deal with their own constitutions as well as with the worlds they inhabit. it has seemed that another application of the same medicine migllt be . researchers turned instead to the development of processes designed to work over general representations of the objects and categories of the world in which the process was designed to be embedded. SystCJTIS based on the representational approach - and it is fair to say that most of the current "expert systems" are in this tradition - have been relatively successful in certain respects. it too had problems: it proved difficult to endow systems with much generality or modularity when they were simply constituted of procedures designed to manifest certain particular skills. not to an It is helpful to look at the historical association between these ideas. since the style of the problem is so paralle. but a major lingering problem has been a narrowness and inflexibility regarding the style of reasoning these systems employ in using these representational structures. a search for the general patterns of intelligent reasoning led to the development of such general systems as Newell and Simon's GPS. predicate logic theorem provers. but to retain a procedural effectiveness in the control component 7 In other words. representation as a Inethod emerged as a solution to the problem of providing general and flexible ways of reflecting (not self-referentially) about the world.Prologue of the knowledge activity). In other words. In reaction against such generality. as well to searcll for commonalities in content. 6 The descriptions of the subject domains were minimal but were nonetheless primarily declarative. to that just sketclled. repr~sentation Procedural Reflection 19 hypothesis refers to ingredient structures. In reaction to such brittle and parocllial behaviour. particularly in the case of the systems based on logic. and so forth.

and they are visible to that constituent process only fonnally (this is the basic claim of computation). in too quick an association between the two ideas. however. in the typical computational process the ieast of which is the question of to whom these various foons of re-presentation are being directed. they are visible only to the ingredient interpretive process of the whole.Prologue Procedural Reflection to 20 appropriate. thereby engendering a flexibility and modularity regarding reasoning. That process is made out of them.but to make clear that two ideas are involved. there is no reason to suppose that the representational structures are visible to the whole constituted process at all.that one cannot make a representational reflective system . (In fact it is almost a great joke that tile blindly fannal ingredient process should be called an interpreter. they are different in kind: one (representation) is a possibly powerful 11lelhod for the construction of systems.a process is constituted from symbols that we as external theorists take to be representational structures. It remains a question whether the representational method will prove useful in the pursuit of the goal of reflective behaviour. the other (reflection) is a kind of behaviour we are asking our systems to exhibit. Furthennore. not that is to say. . IISP interpreter evalutes the expression (+ 2 3) and returns the result the last thing it knows is that the numeral 2 denotes the number two. it might be possible to design a relatively simpler inferential regime over this "meta-knowledge about reasoning". there is no more a priori reason to suppose that they are accessible to its inspection than to suppose that a camera could take a picture of its own shutter . just as the first representational work engendered a flexibility and modularity about the process's embedding world ~rhere are problems. formally or infonnally. Current practice should overwhelmingly convince us of this point: what is as tacit what is as thoroughly lacking in self-kno\vtcdge . If we could inscribe general knowledge about how reason in a variety of circumstances in the "mentalese" of these systems. when the 6. though it is bU'nd to the fact of their being representations.) Whatever is the case with the ingredient process. In the nonnal case - built under the aegis of the knowledge representation hypothesis .as the typical modern computer system? The point of the argument here is not to prove that one cannot make such structures accessible . Thus the interpreter can see them.no more reason to suppose it is even a coherent possibility tllan to say that France is near Marseilles.

cogent definitions cannot even be attempted. First. self-reference. apparatus capable of distinguishing between onc abstract machine and another in which the first is implemented Second. Finally. This is a distinction we encounter again and again. it nlay be easy to claim that when a program is manipulating data structures representing women's vote that the process as a whole is "tllinking about suffrage". if the search for reflection is taken up too . 8 Theories of reference will be required in order to make sense of the question of what a computational process is "tllinkjng tt about at all. and (if we subscribe to the representational hypothesis) of its interpreter. theor~tica1 definition of reflection will have to be backGu by something we are not yet able to do. and of computational reference in particular. is our overall project Procedural Reflection 21 The Theoretical Backdrop It takes only a moment's consideration of such questions as the relationship between representation and reflection to recognise that the current state of our understanding of such subjects is terribly inadequate. in this dissertation I will present a partially-reflective dialect of LISP tllat I have implemented on a PDP-10. the notion seems to require of a computational process. The reason is simple: we are so lacking in adequate theories of the surrounding territory that. derailing the arguments of such thinkers as Searle and Fodor. in a nutshell. In spite of the general excitement about reflection. Theories of computational interpretation will be required to clarify the confusion mentioned above regarding the relationship between reflection and representation: for a system to reflect it must re-present for itself its mental states. is not itself reflective). from the fact that a reflective system is implemented in system it docs not follow that system but the PDP-tO 8 is thereby rendered reflective Hence even a (for example. and we lack theories both of interpreters in general. but what is the process thinking about when the interpreter is expanding a macro definition?). a failure to make it is the most common error in discussions of the plausibility of artificial intelligence from those outside the computational community.Prologue That. that in reflecting it "back off' one level of reference. it is not sufficient for it to comprise a set of fonnal representations inspected by its interpreter. whether reflective or not (for example. Bt where just a few examples will make this clear. no one has presented an underlying theory of ~y of these issues. without considerable preliminary work. A Consider for example the case regarding self-referential reflection. and computational representation.

especially since the representational endeavour has received much more attention than has reflection. 9 To begin with. in spite of an approximate consensus regarding the general fonn of the task. theories of seDlantics for programming languages. TIle sub-discipline is known as the representation 0/ knowledge. it would not . interpretation. but in the survey just mentioned the surprise of this autllor) claimed to usc the word. and it is surprisingly difficult to weave t11eir various insights into a single col1erent whole. We do not have theories of either representation or computation in terms of which to define the terms of art currently employed in their pursuit (representation. Nor is our grasp of the representational question any clearer. and so forth). or of how to proceed. disagrcenlents emerge on every conceivable technical point. there is remarkably little agreement on whether a representation must "re-present" in any constrained way (like an image or copy). or whether the word is synonymous with such general terms as "sign" or "symbol". A further confusion is shown by an inconsistency in usage as to what by far the Inajority of the respondents (to representation is a relationship between. Evidence of this lack can be seen in the fact that. since what may not be reflective explicitly can usually be treated as implicitly reflective (especially given a little imagination on the part of the theorist). data structure. and are consequently without any well-specified account of what it would be to succeed. inheritance. in other words. as was demonstrated in a recent survey of tile field. and so forth).Prologue Procedural Reflection 22 enthusiastically. Numerous related theories have been developed (model theories for logic. 111e representational consensus alluded to above. However we lack general guidelines on how to distinguish explicit from implicit aspects of computational structures. is widespread but vague. Again r this is due at least in part to the simple absence of adequate theoretical foundations in tenns of which to fOffilulate either enterprise or solution. and substantial effort on its behalf: no representation scheme yet proposed has won substantial acceptance in the field. albeit in a wide variety of ways. rfhus a KLONE structure might be said to represent Don Quixote tilting at a lvi1l(l1nill. one is in danger of interpreting everything as evidence of reflective :hinking. a serious difficulty. control structure. implelne1l1ation. let alone of what to investigate. but they don't address tile issues of knowledge representation directly. the central notion of "representation" relnains notoriously unspecified: in spite of tIle intuitions mentioned above. as between format symbols allti the world about lvhich the process is designed to reason.

ranging from how natural language is translated into the representational structures. work. such practice makes comparison and discussion of technical details always problematic and often impossible. they are strikingly distinct. one of computational origin. tO In addition. to how they impinge on the rational policies of the "mind" of which they arc a part. In other words the majority opinion is not that we are representing knowledge at all. concept. and plan. we are faced with a pletllora of apparently incomparable technical words and phrases. unit. that knowing is representational. we have only a dim understanding of the relationship that holds between the purported representational structures and the ingredient process that interprets them. unless severely constrained. defeating attempts to build on previous lois lack of grounding and focus has not passed unnoticed: in various quarters one hears tile suggestion that. Node. there are terminological confusions: the word "semantics" is applied to a variety of concerns. etc. This relates to the crucial distinction between that interpreting process and the whole process of which it is an ingredient (whereas it is I who thinks of sunsets. as was just mentioned. schelna. script. but tltat are defined using fonnat terms peculiar to the system at hand. to what functions are computed by the interpreting process. We arc left on our own to induce the relevant generalities and to locate them in our evolving conception of the representation enterprise as a whole. fraine. tIle entire representation enterprise . class. it is at best a constituent of Iny mind that inspects a mental representation). are all popular terms with similar connotations and ill-defined nleaning. Unfortunately. but rather. as we put it above. although. such general terminological problems are just the tip of an iceberg.Prologue Procedural Reflection 23 taken as representing the fact or p1:oposition of this activity. When we consider our specific representational proposals. Furthermore. rllte term "interpretation" (to take another example) 11as two relatively well-specified but quite independent meanings. the other more philosopllical. how the two relate remains so far unexplicatcd. Furthernlore. to what those structures represent. pattern. it The theoretical situation (this may not be so hannful in terms of more practical goats) is further hindered by the tendency for representational research to be reporlcd hI a rather demonstrative fashion: researchers typically exhibit particular fannal systems that (often quite impressively) embody their insights. for example.

of implicitness. of objectification. 14 community: the survey just mentioned lists more than thirty new representation systems under active development The strength of this persistence is worth noting. that all we need is a set of ideas about what axioms and inference protocols are best to adopt. It is true that any satisfactory theory of computational reflection must ultimately rest.Prologue may be ill-conceived - Procedural Reflection 24 that we should tum instead to considerations of particular LISP. and suggests that practical progress will be . manipulation. In the case of designing reflective systems. on theories of computation. of semantics Hnd reference. epistemological issues (such as how we reason about. and so forth. The wealth of programs and systems we have built often betray sometimes in surprising ways patterns and insights that eluded our conscious thoughts in the course of their dcvcloplnent. and so forth. What is mandated is a rational recollstruction of those intuitions and of that p!actice. The first is that questions about the central cognitive faculty are at the very least premature. and should use as our technical base the traditional formal systems (logic. of representation. liquids or actions). and more seriously may for principled reasons never succomb to the kind of rigourous scientific analysis that characterizes recent studies of the peripheral aspects of mind: vision. 13 The other argument is that logic as developed by the logicians is in itself But such doubts cannot be said to have deterred the whole of the sufficient. such a reconstruction is curiously urgent. more or less explicitly. especially in connection with theoretical difficulties just sketched. But it would be a mistake to conclude in discouragement that the enterprise is doomed.one that "ups the ante" in the search for a carefully fOfJnulated theory. In fact thi$ long introductory story ends with an odd twist . audition. of computation interpretation. of intensionality. On the other hand as a community we have a great deal of practice that often embodies intuitions that we are unable to fonnulate coherently. 12 In defense of this view two kinds of argument are often advanced. say. and so forth). th~ There can be no doubt that there are scores of difficult problems: we have just barely touched on some of the most striking. What is demanded is that we stay true to these undeniably powerful ideas. of formality. programming language semantics. and attempt to develop adequate theoretical structures on this home ground. or to retreat to the meta-theoretic stabHity of adjacent fields (like proof theory. grammar. and so forth) that representation schemes were originally designed to replace. model theory. The mornt is at once more difficult and yet more hopeful.

It is simply likely to be llomanageably compli. we must have an adequate theories of computational representation and reflection explicitly formulated. while we humans might make do with a rich but unarticulated understanding of conlputation. developing self-descriptive systems to provide. encoded within the representational medium. sema~tics. in constructing a reflective calculus one must support arbitrary levels of metaknowledge and self-modelling. That is. if widely accepted. however.' . For one thing. at least at the present time. representation. In general. if we are to build a process that "knows" about itself: and if we subscribe to the view that knowing is representational. If one repf~scntation hypothesis. However there are a number of reasons why such an approach ~ay be ruled out in the present case. we must not forget that computers do not share with us our tacit understanding of what they arc. since an encoding of that theory is mandated to play a causal role as an actual ingredient in the reflective device. was already drawing to a close just as the theory of airfoils and lift was being fonnulated - the theory that. We have argued that this is a substantial. then we are committed to providing t11at sytem with a representation of the self-knowledge that we aim to endow it witil. an only partially understood fonnalism. hypothesis. Knowledge of any sort and self-knowledge is no exception is always theory relative. and it is self-evident that confusion and complexity will multiply unckecked when one adds such faciliti -. The complexities surrounding the use of APPLY in LISP (and the caution with Wllich it has consequently come to be treated) bear witness to this fact subscribes to the knowledge However there is a more serious i'robleo. . it is of course possible (some would even advocate this approach) to build an instance of a class of artefact before formulating a theory of it The era of sail boats.Prologue Procedural Reflection 25 impeded until we take up the theoretical task. it becomes an integral part of and reasoning behaviour of that formalism. In other words. The representation hypothesis implies that our theories of reasoning and reflection must be explicit. an account of (roughly) the syoUtx. One reason to find it plausible comes froln viewing the entire enterprise as an attempt to communicate our thought patterns and cognitive styles including our reflective abilities to these emergent machines. best explains how those sailboats worked.cated to attempt to build a self-reterential system unaided by the clarifying structure of a prior theory. it has often been pointed out. It may at some point be possible for understanding to be tacitly comlTIunicated between humans and system they have constructed. . and reflection. In tile meantime.

etc. However this issue too will be largely ignored. frames. The second. in part because it is so llt·constrained. and manipulation. it will not be pursued here. Introduction Procedural Reflection 26 Chapter 1. the question is one of how to construct a program able to reason about and affect its own interpretation . however. methods of indexing and grouping representational structures. In computational terms. having received (so far as this author knows) almost no As a consequence. We will show how to construct a computational system whose active interpretation is controlled by structures thclnselves available for inspection. . The provision of a computationally tractable and epistemologically adequate de'JCriptive language. In spite of its centrality. and dealing with its own reasoning processes over that domain. Introduction The successful development of a general reflective calculus based on the knowledge representation hypothesis will depend on the prior solution of three problems: 1. coveling such diverse issues as adequate theories of intensionality. can be shown to manifest this structure. every representation system proposed to date LISP) exemplifies what we may call a dual-calculus approach: a procedural calculus (usually Even such purpCJnedly unified systems as PROLOG 1 is conjoined with a declarative formalism (an encoding of predicate logic. 2. 3. though it is occasionally acknowledged to be direct attention.of how to define a calculus with a reflectively accessible control structure. The formulation of a unified theory of computation and representation. The first of these issues is the collective goal of present knowledge representation research. We will in passing suggest that this dual-calculus style is unnecessary and indicative of serious shortcomings in our conception of the representational endeavour.1. and support for variations in assertional force. and The demonstration of how a computational system can reason effectively and consequentially about its own inference processes. in ways tllat allow a process to shift smoothly between dealing with a given subject domain. modification. though much studied.). ·it has met with only partial success. The focus instead will be on the third problem: the question of making the inferential or interpretive aspects of a computational process themselves accessible as a valid domain of reasoning. importan~ is a much less well publicised issue. The problems involved are enonnous.

In the next section. powerful. we will identify six distinguishing characteristics of all reflective behaviour. we will sketch the model of computation on which our analysis will be based. General Overvi2w The term "reflection" does not name a previously we!l-detined question to which we propose a particular solution (although the reflection principles of logic are not unrelated). we will set forth on the analysis itself: As a technical device. . since we will be primarily concerned with computational reflection. a theory of the dcnotational significance of sexpressions) formulated illde/Jelldenl of the behaviour of the inlerpreter. as we will discuss in the concluding chapter. The second differs rather substantially from I-LISP. same approach as we have followed here for The first LISP dialect (called 1-LISP) will be an example intended to summarise current practice. Introduction Procedural Reflection 27 1. before what can present a theory of what reflection comes to. to serve as to work out our theories in detail. All of these preliminaries are necessary in order to give us an attainable set of goals. therefore. Nevertheless. primarily for comparison and pedagogical purposes.e.and it is a convenient fomlalisln in which to express its own meta-theory. by way of introduction. that this focus on into thinking that tt~e LISP.class accessible structures. we will be able to define what we mean by procedural reflection an even smaller and more circumscribed notion than computational reflection in general. Thus prepared. it would be possible to construct a reflective dialect of FORTRAN. Then. (2-lISP) in that it is modified witl1 reference to a theory of declarative de notational sClnantics (i. or any other procedural calculus. by pursuing essentially the LISP.. given that we will use a variant of lhe )-calculus as O\lr mathematical meta-language (this convenience holds especially in a statically seoped dialect of the sort we will ultimately adopt). SMALLTALK. and uniquely suited for reflection in two ways: it already embodies protocols whereby programs arc represented in first. once we have developed a working vocabulary of computational concepts. however. TIle interpreter is .a. we will in the course of the dissertation develop three successive dialects of illustrations.1. we will have to give an account of what reflection is. was chosen because it is simple. and to provide a technical ground in which We should say at the outset.. should not mislead the reader or the principles IISP LISP basic reflective architecture we will adopt - endorsed in its design - are in any important sense LISP specific. and will set our general approach to reflection into a computational context In addition.

syntactic powers (paradigtnatically exemplified by the primitive Because of its metacontains a (EVAl QUOTE). the the value of the function computed by the is a nonnal-fonn codes. and in part because. More specifically.i. being fanliliar. is at heart a first-order language.ISP 3-LISP program will normal-form designators of both the environment and continuation structures that were in effect a moment before. semantically and structurally Ollr but modified so that reflective procedures are supported. will occupy \yell over half of the dissertation. I-LISP. will call of LISP 2-LISP a semantically rationalised and will argue that it makes explicit t. and the wilt subject I-lISP to a rather t110rough semantical scrutiny. We will argue that it is crucial. we will document its properties in part to serve as a contrast for the I-LISP can serve as a base in but before attempting to constnlct a reflective dialect. inspcct. protocols for expanding macros. like liSP 1. fonnulated with respect to a primitively endorsed and encoded theory. Though we will ultimately criticise much of subsequent dialects. a procedurally reflective based on 3-LISP 2-LISP. for a program to reflect and thereby obtain fully articulated "descriptions". of which the most important is the provision. After introducing I-LISP. and the ability to lnention program fragments. I-lISP variety of inchoate reflective features. of the state of the interpretation process that was in effect at the moment of reflection.e. The reason is that our analysis will require a reconstruction not only of IISP but of computational semantics in general. this will mean tllat a be able to access. which to ground our analysis. and so I-lISP'S on and so forth. 28 then subsequently defined with respect to this theory of attributed basic interpretation process - so that the result of processing of an expression . employing meta-syntactic facilities and dynamic variable seoping protocols to partially mimic higtlcr-ordcr functionality.1. reconstruction that results.6 and all LISP dialects in current use.gnator of the input expression. all of which we will examine in some detail: support for meta"circular interpreters. in order to develop a comprehensible reflective .. structure (and its underlying theory). Introduction Procedural Reflection semanti~s. In our particular case. as a vehicle with goat. at any point in the course of the computation. and Inodify standard 3-I. Fhlally.ISP much of the understanding of LISP that tacitly organises most programmers' understanding but that has never been made an arrticulated part of LISP theories. We dicl~i. called 3-lISP will be developed. we 111is project. 2-LISP which to engender the sorts of procedural reflection we will by then have set as differs from in a variety of ~ays. explicit names for the pritnitive processor functions APPl v).

. and mathenJatics. the~ procedural ccnsequencc of a given expression may affect the subsequent context of use that detennines what another expression designates). that tl)e traditional notion of evaluation is both confusing and confused. It is our view that semalltical cleanliness is by far the most hnportant pre-requisite to any conceivable treatment of reflection. abstract. This semantical reconstruction is at heart a comparison and combination of the standard semantics of programming languages on the one hand. the A-calculus. for and NIL). and must be separated into independent notions of reference and sinlpliflcQlion. declarative semantics. rather than in tenns of a single one. fIowcver. and procedural consequence (a mandate satisfied hy no extant dialccl~). that programming languages are better understood in tenns of two scmantica1 treatments (one declarative. We claim. In particular. that others (such as the numerals and T I-lISP'S evaluator dc-references some expressions (such meta-syntactic terms as de-rcf~rence (QUOTE X). in particular. example). we will also espouse an aesthetic we call category aligllme~t 'by which we mean t.'lat there should be a strict category-category correspondence across the four major axes in terms of which a computation calculus is analysed: notation. on the athe:. for example. as well as advocating selnantical/y rationalised computational calculi. nor are the declarative and procedural facets entirely 3eparate (in particular. structure. to have a semantical analysis of that calculus that makes explicit t:. Introduction Procedural Reflection 29 calculus. We will argue instead for what we will call a semantically rationalised dialect. Neither will survive intact: the approach we will ultimately adopt is not strictly compositional in the standard sense (although it is recursively specifiable). and docs not We will be able to show. as exemplified by current approaches (although interactions between them may require that these two semantical accounts be fonnulattj in conjunction). This attribution of semantical import to computational expressions is prior to an account of what happens to those expressions: thus we will argue for an analysis of computational fonnalisnls in which declarative import and procedural consequence arc independently formulated. and the semantics of natural human languages and of descriptive and declarative languages such as predicate logic. in which simplification and reference pl. in other words. Nor are its consequences minor: we will we able to show.1.mitives are kept strictly distinct. one procedural). we will insist in t th~ dialects we design that each nolatiollal class be parsed into a distinct structural class that each structural class be treated .'e tacit attribution of significance that we will claim characterises every computational system.

Like SCHEME and the A-calculus. nomlal-form designators are environment-independent and side-effect free. thus the concept of a closure can be Since normalisation is a fann of simplification. and so forth. the 2-LISP processor is based on a regimen of normalisation. listed in 55-207. rather than (~ in the case of the A-calculus) in tenns of tile further 2-LISP'S (non-) applicability of a set of syntactic reduction rules. categorical elegance will also prove almost indispensible. Consequently. is causally connected to the workings of the underlying calculus in critical and primitive ways.. It is of course fannulated in terms of our rationalised semantics. with respect to an explicitly articulated procedural theory of en . to facilitate explicit shifts in level of designation).1. and treats the function position of an application as a standard extensional position. in the drive towards reflection. though superficially resembling a meta-circular interpreter (as a glance at the code. which are themselves a derivative class formed from some pairs and one atom. We will say that the 2-LISP processor is sel1lantically flat. jdcd in 3-LISP structures. it is statically scoped. meta-structural expressions (terms that designate other tenns in the language) are not de-referenced upon normalisation. I-lISP programmer must in certain I-LISP situations resort to meta-syntactic machinery merely because fails to satisfy this mild lists. 'Ibis embedded theory. and unlike SCHEME. we will be in a position to design 2-LISP. Introduction Procedural Reflection 30 in a unifonn way by the primitive processor. serve semantically to encode both function applications and enumerations). and independent ot: the specification of how they are treated by the primitive processor. shows). as they are when evaluated. reconstructed as a nomlal-Jonn function designator. Though it does not have the same status as seman tical hygiene. where the notion of normal-form is defined in part with reference to the semantic type of the symbol's designation. 11le reflective model is . 2-LISP is a higher-order fonnalism: consequently. Once we have fonnulated these theoretical positions. and is therefore designation-preserving. especially from a practical point of view. that each structural class serve as the Donnalfonn designator of each semanticat CIClSS. I-LISP This is an aesthetic with consequence: we will be able to show that the requirement (in particular. implying that a declarative semantics is fonnulated for all expressions prior to. since it stays at a semantically fixed level (although explicit referencing and dc-referencing primitives are also provided. taking each expression into a normal-fonn designator of its referent. called the reflective Illodel. 3-LISP is straightforwardly defined as an extension of 3-lISP 2-LISP.

and resuming the process below. and environment and continuation designators t!T. such a reflective procedure may arbitrarily control the processing of programs at the level beneath it Because reflection may recurse arbitrarily. each engendering the process immediately below. by constnlcting or modifying these designators. is nevertheless finite. 2-lISP. in other words.1. mentioned only in the meta-language. like any possible reflee-tive system. b) the .erge as part of the primitive behaviour of More specifically. For example. mediated by the reflective model. inherently theory relative. Both a straightforward implementation and a conceptual analysis are provided to demonstrate that such a machine The 3-LISP reflective levels arc not unlike the levels in a typed logic or set theory. arbitrary 3-LISP protocols. Under such an account. 'lllc architecture of explored separately in 3-LISP 3-lISP Reflective levels. as a way of explaining LISP'S bf'havio1J1\ in 3-1. running simple procedures at arbitrary levels in this reflective hierarchy. although of course eaell reflective level contains an omega"ordcr untyped computational calculus essentially isomorphic to (the extensional portion at) traditional systems. that distinguishes one computaional level fronl the next. had the machine been nloning all along in virtue of the explicit interpretation of the prior program. the use of reflective procedures amounts to. whereas environments and continuations wilt up until this point have b"'en theoretical posits. re. on the other hand. TIle locus of agency in each or mathematical traditions. 3-lISP is most simply defined as an infinite tower of 3-LISP processes. in virtue of running a copy of the reflective model.15 0 such entities move from the semantical domain of the meta-language 3-LISP into the se. is a notion without precedent in logical allows us to unify three concepts of traditional programming languages that are typically independent (three concepts we will have I-lISP): a) the ability to support meta·circular interpreters.llant:cal domain of the object language. are at once stronger and more encompassing than arc the order levels of level./leclive procedures can bind as arguments (designators of) the continuation and environment structure of the interpreter that would have been in effect at the moment the reflective procedure was called. Furthermore.. Introdl1ction Procedural Reflection 31 similar in structure to the procedural fragment of the meta-theoretic characterisation of 2LISP that we encoded in the A-calculus: it is this incorporation into a system of a theory of its own operations that makes 3-lISP.

for debugging purposes). in particular. of which the integration of declarative import and procedural consequence in a unified and rationalised semantics is undoubtedly the most important. . LISP The dissertation concludes by drawing back from the details of construction of other reflective languages - development. and the constant question of the proper usc of metastructural olachinery. since all aspects of the state of the 3-lISP interpretation process are available. and c) the inclusion of procedures that access the state of the implementation (usually provided" as pan of a programming environment.e. while of course not formal results.is merely one of making explicit what we all already knew.. The matter of category alignment.that procedurally reflective and selnantically rationalised variants on these types of languages could be readily constructed as well. there are a variety of other lessons to be taken from our investigation. Finally. with sufficient reflection. or other new systems built from the ground up.two (related) concepts commanding considerable current attention. Introduction Procedural Reflection 32 provision of explicit names for the primitive interpretive procedures (EVAl and APPLY in standard IISP dialects). EVAl and APPl Y. the unification of a variety of practices that until now have be treated independently: macros.fully in the traditional spirit of rational reconstruction . as objectified entities within the 3-LISP structural field. in favour of separate simplification and de-referencing protocols. independent of implementation). The present contribution . Fortunately. and so forth. meta-circular interpreters. we will be able to show that this early impression is false . and showing how the techniques employed in one particular case could be used in the reflective dialects of current fonnalisms. We will show. that might seem on the surface incompatible with the notioll of a system-wide declarative semantics. We will show how all such behaviours can be defined within a pure version of 3-lISP (i. is the major. The rejection of evaluation. consequence of this revised semantical approach. implementation-dependent debugging routines. but not the only. quotation. tentative steps in this direction have been taken in many areas of current practice. are nonetheless important permeating themes. should convince tlle reader of one of our most important claitns: procedural reflection is not a radically new idea. Besides the basic results on reflection.1. how our approach to reflection· may be integrated with notions of data abstraction and message passing .

have any claim to the more general term). one of the morals under our present reconstruction is that the boundaries between these two types of calculus should ultimately be dismantled. 3-LISP cannot properly be called fully reflective. and as the unified treatment of semantics betrays. Third and finally. Our investigation will always be carried on with the parallel declarative issues kept finnly in mind. the decision to first explore reflection in a procedural context should be taken as methodological. and to a certain extent mathematics) with the procedural traditioll (primarily computer science). we consider it important to unify the theoretical vocabularies of the declarative tradition (logic. based on techniques set fortlt here. the dissertation is otTered as the first step in a general investigation into the construction of gellerally reflective computational declarative semantics. All of the substantive issues. given the flavour of the discussion so far. philosophy. it is towards a unified system that we are aiming. TIle scmantical approach we will adopt here is but a first step in that direction: as was mentioned in the first paragraph. these topics arc pursued in a procedural context because it is simpler than attempting to do so in a poorly understood representational or descriptive system. have their immediate counterparts in the declarative aspects of reflection. especially when such declarative structures are integrated into a computational framework. as we will explain at a number of points. as the very first paragraph of this chapter suggests. considerable effort has been expended in the dissertation to prescnt a single semantical and conceptual position that draws on the insights and techniques of both of these disciplines. as this last comment suggests.1. This impression is in part illusory. Introduction Procedural Reflection 33 We conclude this brief introduction with three footnotes. As was mentioned in the preface. however. First. a fully unified treatment remains an unattaincd goal. rather than on representational. the reader may be tempted to conclude that the primary emphasis of this report is on procedural. Furthermore. Nonetheless. rather than as substantive. Secondly. calcul~ to be based on more fully integrated theories of In spite of its reflective powers. concerns (an impression that will only be reinforced by a quick glance through later chapters). the attribution of a declarative semantics to LISP 8"cxpressions will also reveal our representational bias. This is not because the 3-LISP structures . since a-LISP structures do not form a descriptive language (nor would any other procedurally reflective programming language tllat might be developed in the future. and in spite of its representation and computation.

we hope to convince the reader that. although it will be of some interest on its OWO. In sum. . implying that even if it were viewed as a descriptive language it would remain algebraic). in brie~ no way to say anything in such a fonnalism: we can set x to 3: we can test whether x is 3. 3-LISP is only a corollary of the major theses adopted in its development. but we cannot say that x is LISP 3. There is.1. but mther because all 3-LISP expressions arc devoid of assertional force. Introduction Procedural Reflection 34 lack expressive power (although 3-LISP has no quantificational operators. Nevertheless. we contend that the insights won on the behalf of 3radical~ will ultimately prove useful in the development of more generally reflective systems.

however. in general and in the computational case. Introduction Procedural Reflection 35 l. on the other hand. certainly it would seem that most of what we take computational systems to do is attn-billed. For example. you would have some reason to claim that you had demonstrated computational reflection.1. Thougl1 we will work with this larger goat in mind. in a way that is radically different from the situation regarding our interpretations of the actions of other people. In particular. On one reading this tenn might refer to a successful computational model of general reflective thinking. 2 For example. it: as you read this. humans arc first-class bearers of what we might call semantic originality: they tllcmselves are able to mean. we take no position on whether computational processes are able to "think" or "reason" at all. in the sense of a computational process that exhibited authentic reflective activity. Before presenting any of that preparatory material.b. to the extent they can be said to mean or refer at all.b. in virtue of some human finding that a convenient description (we duck the question as to whether it is a convenient truth or a convenient fiction). The Concept of Reflection In the present section we will look more carefully at what we mean by the tenn "reflection". we will also specify what we would consider an acceptable theory of such a phenomenon. In particular.e the attendent model of computation on which it is based. we do well to know where we are headed. after discussing in section I. Computational processes.e. they do so derivatively.d our conception of computational semantics. arc at least not yet semantically original. you rationally and intentionally say . and were then able to construct a computational model embodying or exhibiting such behaviour. and in section l. if you were able to formulate what human reflection comes to (presumably more precisely than we have been able to do). J. we will consider in more detail what we mean by the more restricted phrase "computational reflection". without some observer having to attribute meaning to them. our use of the term will be more modest. The structure of the solution we will eventually adopt will be presented only in section I.L The Reflection and Representation Hypotheses In the prologue· we sketched with broad strokes some of the roles that reflection plays in general mental life. In order to focus the discussion.

b. but we should admit at the outset that the focus of our investigation will be almost entirely 011 the "selfish" part of reflection: on what it is to construct computational systems able to deal with their own illgredient structures and operatiolls as explicit subjcct matters.: reference and meaning and so on arc paradigmaticatly and definitionally what people do. or dcrivately ascribed.vith the reflection hypothesis.ses for deeper reasons. such as that this is an easier and better-constrained subject matter (since after all we are in no position to postulate models of thinking about external worlds).". for similar purposes. The reflection hypothesis spelled out in the prologue. the computer has not referred to Scotland in any full-blooded sense: it hasn't a clue as to what or where Scotland is. In sum. we will consider interllal or interior processes able to reflect on interior structures. and I supply the reference relationship between that spelled word and the country in the British Isles. again having to do . you succeed in referring to this section. However in fact this restriction in scope al. we find it convenient 10 describe as reasoning reflectively. On the other hand. This is one major reduction in scope. and it tells me that it is on the west coast of Scotland.. TIle reasons for this constraint on our investigation are worth spelling out. wiithout the aid of attendant observers. in the prologue. the rest is hypothesb. First. . it could be made to reason reflectively in a certain fashion. Again. which is the only world that those internal processes conceivably can have any access to. Introduction Procedural Reflection 36 ttl am now reading section I. and falsifiable theory. we spoke of reflection as if it encompassed contemplative consideration both of one's world and of one's self: We will discuss the relationship between reflection and selfreference in more detail below. we immediately adopt another. It might seem as if t11is restriction arises for simple reasons. You do so because we define the words that way. about how computational models of reflection might be constructed. it has typed out an address that it probably stored in an ASC:II code. if I inquire of my home computer as to die address of a friend's fann.1. we avoid completely the question of whether the "reflectiveness" embodied in our computational models is authentically borne. In other words your actions are the definitional locus of reference. embodied this cautionary stance: we said there that in as nluch as Q computational process can be constrocted to reason at all. we will construct a particular kind of LISP processor (interpreter). For example. Rather. Thus our topic of computational reflection will be restricted to those computational processes that.

1. consisting of an ingredient process in northern Canada. genuine reflective thought. then when I think. it is important to reiterate. especially in conjunction with the representation hypothesis. For consider: if it turns out that P whatever) internal computational structures. P will reflect on the knowledge structures this would be an representing Virginia Falls (in some weird and wondrous way) - unhappy proposal. which. our exclusive focus on sf!lfreferential aspects of those processes is all we can do (given our two governing hypotheses) to uncover the structure of constituted. in other words. I am a computational system. as an explanation of the mechanism of reflection.the subject matter to be explained . because we are focussed on the behaviour of interior processes. What do we suppose that my processor p is doing now? Presumably F ("presumably". Rather. . is its tacit assumption that the computation engendering reflective reasoning. engender more complex processes that interact with the world. but rather in virtue of running programs. at least. say. This "interior" sense of language processors interacts crucially with the reflection hypothesis. Introduction and LISP Procedural Reflection 37 processors have no access to anything except fields of LISP s-expressions. we are under no compulsion to believe) my processor manipulating representations 0/ my representations of Virginia Falls. my ingredient processor p manipulating formal representations of my knowledge of the world. is now In other words. according to the knowledge representation hypothesis. Suppose. On the other hand LISP processors are crucially interior processes (in a sense that will be made D clear in the next section): they do not interact with the world directly. in the circumstance just described. that I back off a step and comment to myself that whenever I should be writing another sentence I have a tendency instead to think about Virginia Falls.should presumably not occur as a phenomenon in the explanation. The most important feature of the reflection hypothesis. Not only can we restrict to our attention to ingredient processes "reasoning about" (computing over. about Virginia Falls is manipulating representations that are about Virginia Falls. that L'le interior process compute over a different kind of sYlnbol. since it would not otTer any hope of an explanati()n of reflection. Reflective behaviour . We can put this same point anoUler way. then. we can restrict our attention to processes that shift their (extensional) attention to meta-structural terms. the reflection hypothesis is at once much stronger and more tractable (altllough perhaps for that very reason less plausible): it posits. The reflection hypothesis docs not state that. not on compositionally constituted processes.

for it is only because of it that we have any right to call our inquiry a study of rejlection.~rly proceed over nonna! structures. I.' Reflection in Computational Fonnalisms With these preliminaries set straight. or whether free variables ure dynamically seoped. etc. such as LISP and ~s SNOBOL. it is our methodological allegience to the knowledge representation hypothesis that underwrites our self-referential stance. ete..b.. .. constructed. although a need for some sort of reflective power has appeared in a variety of contexts (such as for over-riding defaults. INTERLISP. 1Ibough we will not mention this meta-theoretic position further. and in all representation languages. the problem derives from the fact that in traditional computational p~ocess fonnalisms the behaviour and state of the interpretation are not accessible to the reasoning procedures: the interpreter fonns part of the tacit background in tenns of which the reasoning processes work. and manipulated as first class entities. In more representational or declarative contexts no such mechanism has been demonstrated. in the majority of programming languages. is nonetheless similar in kind to the sorts of computation that regur. defeats portability and coherence. only the un-interpreted data structures are within the reach of a program. In sum. to the question of what it would be to make a computational process reflective in this sense.3 ). At its heart.1. Therefore such matters as whether the interpreter is using a deptll first control strategy. remain by and large outside the realm of reference of the standard representational stntcturcs. or how long the current problem has been under investigation. although such a solution is inelegant in the extreme. gracefully handling contradictions. rather than a (presumably less interesting) study of computational selfreft'rence. or what caused the interpreter to start up the current procedure. we may turn. A few languages.. extend this basic provision by allowing program structures to be examined. and in general exl1ibits a variety of mis-features we will examine in due course. What has never been provided a high level language in which the process that u interprets those programs is also visible and subject to modification and scrutiny. Introduction Procedural Reflection 38 although it may be over a different kind of structure. it is crucial that it be understood. lacks generality. Pfhus. then. One way in which this limitation is partially overcome in some programming languages is to allow procedures access to the structures of the imp/emellta/ioll (examples: MOL.).

From an intuitive point of view it doesn't seem unreasonable to say. "you should make checking capacitors your first priority. 1110Ugh we are skirting close to the edge of an infinite regress. it is clear that something like this kind of protocol is a natural part of nonnal human conversation.p p (51-1) Though it isn't difficult to build a problem solver that embodies some such behaviour (at least on some computable reading of "not provable"). for instance.. and that.. you should assume that il works". All sorts of technical questions arise. that we were given a monotonic nawral-dcduction based theorem .. independent of context or domain. in virtue of being written down. or. Suppose. having to do with. or with whether other less heuristic approaches have been tried first instances of something like 51-1 What we are after is a way to write down specific that refer explicitly both to the subject domain and to the state of the deductive apparatus. usually constraints on when such inferences are appropriate. what language to use. There are. the question is whether we can make lonnal sense out of this intuition. or even to whom such a statement should be directed. it is sometimes suggested that a default should be implemented by a deductive regime that accepts inferences of the following non-monotonic variety: . how crucially the problem needs a reliable answer. lead that inference mechanism to behave in the way described. it would be sufficiellt 10 establish thai )'OU cannot prove its negation. one typically doesn't want such a rule to be obeyed indiscriminately.. One can imagine that it would be useful to have inference rules of the following sort: "unless you have been told that the power supply is broken. Particular examples are easy to imagine. "By the "'ay.1. if you ever want 10 aSSUlne p. since they are more likely to break down than are resistors". Consider. but of h01V to say it (say. a computational process designed to repair electronic circuits. Introduction Procedural Reflection 39 A striking example comes up in problem-solving: the issue is one of enabling simple declarative statements to be made about flOW the deduction operation should proceed For example. for example. t. and that genuinely affects its behaviour. without each time requiring surgery on tile inner constitution of the inference engine. in other words. Furthennorc. to some kind of theorem-prover) in a way that doesn't lead to an infinite regress. for example. we would like ensure that such rules could be modularly and flexibly added and removed from the system.". It is not obvious.. It is clear that the problem is not so much one of what to say. say.

but rather to build a monotonic one prepared to reason about a non-monotonic one. and various dialects of Inlpcrial College6 PROLOG 51-1. and to talk explicitly about the set of sentences derivable from other sentences. Another option would be to build a non-monotonic inference engine from scratch. then "p" is. But this would to solve the problem by avoiding it . such a program is readily perhaps most clearly the Ie-PROLOG are best viewed in this light The problem with such solutions. There are various ways we could encode it as a sentence . no system claiming to be of just this sort has been demonstrated.the whole question was how ~{et use SUC11 comments on would be to Although of the reasoning procedure coherently within the structures of tile problem-specific application. is not in a certain set. . However.. To do this would not be to construct a non-monotonic reasoning system.. in which the behaviour of the inference process is controlled. they are best understood as separate aspects. but to meta-theoretic expressions of the form imagineablc.. it wouldn't make the current inference mechanisnl behave non-mollotonically. at least on the face of it. What a PROLOG user is given is not a unified or reflective system.p. Although the elements of the two languages are mixed in a PROLOG program. and then to say that if the sentence . and so forth) constitutes the declarative language. like the abstract specifications of a program. it doesn't help us. another possibility and one we will focus on for a moment - design a more complex inference mechanism to react appropriately not only to sentences in the standard object language. although such a sentence might contribute to a model of the kind of inference procedure we desire. the identity of the variables. with the question of hOlY a system using defaults might actually be deployed. but a pair of two largely independent fonnal systems: a basic declarative language in which facts about the world are expressed. While such a fonnulation might be of interest in the specification of the constraints a reasoning system must honour (a kind of "competence theory" for non-monotonic reasoning4)..1. is their excessive rigidity and inelegance. Could we give it 51-1 Procedural Reflection 40 51-1. . the "consumer" and "producer" annotations on the variables. Introduction prover for first order logic. and a procedural language. the "cut" operator.one way would be to use set theory. at least in the form given above. Another (the sequential ordering of the sentences and of the predicates in the premise. as an implication? Certainty not. with the standard semantics of first-order logic. using expressions like 51-1 to constrain its behaviour. is not even a well-fonned sentence. however. coupled with the fact that they don't reatly solve the problem in any case.. One set (the clause and implication and predicate structure.

as it happens. a meta-theoretic description of the system would have to describe only one formal language. in the same language and subject to the same semantical treatment. It would surely be far more elegant to be able to say. the reflective capabilities could recurse without limit (in PROLOG and other dual-calculus sytcms there is only one level). Thus the claim that to use PROLOG is to "program in logic" is rather misleading: instead one essentially writes programs in a new (and. in the sense that a procedurally reflective calculus is by no means a fully reflective one. rather than having to be extracted from procedural code.CHARLES) andCUT(CLAUSE-13) or DATA-CONSUMER(VARIABLE-4). this kind of dual-calculus approach seems ultimately rather baroque. to continue with the PROLOG For example. in the same language as the target world is described whatever it was salient to say about how the inference process was to proceed example. However. using an encoding of tirst-order logic as the declarative representation language. . Introduction Procedural Reflection 41 and so forth) constitute the procedural1anguage. and clarity of semantics that would result are too obvious to belabour: just a moment's thought leads to one realise that one a single semantical analysis would be necessary (rather than two). Of course this is a dual system with a striking fact about its 9rocedural component: all conclusions that can be reached are suaranteed to be valid implications of prior structures in the' representational field. one would like to say both The increase in elegance. even this more modest notion is on its own a considerable subjcct of inquiry. so that they may take their natural effect as part of the tacit background in which the reasoning process works this ability is a particular form of reflection we will call procedural reflection ("procedural" because we are not yet requiring that those structures at the samc time describe the reasoning behaviours they engender: that is a larger task). l1tough ultimately limited. and so forth. as was mentioned above. \vould be immediately available.1. The ability to pass coherently betwecn two situations: in the reflective case to have the structures that nonnally control the interpretation process be fully and explicitly visible to (and manipulable by) the reasoning process. descriptions of the inference mechanism. and is certainly not conducive to the kind of reflective abilities we are after. but this is just like saying that the flow of control of an ALGOL program is affected by the data strnctures. Of course the flow of control is affected by the declarative aspects. expressive power. and in the other to allow the reasoning process to sink into them. not two. rather limited) control language. FATHER(BENJAMIN.

including itself . in other words. Although any abstract machine of Tuiing power can provably model any other . repeat my ignominious performance - it in other words. What we need is a theory of the causal powers required in order that a system's possession of self-descriptive and ~elf-mode11ing abilities will actually matt~r to it . for example. from description to reality. Suppose.our solution features might talte. of a.iiL Six General PropertiesofRejlection Procedural Reflection 42 Given the foregoing sketch of what our task is.there can be no sense in which such self-modelling is even noticed by the underlying machine (even if we could posit an animus ex maclzina to do the noticing). before plunging into details. it is appropriate to ask. just as the result of reflecting has to affect future non-reflective behaviour. we are dealing with artefacts behaviourally defined. if I merely smile in vacant pleasure at an image of an improved me. ' Similar requirements of causal connection hold of human reflection. you simply cannot afford simply to reason about yourself as disinterestedly and inconsequentially as if you were someone else. that we will expect our ultimate solutions to exhibit. It: on the other hand. the n'!tion is one of self-reference. In addition. stronger titan the'Dotions explored by mathematicians and ph~osophers over much of the last century. Six properties of reflective systems can be identified straight away or explained.1. Iny rejlective contemplations have no effect on my subsequent behaviour . we aim to build a computational system of substantial . we will have to build something that if. causally-connecied kind. The move has to be made. reflective powers. however they end up being structured First. actual ~ehaviour is our ultimate subject matter. Introduction l. whether we have any se~se in advance of what form . that after taking a spill into a river I analyse my canoeing skills and develop an account of how I would do better to lean downstream when exiting an eddy. Coming to this realisation is useful just in so far as it enables me to improve. but then. unlike systems of logic which are functionally defmed abstractions that in no way behave or participate with us in the temporal dimension.b.a req\lirement of substance since full-blooded. so does prior non-reflective . not simply the mathematical characterisation of formal relationships.then my refl~ction will have been worthless. affected by its ability to "think about itselr'. In dealing with computational processes. This holds no matter how accurate the'self-descriptive model may be.

so that a reflective program can straightforwardly refer to the continuation of the process below it) Furthennore.1. as has often been remarked.ng inappropriately in some fashion).to do with self-knowledge. Second. the relationship between reflective and non-reflective behaviour must be of a fonn suel} that both information and effect can pass back and forth betwee~ them. I had been unable to remember what I had been doing just before I capsized. . and thereby obtain access to the reasons that were marshalled in support of the original decision. you have to make it true that when the situation does arise. (An example is the issue of providing continuation structures to encode control flow: we will provide separate continuation structures for each reflective ltvel. we will have to provide the ability to drop down from a reflected state to a non-reflected one. It would have been equally futile it: when I paused initially to reflect on the cause of my d:Jnking. to take another example. These requirements will impinge on the technical details of reflective calculi: we will have to strive to provide sufficient connection between reflective and non-reflective behaviour so that the right causal powers can be transferred across the boundary. Introduction Procedural Reflection 43 behaviour have to be accessible to reflective contemplation. that you decide at some point in your life that whenever some type of situation arises (say. and to review what has happened in the past when you have let your basic tendencies proceed unchrcked. the interactions can become rather complex. one must also be able to move from reality to -description. as is the case ill any theoretical endeavour. without falling into the opposite difficulty of making theln so interconnected that confusion results.altllough just what remains to be seen . but we will also have to provide a way in which a designator of the lower level continuation can be bound ill the environment of the higher one.l ref~rcnce theory-r~:ative. having left the base level tiystcm in suetl a state that when certain situations occur the system will automatically reflect. to avoid unwanted interactions. The dispassionate fellow that you must now become is one that ~lnbodies a decision at SOlne future point 10 reflect. Just as one cannot interpret the worid except by using the concepts and categories of a theory. one cannot reflect on one's self except with to a theory of oneself: Furthennore. without acting in a self-conscious way from now until such a circumstance arises. Similarly. when you start behavi. Somehow. as well as with self"re!erellce. In sum. that you will pause to calm yourself down. in our technical form. and knowledge. you will have left yourself in a state that will cause the appropriate reflection to happen. is inherentl.disms. Suppose. retlection has something .

since there arc various senses (other recent research reports not withstanding8 ) in which no computational process. i but causally connected in novel ways). In the more common case. LISP theories.class objects. since environments as such LISP'S. don't exist in non-reflective I-Iowcver. There are other possible we have chosen. other objects would probably be posited instead: in order to reflect you have to use associated theoretical entities. even though those entities cannot be claimed to have a theory-independent ontological existence in the behaviour being explained. It is impossible in a non- reJ1ective LISP to define a predicate true only of environments. But the point is that in building a reflective model based on this alternative theory. Introduction Procedural Reflection 44 the phenomena under consideration under-detennine the theory that accounts for them. In other words. represented in its own internal language.. you must inevitably do so in a somewhat arbitrary theory-relative way. One of the mandates we will set for any reflective calculus is that it be provided. once we endow our particular dialect 'Nith reflective powers. when only parts of the phenomenal field are to be treated by the theory. in which many common not!Qns of LISP (such as the notion of an environment just mentioned. even when all the data are to be accounted for. as opposed to "reflex i veil. can :Juccecd narcissistically in thinking about the fact that it is . TIleoretical entities may be posited by this account that facilitate an explanation of behaviour. SOllIe theory and its The third general point about reflection regards its name: we deliberately use the term "reflectiveil. some of which differ radically from the one It is possible. even thougll they are not first-class objects of the language in any direct sense. we will adopt a standard account. 3-LISP will be provided with a "theory". when you reflect on your own behaviour. the notion of an environment will be crucial. in 3-LISP. with a complete (in some appropriate sense) theory of how it is fanned and of how it works. an even wider set of alternative theories emerge as possibilities. in any sense that this author can understand. to replace the notion of environment altogether (note that the A-calculus is explained without any such device). and environments will be nassed around as first. In providing this primitively supported reflective model. and a pat·alle) notion of a cOlltinuation) play a central rolc.1. for example. of 3-LISP (reminiscent of the meta-circular interprcter3 demonstrated in McCarthy's original report6 and in the reports of Sussman and Stee!o. For example.

much of the technical work . without violating the ultimate truth that not everything can be made explicit in a finite mecllanism. it is a truism that there is ultimately no escape from being the person in question. What was previously an inexorable stepping from one state to the next is opened up so that each move can be analysed. This leads us to the fifth general comment.) The fourth comment is that. in virtue of reflecting. Thus simplicity and flexibility can be achieved together. albeit in a controlled and useful way. being replaced by an (albeit possibly complete) account of itself. and so forth. the "mind's eye" moves out of its own view. or an utterly objective vantage point from which to view either oneself or the world. From the fact of having a name for itself it does not automatically acquire the ability to focus on its current instantaneous self. implement. and at the same time provide (through reflection) the user with the ability to modify or adjust the behaviour of this kernel in peculiar or extenuating circumstances. Introduction Procedural Reflect. which is tllat the ability to reflect never provides a complete separation. (Though this description is surely more suggestive than incisive.and so on and so on.. The kind of reflecting we will consider the kind that we will be able technically to define. and control t requires that in the act of reflecting the process "take a step back" in order to allow the interpreted process to consider what it was just up to: to bring into view formal symbols which describe its state "just a mODlent earlier"..1. lbough we will generally downplay any connection between our farinal work and human abilities. a process can always obtain a finer-grained control over its behaviour than would otherwise be possible. No matter now reflective any given person may be. like a transparent eye in a room full of mirrors. we can perhaps allow that tile kind of reflection we arc nlodelling is closer to what is known as delachtne1l1 or awareness than to a strict kind of self-objectivity (this is WilY we are systematically and intentionally imprecise about whether reflectioll is focused on the self or .ion 45 at that very instant thinking about itself thinking about itself thinking . for in the process of "stepping back" or reflecting. countered. This ability enables a system designer to satisfy what might be taken as incolnpatible demands: the provision of a small and elegant kernel calculus. with crisp definition and strict behaviour. In other words we will see in great detail how reflective powers in fact provide for a more subtle and more catholic - if less efficient way of reacting to a world.to be presented will allow us to make it precise. The requirement here is as usual for what was previously implicit to be made explicit. .

ction: you and I can interrupt au l' conversation in order to sort out the definition of a contentious term.we do so using other tenns. a new background fills in to support the Again. being reflective is a stronger requirement 011 a calculus than simply being able to model the calculus in the calculus. The reason for this claim is that. we cannot step out of it to view it from a completely independent vantage point Similarly. The environment example just mentioned provides an illustration of this in a computational setting.1. As well as "backing up" in order to reflect on its thoughts. the ability to reflect is something that must be built into the heart or kernel of a calculus. The operation of reflecting makes explicit what was just implicit: it renders visible what was tacit In dojng so. so that (for example and very roughly) when a process "decides to assume something". Since language is our inherent mediWll. As we will see ill detail. in other words. There are theoretically demonstrable reasons why it is not something Wllich can be "proArammed up" as an addition to a calculus (although one of course can illiplement a reflective machine in a non-reflective one: the difference between these two must always be kept in mind).. in accord with the consequences of those reflections. while the systems we build will at any point be able to back up and mention what was previously used. comes in connecting the self-model to the basic interpretation functions in a causal way. This will be demonstrated in detail. rather than simply constructing a model or self-description or hypolhesis that says that it is in fact assuming it. something any machine of Turing power is capable of doing (this is the "making it matter" that was alluded to above).. in doing so more structures will come into implicit use. Introduction Procedural Reflection 46 on the world). and such connections cannot be "programmed into" a calculus that does 110t . reflection. the same is true of human refl. Both parts of L'lis involve a causal support them connection between the explicit programs and the basic workings of the abstract nlachine. of course. in the nermal (non-reflective) course of events - unable to access it explicitly. at any level. certainly Quine's lesson of Ncurath's boat holds as true for the systems we design as it does for us designers. the environment in which are bound the symbols that a program is using is. but . 9 Sixth and finally. has been a major one in philosophy at least since Peirce.as has often been remarked . merely part of the embedding background in which the program is running. as suggested above. however. to consider tile world directly.. it in fact assumes it. the process needs to be able to "drop back down again". dependent on it but The program operates within that background. This lesson. the crucial difference. as discussed in the first comment.

from our consideration. incompleteness. we want the process as a whole to be able to refer. But by and large the system of levels we will adopt will exclude such local self-reference.b. of course. we will also make evident the fact that the designation of any given expression is a function not only of the expression itself: but also of the state of the processor at the point of use of that expression.use of the knowledge representation hypothesis. First.ery different our concerns will be from these more traditional studies. especially since it has been exactly in these areas where the major results on paradox. are undeniably problematic (strictly. . with the self-rejerential aspects of reflective behaviour. We do not typically want specific structures themselves to be self-designating. exactly to avoid many of the intractable (if not inscrutable) problems that arise in such cases. l. particular expression or structure. however we could use instead the composite term This five word noun phrase'? It None of these truths impinge particularly on our quite different concerns. to ils whole self. There has been in the last century no lack of investigation into self-referential expressions in formal systems. undecidability. . there is no doubt in our work that we consider the locus of re!e"ing to be an entire process. and so forth. although in fact this usually reduces to a question of it refering to some of its own ingredient structure. practically if not formally. are unarguably odd. Truly self-referential expressions. Introduction primitively. such as the cliched This sentence is false. and certain instances of them. then. Even though we will posit declarative semantics for individual expressions. Two facets of the computational situation show how -. the symbol does not use itself: To the extent that we want our system to be self-referential. not a . It will be perfectly possible to construct apparently self-designating expressions (at least up to type-equivalence: token self-reference is more difficult). the sentence "This sentence is six words long" cOlltains a self-reference. but is not itself self-referential. Reflection and SelfRejerence Procedural Reflection 47 At the beginning of this section we said that our investigation of reflection in general would primarily concern itselt beca. And of course it is the processor that uses the symbol. have arisen. to first approximation. We should therefore compare our enterprise with theSe theoretical precursors. although we do not formalise this.iv. such as This sentence is six words long.1.

Morc generalJy. rather. which may make it clearer. Suppose that HI is some handle. . Suppose that. The sentence "This sentence is six words long" doesntt actually refer. in any causal full-blooded The causal reference relationship between that sentence as sign. Introduction Procedural Reflection 48 The second major comment is this: in traditional formal systems the actual reference t relationship between any given expression and its referent (be that referent itself or a distal object) is mediated by the externally attributed semantical interpretation function. is the following: (51-3) . informally. take to be a reference relationship. called a handle (a canonical fonn of meta-descriptive rigid designator) and another symbol that. the semantical import of that relationship remains external. strictly speaking the relationship between HI and 51 is an internal But the causal relationship relationship. to anything. in constructing reflective computational systems it is crucial that we not defer causal mediation through an external observer. in 3-lISP there is a primitive relationship that holds between a certain kind of synlbol. we know that: :I [:=:( n) = s)] :J [cfl( H) s]] (51-2) However this equation. flows As we said in the previous section about causal connection. between and 51 must be inlern~l: otherwise there would be no way for the internal computational processes to treat that relationship i~ any way that mattered. is "1 the externally attributed semantical interpretation function. to use the prior example. even if the semanlica! understanding of that causal connection is externally attributed f"or example. More revealing of the fact that we take the relationship between handles and referents to be a relationship. each handle designates. that we. We can put this a little more fonnally. as external semantical attributors. as well as VH• 5 [[ HANOl E( H)] A [Z(H 1 ) = 51]. Until we can construct computational systems that arc what we called semantically original. if we arc allowed to reify relationships. though in some sense strictly true. Reflection in a computational system has to be causally connected. and tllat Z is the primitive function that relates handles to the structures we call their referents. in no way reveals the structure of the relationship between r~fcrellcc cI» and Z. it merely states their extensional equivalence. we English speakers lake it to refer to itself: through us. and that sentence as significant. sense.1. Thus we have. [4»(H 1) = SI]. and tltat 51 is some structure that "1 refers to.

Procedural Reflection 49 rather. . Put another way. until then we will have to content ourselves with causally original but selnanlically derivative systems. as: (51-4) The requirement that reflection maller. and once internally so that the appropriate causal behaviour. in the inchoately semantical computational systems we are presently able to build. since it would appear that mattering . since not all symbols are handles. On that day when we succeed in constructing semantically original mechanisms.1. Introduction Of. to which we attribute semantics. What is striking is that the mattering cannot be derived from the semantics. The reflective dialects we will examine wilt all be of this form. not something that can fOllow the semantical relationships.are a precursor to semantica1 originality.one without precedent in pre-computational formal systems. is a crucial facet of computational reflection . to summarise. those two presently independent causal connections may merge. the reference relationships between internal meta-level symbols and their internal referents (these are the semantica1 relationships that are crucial in refleCtive considerations) may have to be causal in two distinct ways: once mediated by us who attribute semantics to those symbols in the first place.real causal connections . can be engendered.

we may assume that a process consists approximately of a connected or coherent set of events through time.c. although they must have temporal extent Whether there are' more abstract dimensions in which in is appropriate to locate a process is a question we will side"step. Thus the set of events that collectively form a coherent process in a given world will all be events on the surface of this abstract object. (Sl-6) PROCESS P It is crucial to distinguish more and less fine-grained accounts of the surt1ce of a process. on the other. In any given circumstance this set of evcnt~ could presumably be more or less specifically described: we might simply say that the process had certain gross input/output behaviour (Uinput" and "output" would have to be defined as surface perturbations of a certain class: this is an interesting but non-trivial problem). we will rely· more on example t and on the uses to which we put these objects. although not distinguishing. mark of computer science. including tile exact temporal relationships between one event and the next. which is the interface between the process and the world in which it exists (we presume that in virtue of objectifying processes we carve them out of a world in which they can then be said to be embedded). The reification of processes as objects in their own right - composite and causally engendered .1. AProcess Reduction Model ofComputation We need to sketch the model of computation on which our analysis will depend. The icon is intended to signify what we will call the boundary or surface of the process. from compositional accounts of its interior. Processes are inherently temporal. as in the following diagram. since this entire characterisation is by way of background for another discussion. on the one hand. '"Ibat a process has an interior is again a striking assumption throughout computer science: the role . or we might account in tine detail for every nuance of the process's behaviour.is a distinctive. though we will not define the concept precisely. and so forth. Introduction Procedural Reflection so l. than on explicit formulation. but not otherwise physical: they do not have spatial extent. We take processes as our fundamental subject matter. We will often depict processes as rough-edged circles or balls.

is more the role of physics or electronics than computer science per see What is critical is that at some stage in a series of computational reductions this leap from the domain or processes to the domain of mechanisms be taken. It: for exalnple. . There may be more than one internal process (in what are known as para/lei or conconcurrent processes).on of a computational process. that micro-code processor interprets a set of instructions that arc the program for a macro-machine. then an entire hierarchy of processes above it may obtain indirect realisation.1. Reductions of processes which do not posit an interior process as the source of the agency we will consider outside the proper realm of computer science. Rather. There are a variety of architectures dissertation on just one of these. It is for this reason that we can this model a "process reduction" model of computation. Suppose for instance that you interact with a so-called LIsp-based editor. in conjunction with some appropriate behavioural surface with which you interact. together engender the Every computational process (we will examine in a moment which processes we are disposed to call computational) has within it at least one other process: this supplies the animate agency of the overall constituted process. However this kind of reduction from process to. then a Dlacro"processor may thereby exist. since at each stage of computational reduction a given process is reduced in terms of constituent symbols and other processes. that macro-machine may interpret a machine language program tllat implements reduction) a SNOBOL SNOBOL: thus by two stages of COI"position (the inverse of processor is also realised. Similarly. we will briefly mention just two. behaviour of physical mechanism. or there may be just a single one (known as serial processes). say.l-te editor. although of course some such reduction must at some point be &ccounted for if the engendered process is ever to be realised. Given this one account of what we may call the reillisat. or classes of architecture that computer science has studied. but will focus throughout the LISP processor. On the other hand that process never appears as the surface of the editor: no editor interaction is directly an interaction with the processor. as for example in the explaining how the behaviour of a set of logic circuits constitutes a processor (interpreter) for the micro·code of a given computer. the IISP liSP program. It is standard to assume that the LISP interpreter is an ingredient process within the process with which you interact: it in fact is the locus of anima or agency inside your editor process that supplies the temporal action in t. Introduction Procedural Reflection 51 of interpreters (what we will call processors) is a striking example.

to the messagepassing metaphors in such AI languages as ACTI and SMAllTALK. we discuss them here only in order to admit that the model of reflection tllat we will propose is not (at at lcast at prescnt) sufficiently general to encompass them. although that term is so semantically loaded that we will avoid it for the time being. can be interpreted as) the behaviour of the P Responsibility for the surface of the total process is presumably shared in some way amongst me five ingredients. Examples of this sort of reduction may be found at any level of the computational spectrum. . The second is the program or clata stnlclures (or both): it is often c.e. from metaphors of disk-controllers communicating with bus mediators communicating with central processors. and so forth. we show in the following diagrams two quite different forms of computational reduction: what we will call a communicative reduction and an interpretive reduction.·ocess is composed of what we will call a 1'1 • processor and a structural/ield. The first ingredient is the locus of active agency: it is what is typically called an "interpreter". We will focus instead on the far more common model that we call an interpretive reductioll.1. thus in processes.alled a set of sYJllbo!s. tO (51-6) Communicative reductions will receive only passing mention in this dissertation. The arrow is intended to mean "reduces to". In such cases the overall p. behaviour is (i. 51-6 we imply that process P reduces to a set of five interior What it is for processes to communicate we will not say: the assumption is tota~ merely that these five ingredient processes interact in some fashion. Introduction Procedural Reflection 52 In order to make this talk of processors and so forth a little clearer. pictured in the following diagram.. although we avoid that term because of its confusio!l with notions of interpretation from the declarative tradition (we will have much more to say about this confusion in chapter 3). so that taken as a composite unity their constituted process.

1. and so forth) elements of the structural field.. reacts to. The structural field of LISP consists of what are known as s-expressions: a combination of pairs (binary graph elements Gf a certain fonn)t atoms. etc. which includes statements. Introduction Procedural Reflection S3 (51-7) All of the standard interpreted languages are examples of this second kind of reduction. We the tables that list current balance. and so on - the structural field of process that you are building. P. CHEQUERS fORTRAN might call those data structures - interest rate. manipulates. recent deposits. and programs arc static. FORMAT you set out to build a do is specify a set of FORTRAN program to manage your financial affairs: what you would data structures and a process to interact with them. is a process. interpretive model to underwrite both language design and the construction of particular programs. however. For example. numerals. The program that you want to interact with this data base we will simply call first reduction of CHEQUERS Thus the would be pictured in our model as follows: (51-8) CHEQUERS We have said. that because P p is specified by a p FORTRAN program (p is not itself a program. requiring interpretation by a processor in can itself be understood in tcnns of a reduction in order to engender behaviour). Suppose that primarily an ordered sequence of FORTRAN instructions. and so forth. FORTRAN constructs. We intend the. we can characterise tenns: we will posit a FORTRAN FORTRAN in these processor that computes over (examines. of which LISP is as good an instance as any. Thus .

1.ond. First. by the computer science tenn interpreter (again. processor Thus we have a dOllble reduction of the following sort: (51-9) FORTRAN PROCESSOR CHEQUERS There are a host of questions that would have to be answered before we could make this precise (before. Suppose we consider the compiler that compiles IBM 360. which when processed by the yields process P. Sec. The reason that we call the process that interprets LISP programs an interpreter is because LISP programs are structural field arrangements that engender other interior processes that work over data structures so as to yield yet other processes. into the machine IBM language of the '[hen the compilation of some FORTRAN program cF into an . by a compilation we refer to the transformation or translation of a stnictural field arrangement 51 to another structural field arrangement 52' so that the surface of the process that would be yielded by the processing of 51 by some processor Pt is equivalent (modulo some appropriate equivalence metric) to the processing of 52 by some processor P2. For example.or") we refer to a process lhat is the interior process in an illterpretive reduction of another interior process. the process p in the check-book example was not an interpreter. define a variety of commonplace terms of art of computer science. the data structures in the foregoing example are themselves have to be implemented in FORTRAN as welL However to fill out the model just a little. we can suggest how we might. we could construct an adequate mathematical treatment of these intuitions). because it was the ingredient process only singly: the process lhereby constituted. for example. we spoke ~bove about a FORTRAN processor. was not itself an interior process. in these terms. Introduction Procedural Reflection FORTRAN 54 terms of the program c ("c" for "coden). Hence p fails to be an interpreter. For example. we use instead "proceStc. but of course such a processor is rarely if ever realised: rather. Wl1ich we called CHEQUERS. For example. fORTRAN programs arc typically compiled into some machine FORTRAN language.

one implements a language by providing a process implement LISP.) Finally. will yield a process whose surface can be taken as a processor for the interpreted language. of the implemented field. just because a given computational model predicts the most tninute temporal nuances revealed by click-stop . A weak computational model of some mental phenomenon would be a computational process that was claimed to be superficially equivalent to some mentai behaviour. More interesting is to implement a language (by a architcctu~e computational Iangge we mean an of a structural field and a behaviourally P specified processor that interprets arrangetnents of such a field). (By a program we refer to a structural field arrangement . and by constructing a program in the implementing language that. Thus compilation is relative to two reductions. with respect to that encoding of the implemented language's structural field. one language is implemented in another by constructing some arrangement or set of protocols on the data stmctures of the implementing language to encode the structural field of the implemented language. if any. Note that surface equivalence of this sort can be arbitrarily finc-grained.vithin an interior processor i. Thir~ by implementation we typically refer to two kinds of construction. alld is mandated only to ensure surface-surface equivalence. to the inner structural field of a double reduction . Typically. we can irnagine how this model could be used in cognitive theorising.e. that can be reduced to the structural field and interior processor of the language being implemented.. all I am required to In other words if I do is to provide a process that behaviourally appears to be a constituted process consisting of the LISP structural field and the interior LISP processor.since programs are structures that are interpreted to yield processes that in turn interact with another structural field (the data structures) so as to engender a whole constituted behaviour.1. when processed by the implementing language's processor. Thus I am completely free of any actual commitment as to the reality. In its most general form. Introduction 360 Procedural Reflection 55 machine language porgram C360 would be correct just in case the surface of the process that would result from the processing of CF by the (hypothetical) FORTRAN processor would be equivalent to the process that will actually result by the processing of C3BO by the basic IBM 360 machine language processor. To implement a process simply means to construct a structural field arrangement S for some processor P so that the surface of the process that results from the interpretation of s by p yields the desired behaviour.

This has been the briefest of sketches of a substantial subject Ultimately. Introduction Procedural Reflection S6 experiments and so forth does not imply that anything other than surface equivalence has been achieved In contrast. We count as computational. The main constituents of a car I understand in . First.. only those processes consisting of ingredieot structures and events to which we. for example. a strong computational model would posit not only surface but interior architectural structure. the A-calculus. can be explained only because this local accessibility constraint is violated (otherwise it would be a perfectly well-defined construct). Thus for example Fodor's recent claim of mental modularity11 is a coarse-grained but strong claim: he suggests that the dominant or overarching computational reduction of the mental is closer to a communicative than to an interpretive reduction. no such locality considerations come into play. demonstra~es: In addition. for the present investigation. attribute scmantical import. Why it is that the well-known joke about a COME-fROM statement in FORTRAN is funny. but in this analyses. as external observers. The reason that I do not consider a car to be a computer. Second .1. arises exactly from this question of the attribution of significance.1jJ/ be locally continuous. we can think of the processor looking at the structural field with a pencil-beam flashligh~ able to see and react only to what is currently illuminated (morc fonnally. as LISP from the fact that A is accessible from B it does not follow that B is accessible from A. it should be fonnalised into a generally applicable and mathematically rigourous account. However there are three properties of all structural fields that are important for us to ma~e clear. in ~articular. and so forth.and this is a major point. the measure space yielded by this locality metric need not· be uniform. although I am tempted to think of its electronic fuel injection module computationally. with which we will grapple considerably in our considerations of semantics structural field elements are taken to be significant - it is for this reason that we tend to call them symbols. Infonnally. Note as well that in logic. since the interaction of a processor with a slroctura~ field is always constrained . the behaviour of the processor must always be a function only of its internal state plus the current single structural field element under dissertation we will merely use its basic structure to organise our particula~ investigation). over every structural field there must be defined a locality metric or m~asure.

and are in danger of thinking that the simpler phrase "symbol manipulation" lneans format symbol manipulation. or a full. There are obvious parallels and connections to be cAplorcd. as section l. But in spite of its familiarity."onic fuel injection system. nor sOlncthing specific to IISP'S circulnstanccs. In other words the proper use of the term "computational" is as a predicate on explanations. we mention thenl here only because they will play an inlportant role in our reconstruction of LISP. and the question of what would be required far a computational system to be senlQIJ/ical/y original in the sense discussed at the beginning of Ute previous section. even Lltough the machine itself is not allowed access to that interpretation (for fear of viola~ing the doctrine of mechanism). Introduction tenns of mechanics not posit atl Procedural Reflection 57 forces and torques and pla5ticity and geometry and heat and sen~e combustion and so on. The prescnt moral is nlcrcly that this attribution is neither something new. and so forth. logical operations. a calculuator. an elect. The third constraint follows directly on the second: in spite of this scmantical attribution.s a major claim. These are not interpreted notions: the best explanation of a car does externally attributed seman tical intepretation function in order to make of the car's internal interactions. all of which Qre interpretations of how it works. l1tus I may know that the ALU in my machine works in such and such a way.d and chapter 3 will make clear.1. but I understand its workings in terms of addition. hoy/evert . With respect to any computer. This is tlle slibstance of the claim that computation that computation has to do with the interaction with symbols solely in virtue of their shape or spelling.. not on artefacts. LISP although we will make explicit this attribution of significance to structures in our of a full declarative semantics for LISP. for e~~amplet between this external attribution of significance to tile ingredients of a computational process. the interior processes of a computational process must int~ract with these structures and symbols and other processes in complete is famlal symbol manipulation - igllorance and disregard of any externally Qttributed semanlical weight..whether it is an abacus. We within computer science arc so used to this fonnality condition this requirement that computation proceed syntactically that we are liable to forget that it i. part of our semantical reconstruction will argue that we have not taken this attribution seriously enough. 'fhe external attribution of signi!icance is a . scaie digital computer the best explanation is exactly in tenns of the interpretation of the ingredients. A book should be \vritten on all these matters. pre~entation This is not the place for such investigations.

1. Introduction foundational part of computer science. Procedural Reflection S8 .

Pre-Theoretic Assumptions In engaging in semantical analysis. as a fancy word for abouilless. it is clear that semantical vocabulary will permeate our analysis. simply by using o • the tenn jbnnal you admIt that you attribute significance to it on the side).i). l. Informally. we talked of symbols that represented knowledge about the worl<L and of structures that designated other structures.d.whatever they come to - emerging from the paradigmatic human usc of language (as we mentioned in section 1. we implicate semantics. all . given some specification of what they were designed to do. our goal is not simply to provide a mathematically adequate specification of the behaviour of one or more procedural calc'Jli one that would enable us. Introduction Procedural Reflection 59 i. as we said at the end of the last section. for the teon "semantics" can in viewed. by "semantics" we do not simply mean a mathematical formulation of the properties of a system. because. formulated from a meta-theoretic vantage point (unfortunately it seems that the teon may be acquiring this rather weak connotation with some writers). when say that a process - human or computational . Even at the very highest levels. no one could possibly understand forO falsity. such as an eggplant or a waterfall. In discussing the knowledge representaticn and reflection hypotheses. but also that the computations over them occur in explicit ignorance of their semantical weight (you cannot treat a non-semantical object. to set straight our semantical assumptions and tcchniquese and to make clear what we mean when we say that we will subject our computational dialects to semantical scrutiny. therefore. We are interested in semantics for two reasons: first. In particular. for example. we take semantics to have fundamentally to do with meaning and reference and so forth . LISP without knowing that the atom inc~udes T stands for truth and NIL From the fact that computer science is thought to involve !annal symbol manipuation we admit not only that the subject matter symbols. formally. to prove programs correct.is reasoning about a given subject. The Rationalisation of Computational Semantics From even the few introductory sections that have been presented so far. at least in part.di. we said that the attribution of semantic significance to the ingredients of a process was a distinguishing mark of computer science. It is necessary. In the model of computation just presented. or reasoning about its own thought processes.b. Rather.1.

Most of the results are consequences of the for perspicuity. we will require that our semantical analyses answer to the following two requirements. We will thcrefnre 1Iave to make clear the declarative semantics of the elements of (in our case) the field. Given this agenda. the undeniable reason is that "C+ 2 3)" is understood as a complex name of the number tlIat is the successor of 4. since the attributed semantics mentioned in the first premise includes not only a pre-theoretic understanding of wllat happens to computational symbols. from just these two principles we will be able to defend our requirement of a double semantics. how . but also a pre-computational intuition as to what those symbols stand for. They should make evident that. Specifically. because semantics is the study that will reveal what a computational system is reasoning about. To borrow a phrase from 8arwise and Perry. We we defmed LISP in the way that we did (+ 2 3) arrange things - so that the numeral 6 is the value because we know what stands for. the A-calculus.e: 1. They shouid manifest the fact that we understand computational structures in virtue of attributing to them semantical import. we will approach the semantical study of computational systems with a rather precise set of guidelines.s a fUllction of lvhat they mea". in that they must be defined over structures independent of their semantical weight. Strikingly. our rcco&struction is an attempt to regain our semantic in1locence . but the following basic tenet (\\re have relativiscd the discussion to same would hold for any other calculus): What LISP !. f'or example. and a theory of what a computational process is reasoning about is a pre-requisite to a proper characterisation of reflection. and second. the LISP.· rather. 2. as well as establishing their procedural import LISP structural We will explore these results in more detail fonn of the argument is quite simple. the expression "(+ 2 3)" in LISP evaluates to 6. and so forth). emerging from the two facts about pr~esses and structural fields laid out at the end of section I. b~low.an innocence that still permeates traditional fOlmal systems (logic. but that has been lost in the attempt to characterise the so-called "semantics" of conlputer . but in its barest outlines. in spite of such attribution. computational processes are fOrmal.Iructures mean LISP proce~sor.s not a function of how they are treated by the they are treated .1. Introduction Procedural Reflection 60 computational systems are marked by external semantical attribution.

as are many other examples on which we will begin to erect our denotational account For example. and is the function fonnally computed by the language processor. We will call such a function an interpretation function (to be sharply distinguished from what in computer science is calted an interpreter. as for example in the English sentence "did you notice that the CAR of that list is the atom LAMBDA". this simple situation is made more cOlnplcx because we are studying a variety of interacting interpretation functions.diL Semalltics in a Computational Setting In the most general fonn that we will use the term semanties. it is commonplace use the t. Schematically. as shown in the following diagram. which we are calling a processor).12 a SCRlantical investigation aims to characterise the relationship between a syntactic domain and a semantic domain - a relationship that is typically studied as a mathematical function mapping elements of the first dOIT. In particular.ain into elements of the second. Introduction programming languages. e is the interpretation function mapping notations into elements of the stnlctural field. 0 will be explained below. once one recognises that it is an important thing to do. II» is the interpretation function Inaking explicit our attributed semantics to structural 'It field clements. fonnulating the declarative semantics of a computational fonnalism is not difficult. From such practice we have CAR incontrovertible evidence that a term such as (QUOTE X) (CAR X) designates the QUOTE of the list or pair designated by x. Finally. 1. it is intended to indicate a cIJ-scmantic characterisation of the . we have already mentioned the unarguable fact that (at least in certain contexts) T and NIL designate Truth and Falsity.1. rather Ulan that it is a naming primitive). That "(+ 2 3) II Procedural Reflection 61 designates the number five is self-evident.etm "CAR" as a descriptive jUnction to designate the first element of a pair. the function til is an interpretation function from s to 0: I Syntactic Domain S]--_flt__~ Semantic Domain 0 I (51-10) In a computational setting. In sum. the diagram below identifies the relationships between tile three main scmantical functions that permeate our analysis. it is hard to imagine an argument against our assumption that designates x (in spite of often-heard claims that is a function that holds off the evaluator. Similarly.

and the person who lived in the 17tll and 18th century would be the referent s~. 'on the ot. Putnam. all of which are within the machine ('1' is meant to signify psychology narrowly construed. chosen to suggest philosophy. whereas i' indicates the formally computed relationship a distinction similar. qua sentence of English. the mentalese representation of it would be SI. where "Mark Twain". I reply and N2 arc identical. tile first phrase. 01. then. signifies the relationship between a set of symbols and the world. By far the most common situation. my reply would be 01 N2. in the sense of Fodor. 51. would be the same fellow. If you say to me the phrase "a composer who died in 1750" and I respond with the name "J. (51-11) Notation Nt Notation N2 e a For mnemonic convenience. then Dl and 01 are tile same object. As we will see in the next . since a study of it is a study of the internal relationships between symbols. in terms of the figure. and others13). Similarly. N2. as we will soon argue. As an example to illustrate 51-11. would be Nt. Introduction Procedural Reflection 62 relationship between 51 and 52. The label "cz-". and the mcntalcse fragment that I presumably accessed in order to formulate that reply would be Finally. we use the name "i''' by analogy with psychology. however. Nt. and 02. in other words. where and 02 are the same entity - a circumstance where we say that the function + is des. Ot. We wilt examine cases.ing. for example.gnation-prese". that we accept the hypothesis that our minds are computational processes). suppose we accept the hypothesis that people represent English sentences in an internal mental language we will call mentalcse (suppose. in this case.1. to that between the logical relationships of derivability (1-) and entailment (ta). 01 will be as in the 3ach example.1ter hand. need not neccsS<1rily all be distinct: in a 51 variety of different circumstances two or more of them may be the same entity. Bach". 52. Similarly. 02 would again be the long-dead composer: thus and 02. S. on hearing the phrase "the pseudonym of Samuel Clenlclls". of self-referential designators. if. in other words.

for comparison. the argument we will present in chapter 3 will proceed roughly as follows. and the statement that. I-LISP'S 'If its argument in this case has yet to be explained (saying that it preserves is too easy: the identity function preserves designation was well. is the set of structural field elements. de-references just those lenlls whose referents lie within implements 4». are not. (The formulation used here is simplified S satisfies this equation has the evaluation property. beginriing with since it has evident connections to both declarative and procedural traditions. the equation holds of I-LISP for perspicuity. one still does not necessarily know the relationships between «P(Sl) and 4»(5 2 ). but in fact natural. Similarly. in other words. are both designation-preserving relationships. where it is not. 1-LISP'S and SCHEME'S evaluation In the tenns of this diagram.(5) E S then ~(S) = ~(S) else ~('I'{S» = «1'(S) ] evaluator. the a-reduction and p-reduction of the A-calculus. as well as a procedural if. v is f)-preserving.1. we ~i11 shift towards computational systems. 51-12 is unfortunate. Where it can. to define a declarative 4' for LISP. Introduction Procedural Reflection 63 section. ignoring contextual relativisation. More seriously. we will be able to show that I-LISP'S '1' (EVAL) obeys the following equation. although what it does do with 4» the structural field. to show the general properties of the f)S aud irS employed in those fonnalisms. Next PROLOG. whereas processors. We will argue instead for a dialect described by the following alternative (again in skeletal form): . We will also sketch some of the mathematical characterisation of these two interpretation functions. and the derivability relationship (t-) of logic.) (51-12) vs I-LISP'S € S [if . First we will review logical systems and the A-calculus. It will be clear that though similar in certain ways. they are nonetheless crucially distinct In particular. thus defeating attempts to engender reflection. for example. We will say that any system that the evaluation theorem. and therefore even if one knows of two expressions 51 and 52 that 51 is '1'(5 2). and is designation-preserving otherwise. the 2. Finally we will take up LISP.and 3-LISP processors will be designation-preserving. in part because the question of is not in general decidable. but The behaviour described by whether 4»( 5 ) E S EVAl is not the identity function). in other words. as we have already indicated. We will argue that it is not only coherent. it makes the explicit use of meta-structural facilities extraordinarily awkward.

any Diagrammatically. from the third property. or equivalently. therefore. as was a property of and 2-LISP suggested earlier ('I' = '1'0'1'. which we will have to define. in addition. we will be able to that 'i' is idempotent. Introduction 'IS E S Procedural Reflection A NORMAL-FORM('I'(S»] 64 II 4'(S) = 4'('1'(S»] 2-LISP. (51-13) When we prove it for we will call this equation the nonna/isation theorem. that will follow from our category alignment mandate. 2-lISP 3-LISP. we will in contrast define nonnal-fonncdness in tenns of the following three (provably independent) properties: must be context-indepeiulent. As we will argue in more detail in chapter 3. '1'(5) would definitional/y be in normal-form. 1. They must be stable. In the A-calculus. since the concept of that name is defined in terms of the non-applicability of any further p-reductions.1. in the sense of having the same declarative and procedural import independent of their context of use. In addition. 2. rIbcrc is another property of nonnal-form designators in beyond the three requirements just listed. circumstance it describes is pictured as follows: (51-14) normal form /' Such a 'ItI in other words. It relies. independent of the structural . is always c)-preserving. implying that t11eir procedural treatment will have no affect on the structl1ral field or state of the processor. by which we mean that they must normalise to themselves in all contexts. They must be side-effect free. They It will then require a proof that all 2-LISP and 3-lISP results (all expressions SllOW '1'(5» are in it nonnal-form. and 3-lISP 'IS '1'(S) = 'It{i'(S») - that will ultimately be shown to have substantial practical benefits. plus this proof that the range of includes only nonnal-form expressions. the system satisfying we will say has the nonnalisation property. this makes the notion less than ideally useful: in designing 2-LISP and 3-LISP. on a notion of nonna/ lann. 3. In designing those dialects we will insist that the structural category of each normal fonn designator be deternlinablc from the type of object designated.

This category result. as will be examined in a moment). number). demonstrate that any term that designates a number will be taken by 'I' into a numeral. there are two boolean constants $T and SF that arc nonnal-fonn designators of Truth and Falsity. That normal form designators cannot be canonical arises. and a canonical set of rigid structure designators called handles that arc normal-form designators of all s-expressions (including thclnsclves). of course. Instead of pursuing that sort of unhelpful approach. independent of the fonn of x itself (although the token identity of i'( X) cannot be predicted on such information alone. and therefore if nonnal-form function designators were required to be unique it would follow that expressions that designated funcuons could not necessarily be nonnalised. will succumb to a standard nonnalisation procedure. we will also have to specify nonnal-fonn designators for sequences and other types of mathematical objects included in the . however. and have a syntactic class of nUlnera!s. they satisfy the requirements on nonnal·fonnedness. will nonnalise to the numeral 11. We include The numerals are canonical (one per U1US the numbers in our semantical domain. d(~signators from just the designation of a term x the structural category of i'(X) will be predictable. In other words. will have to be proved: we call it the sellUlntical type theorem. and as usual they are side-effect free and context independent. Similarly. and if + designates the addition function.1. since normal-fonn designators are not necessarily unique or canonical). which are taken to be Donnal form number designators. since numerals will be defined as the normal-fonn For example. (+ X since it designates eleven. And so on: closures are nonnal-fonn function designators. as mentioned in the last paragraph. we will be able to of numbers. Introduction Procedural Reflection 6S type of the original designator. on this scheme. from computability considerations: one cannot decide in general whether two expressions designate the same function. All well-dermed function-designating expressions. The semantical type theorem says that any tenn that designates a "number will nonnalise to a numeral: thus if x designates five and Y designates six. then we know (call prove) that V). still satisfying the three requirements specified above: such a designator will by definition be called a closure. we will instead adopt a non-unique notion of nonnal-form function designator. Some 2-lISP (and 3-lISP) examples will illustrate all of these points. and independent as well of any of the machinery involved in implementing v (this is in distinction to the received notion of Donnal fonn employed in the A-calculus.

nnd the comments just made about LISP'S inclusion of QUOTE.e. is that because LISP includes its syntactic domain within the semantic domain . It is this regained coherence that. we claim. but. In the LISP dialects we consider. nor any of the typical inference rules one encounters in mathematical or philosophical logics. .1. What would emerge would be a semantics for a deviant A-calculus with some operator like QUOTE included as a primitive syntactic construct . we will retain sufficient machinery to handle side effects..because LISP has QUOTE as a primitive operata.. as we will see in detail in chapter 3. is a necessary prerequisite to a coherent treatment of reflection. behaviour mandated by not new: this is how all standard semantical treatments of the A-calculus proceed. in order to illustrate how the semantical reconstruction we endorse However it is important to recognise that the 51-13 is would impinge on a language design. in other words. in other words .a semantic inelegance was inadvertantly introduced in the design of the language that has never been corrected. but it is of course always possible to remove such facilities from a calculus. Procedural Reflection 66 We have diverted our discussion away from general semantics. Nei~er the A-calculus reduction protocols.. Similarly. such an analysis should emerge as a straightforward corrollary. once the mathematical analysis of 2-LISP is in place. in part by connecting the language of our computational calculi with the language in which those prior linguistic systems have been studied. In fact it is hard to imagine defending 51-12.a semantics for a w~ll 11lela-struclural extension of the already higher-order A-calculus. de-reference the expressions over which they are defined. We not pursue this line of attack in this dissertation. Thus our rationalisation of LISP is an attempt to regain the semantieal clarity of predicate logic and the A-calculus. onto the particulars of 2-LISP and 3-LISP. the ability to name composite expressions as unities). suggest that one way to view our project is as a semantical analysis of a variant of the A-calculus with quotation. and the designation-preserving aspect of it is approximately true of the inference prfJCedures for logical systems as well. A final comment The consonance of 51-13 with standard semantical treatments of the A-calculus. Introduction semantical domain. we could remove the numerals and atomic function designators (i. What may have happened. we can speculate.

rather than as a syntactic mark). functional languages. F"r example. The hyper-intensional QUOTE operator is not in itself difficult to deal with. However there are a variety of complications that will demand resolution. we of course pursue this latter question in detail. and that the primitively recognised closures designate a certain set of functions. with extensional procedures recast in appropriate ways. and initially posit the designation of each primitive object type (saying for instance that the numerals designate the numbers. but no with intensional constructs will cause a refonnulation of the entire semantics. of which two may be lnentioned here. and even LAMBDA. we begin with declarative import (4)>). they do not reveal how this is to be accomplished. All standard model- theoretic technIques of course allow for the general fact that the scmantical import of a term may depend in part of on the context in which it is used (valiables arc the classic simple example).diiL Recursive and Compositional FonnulaliolU Procedural Reflection 67 The previous sections have suggested briefly the work that we would like our semantics to do. In chapter 3.. where the reconstruction of semantics is laid out. (QUOTE. but we can summarise some of its results here. The second difficulty has to do with side-effect~ and contexts. First. and so forth). If we were considering only purely extensional. and so forth). the story might end there. none of the LISP'S that we will consider are purely extensional: there are intensional constructs of various sorts example. side-effect free. although we will also consider questions about less-tine grained intensionality of 'f the sort that (a statically scoped) LAMBDA manifests.'tat the numerals and booleans are selfevaluating. for which we will view as a standard intensional procedure. Similarly. standard approaches suffice. Beginning very simply. particular difficulty emerges. and then specify recursive rules that show how the designation of each composite expression emerges from the designation of its ingredients. impinges on the appropriate context for declaralive . However the questioIl of side-effects - which are part of the total procedural consequence of an expression.L Introduction 1. that atoms evaluate to their bindings. the ability to deal This is a minor complexity. and then once again specify recursive rules showing how the l-alue or result of a composite expression is fOlmed from the results of processing its constituents. in a rather parallel fashion we can specify the procedural consequence (it) of each primitive type (saying in particular 1. As in any system.

are the specification of fit would seem to violate the ground Intuition which argued that the designation of this tenn. Only the total significance of our dialects will be strictly compositional. it is straightforward to say that the tenn x Y) designates the number seven. in a context in which x is bound to the numeral (+ 3 and Y is bound to the numeral 4.1. relativiscd to the total context of use specified by the encompassing function. local LISP procedural consequence (what an expression evaluates to. In tltis way we will be able to formulate precisely the intuition that 17. such as the designation. and the ~fTerenl The approach we will ultimately adopt is one in which we define what we call a general significance function ~I which embodies both declarative import (designation). 51-16 designates seventeen. we should note that it is not always the case that the processing of a term results in the obvious (i. even though it patently returns the numeral 17 (although note that we are under no pre-theoretic obligation to make the declarative and procedural stories cohere . Just feom the contrast between these two examples (51-15 and Sl-16) it is clear that LISP processing and LISP designation do not track each other in any trivially systematic way.reject IISP exactly because they do 1- not cohere in any way that we can accept). On tl)e other SETQ within hand. However consider the more semantics of the more complex (this is standard LISP): (+ 3 (PROG (SETQ Y 14) V»~ (51-16) It would be hopeless (to say nothing of false) to have the fonnulation of declarative import ignore procedural consequence. we will prove that the expression ( CAR • (A Be» (51-16) both designates and returns the atom A. Introduction Procedural Reflection 68 purposes as well as well as for procedural For example. to include the procedural effect of the structure to which it evaluates. modifications to the ficlcL and so forth). as well as returning the corresponding numeral Lest it seem that by handling Llesc cOlnplexities we have lost any incisive power in our approach. and claim that 51-16 designates seven.e. and full procedural consequence (the complete contextual effects of an expression.in fact we will . inciuding sideeffects to the environment.. will be recursively specified in tenns of the designation of the consitucnts.ignificance. . normal-fonn) designator of its referent For example. the components of that total :. and returns the numeral 7. to use jargon).

' prepared to design a dialect that corrects its I. Introduction Procedural Reflection 69 Although our approach will prove successful. or uses certain resources in certain ways). we will also have seen in detail why it is confusing. from a mathematical specification of the ALGOL . it is impossible to say that tile processor is correct. we will not only know that errors.it always terminates. The Role ofa Declarative Semantics One brief final point about this double semantics must be broug. it might be possible to prove that that program met some specifications (such as that it sorted its input. but it is important to make clear how our semantical reconstruction is a prerequisite to the design of 2-LISP and analysing them. or that it has certain other independently definable properties (such as that. or semantically coherent. after all. 3-lISP.1. programs written in tIle language - givefl such an account. On the standard approach. namely: lvhat is the selnalltical character of the processor itself? In our particular case. Again. one can prove properties of thus. not a post-facto method of It is a simple point. It should be clear that it is impossible to specify a nonnalising processor without a pre-computational theory of semantics. we will be able to only with reference to this pre-computational theory of declarative semantics. we will ultimately abandon the strategy of characterising the full semantics of standard virtually impossible to say anything coheren~ LISP (as exemplified in our I-LISP dialect). but only by first laying out both declarative and procedural theories of IISP. there is no way to say anything substantial about the semantical import of the function that the processor computes. and we will be adequatel. In addition. However none of these questions arc the question we are trying to answer. or that an ilnplelnentQtion of it is correct. for example.processor of ALGOL. LISP is confusing. one can compare this to other accounts: thus it is possible for example to prove that a specification of it is correct. or whatever). . we will be able to specify the semantical import of the function computed by design 2-lISP LISP'S EVAl (this is content of the evaluation theorem). plus the listing of an program. If you do not have an account of what structures mean. Given some account of what it does.div. is our goal: By the time our semantica1 analysis is to judge I-LISP. independent of how they are treated by the processor.. or semantically incoheren~ or anything: it is merely what it is.'1t out. since the confusion about the semantic import of evaluatio11 will in the end make it about designation. not merely to characterise it concluded. This.

1. Introduction

Procedural Reflection

70

I.e. Procedural ReOection

**Now that we have' assembled a minimal ·_'t)C8bulary with which to talk about
**

computational processes and matters of semantics, we can sketch the architecture of reflection that we will present in the final chapter of the dissertation. We will start rather

abstractly, with the general sense of reflection sketched in section l.b; we will then make use of both the knowledge representation hypothesis and the reflection hypothesis to define a much more restricted goat. Next, we will employ our cllaracterisations of interpretively reduced computational processes and of computational semMtics to narrow this goal even further. As this progressive focussing proceeds, it will become more and more clear what

would be be

involv~d

in actually constructing an authentically reflective computational

**language. By the end of this section we will be able to suggest the particular structure that,
**

in chapter 5, we will embody in 3-LISP.

1.e.L A. First Sketch

We begin very simply. At the outset, we characterised reflection in terms of a process shifting between a pattern of reasoning about some world, to reasoning reflectively about its thoughts and actions in that world. We said in tt,e knowledge representau.on hypothesis that the only current candidate architecture for a process that reasons at all

(even derivatively) is one constituted in tenns of an interior process manipulating representations of the appropriate knowledge of that world. W'e can see in terms of the

process reduction model of computation a little more clearly what this means: for the

process we called

CHEQUERS

**to reason about the world of finance, we suggested that it be
**

p manipulating a structural field

**interpretively composed of an ingredient process
**

we were led to the following picture:

s

consisting of representations of check-books, credit and debit entices, and so forth. Thu!:

(51-17)

CHEQUERS

1. Introduction

Procedural Reflection

71

**Next, we said (in the reflection hypothesis) that the only suggestion we have as to ho,v to make
**

CHEQUERS

**reflective was this: as weil as constructing process
**

Q

p

to deal with these

**various financial records, we could also construct process
**

unexp~ted

**to l'eal with P and the structural
**

p

**field it manipulates. Thus 0 might specify what to do when
**

in when the failure

occure~

failed or encountered an

p

situation, based an what parts of P had worked correctly and what state I was

Alternatively,

Finally~ Q

Q

**might describe or generate parts of
**

interpr~tation

that

hadn't been fully specified.

might effect a more complex

process

for

p -

P,

**or one particularized to suit specific circumstances. In general, whereas the world of the domain that
**

P

models, simulates, reasons abovt p

is the world of finance, the but whether it is really at a different time, is a

**world of Q is the world of the process We have 3poken as if different from
**

P,

Q

**and the structural field it computes over.
**

P,

**were a different process from
**

p

or whether it is

def~r

in a different guise, or

P

question we will

for a while (in part because we have said nothing about the

individuation criteria on prc,cesses). All that lnatters for process that does wh&t we have said that What do we require in order for

proc~:>'ses

**the moment is that there be some
**

Because

P.

Q

must do.

Qf

Q

to reason about p?

like all the

lve are considering, fs assumed to be interpretively composed, we need what we

always need: structufal representations of tile facts about

**What would such
**

fonnulat~d

representations be like?

**First, tltey must be expressions (statements),
**

p

Yiith

**respect to some tllCOry, of the state of process
**

actually describe

P,

**(we begin to see how the theory relative Second, in order to
**

p

**mandate on rCllcction froIn section l.b is making itself evident).
**

iliey must be causa/I)1 cOllnected to

~us

**in some appropriate way (another
**

SP

of our general requirements).

we are considering a situation such as that depicted in contain5 these causally

**tile following diagram, where the field (or field fragment)
**

conn(;ctcd structural descriptions:

(51-18)

REFLECTIVE CHEQUERS

1. Introduction

Procedural Reflection

SP

72

p

This diagram is of course incomplete, in that it does not suggest how

should relate to

(an answer to this question is our current quest). Note however that reflection must be able to recurse, implying as well something of the following variety:

(51-19)

REFLECTIVE CHEQUERS

**Where then might an encodable procedural theory come from?
**

possible

sourc~:

We have two

in our reconstruction of a semantical analysis we will have presented a full

theory of the dialects we will study; this is one candidate for an appropriate theory. Note,

**however, since we are considering only procedural reflection, that although in the general
**

case we would have to encode the full theory of computational significance, in the present

**circumstance the simpler procedural component will suffice.
**

The second source of a theoretical account, which is actually quite similar in

structure, but even closer to the one

\VC

will adopt,

i~

what we will call the meta-circular

**processor, which we will briefly examine.
**

I. e. ii. k!eta-Circular Processors

In any computational formalism in which programs are accessible as first class

**structural fragments, it is possible to construct what arc commonly known as nzela-circular
**

interpreters: "meta" because they operate on (and therefore ternlS within them designate) other formal structures, and "circular" because they do not constitute a definition of the

**processor, for two reasons: they have to be run by that processor in order to yield any sort
**

of behaviour (since they are progral11S, not processors, strictly), and the behaviour they would thereby engenrlcr can be known only if one knows beforehand what the processor

does. Nonetheless, such processors arc often pedagogically illuminating, and they wilt play

a critical role in our development of tJ1C reflective model. In line with our general strategy

1. Introduction

Procedural Reflection

73

**of reserving the word "interpret" for the semantical interpretation function. we will call
**

~.Jch

processors mela-circular processors.

**In our presentation of
**

(or MCP's. for short); the

I-LISP

and

2-lISP

we will construct meta-circular processors

2-lISP

version is presented here (all the details of what this

means will be explained in chapter 4; at the moment we mean only to illustrate the general

**structure of this code):
**

(DEFINE NO~MALISE (LAMBDA EXPR [EXP ENV CONT] (COND [(NORMAL EXP) (CONT EXP)] [(ATOM EXP) (CONT (BINDING EXP ENV»] [(RAIL EXP) (NORMALISE-RAIL EXP ENV CONT)] [(PAIR EXP) (REDUCE (CAR EXP) (CDR EXP) [NV CONT)]») (51-20)

(DEFINE REDUCE (SI-21) (LAMBDA EXPR [PROC ARGS ENV CONT] (NORMALISE PRoe ENV (LAMBDA EXPR [PROC!] (SELECTQ (PROCEDURE-T~PE PROC!) [IMPR (IF (PRIMITIVE PROCI) (REDUCE-IMPR PRoel ARGS ENV CONT) (EXPAND-CLOSURE PROC! ARGS CONT»] [EXPR (NORMALISE ARGS ENV (LAMBDA EXPR [ARGSI] (IF (PRIMITIVE PROCI) (REDUCE-EXPR PROCI ARGSI ENV CONT) (EXPAND-CLOSURE PROCI ARGS! CONT»»] [MACRO (EXPAND-CLOSURE PROCI ARGS (LAMBDA EXPR [RESULT] (NORMALISE RESULT ENV CONT»)]»»)

(DEFINE EXPAND-CLOSURE (LAMBDA EXPR [CLOSURE ARGS CONT] (NORMALISE (BODY CLOSURE) (BIND (PATTERN CLOSURE) ARGS (ENV CLOSURE» CONT»)

(Sl ...·22)

The basic idea is that if this code were processed by the primitive primitive processor itself.

2-LISP

processor. the

**process that would thereby be engendered would be behaviourally equivalent to that. of the
**

If, in other words, we were to assume mathematically that

**processes are fiJDctions from structure onto behaviour, and if we called the processor
**

presented as 51-20 through 51-22 above by the name MCP2L, and called the pritnit\ve 2-LISP processor PZLt then we would presumably be able to prove the following result, where by

n~ ..

we mean behaviourally equivalent, in some appropriate sense (this is the sort of proof

of correctness one finds in for example Gordon: 14

1. Introduction

Procedural Reflection

74

(Sl-23)

It should be recognised that the equivalence of which we speak here is a global

**equivalence; by and large the primitive processor, and the processor resulting from the
**

explicit running of the MCP, cannot be arbitrarily mixed (as a detailed discussion in chapter 5 will make clear). For example. if a variable is bound by the underlying processor

not be able to be looked up by the meta-circular code. Similarly, if the metacircular processor encounters a control structure primitive, such as a THROW or a QUIT, it will

PZL' it will

not cause the meta-circular processor itself to exit prematurely, or to terminate. The point,

rather, is that if an entire computation is mediated by the explicit processing of the MCP,

then the results will be the same as if that entire computation had been carried out directly.

We can merge these results about MCPs with the diagram in

51-17, as

follows: if we

replaced

p in S1-17

with a process that resulted from

p

**processing the meta-circular
**

CHEQUERS:

processor, we would still correctly engender the behaviour of

(51-24)

CtlEQUERS

Furthennorc. this replacement could also recurse:

1. Introduction

Procedural Reflection

75

(81-26)

CHEQUERS

Admittedly, under the standard interpretation, each such replacement would involve a

dramatic increase in inefficiency, but the iInportant point for the time being is that the resulting behaviour would in some sense still be correct

**1. e. iv. Procedural Reflective Models
**

We can now unify the suggestion made

a~

the end of section l.e.ii on having

Q

reflect upwards, with the insights embodied in the MCPts of tile previous section, and thereby define what we will call the procedural ,eRective model The fundamental insight arises from the eminent similarity between diagrams compared with 51-24 and

51-26, 51-18

and

51-19,

on the one hand,

**on the other. l'hese diagrams do not represent exactly the
**

Q of

same situation, of course, but the approach will be to converge on a unification of the two. We said earlier tllat in order to satisfy the requirements on the our dialect (we will use

LISP)

s~en

section l.t:ji we

would need to provide a causally connected structural encoding of a procedural theory of within the accessible structural field. In the immediately preceding section we have something that is appoxilllately such an encoding: tile meta-

circular processor. However (and here we refer back to the six properties of reflection given in section I.b) in the normal course of events the MCP lacks the appropriate causal access to the state of P: whereas any possible state of 0 could be procedurally encoded in tenns of the meta-circular prO\.,css (i.e., given any account of the

state

of

P

we could

retroactively construct appropriate argulncnts for the various procedures in the meta-circular

processor so that if that meta-circular processor were run with those arguments it would mimic P in the given state), in tIle normal course of events the state of P will 1101 be so

1. Introduction encoded.

Procedural Reflection

76

This similarity, however, does suggest the fonn of our solution. Suppose first that meta-circular processor - as, for example, in the series of pictures given in

25.

51-24

p

**were never run directly, but were always run in virtue of the explicit mediation of the
**

and 51-

Then at any point in the course of the

computatio~

if that running of one

lev(~l

of the

MCP were interrupted, and the arguments being passed around were used by sonte other

procedures, they would be given just the inf\lrmation we need: causally connected and correct representations of the state of the process p prior to the point of reflection (of

course the MCP would have to be modified slightly in order to support such a protocol of

interruption).

The problem with this

approac~

however, is the following: if we always run

P

mediated by the meta-circular ;>rocessor, it would seem that P would be unnecessarily inefficient Also, this proposal would seem to deal with only one level of reflection; what if

the code that was looking at these structural cncodings of p's state were themselves to

**reflect? This query suggests that we have an infinite regress: not only should the MCP be
**

used to run the base level 0 programs, but the MCP should be used to run the MCP. In

fact all of an infinite number of MCP's should be run bi yet further MCPs, ad infmitum. Leaving aside for a moment the obvious vicious regress in this suggestion, this is not a bad approacll. The potentially infinite set of reflecting processes

Q

arc almost

indistinguishable in basic structure frcm the infinite to\ver of MCP's that would result

Furthermore the MCP's would contain just the correct structurally encoded descriptions of processor state. We would stiU need the mc,diflcation so that some sort of interruption or reflective act could make usc of tllis tower of processes, but it is clear that to a first

**approximation this solution hac; the proper character.
**

Furthermore, it will turn out that we can simply posit, essentially, that the primitive processor is engendered by an infinite number of recursive insL1nces of the MCP, each

running a version one level below. 'Ibe implied infinite regress is after all not problematic,

since only a finite amount of infi)rmation is encoded in it (all but a finite number of the

**bottom levels each MCP is merely nanning a copy of the Mep). Because
**

j

\VC

(the language

As

dcs!gners) know exactly how tile langcage runs and know as well \vhat the MCP is like, we

can provide this infinite nunlbcr of levels, to usc the current jargon, Dilly virtually.

1. Introduction

Procedural Reflectiol1

n

chapter 5 will explain in detail, such a virtual simulation is in fact perfectly well-defined. It

is no longer reasonable to call the processor a meta-circular processor, of course, since it

**becomes inextricably woven into the fundamental architecture of the language (as will be
**

explained in detail in chapter S). should be clear. In order to ground this suggestion in a little more detail, we will explain just briefly

the alteration tllat allows this architecture to be used. More specifically, we will in 3-LISP support what we will call reAective procedures -

It is for this reason that we will call it the reAective

processor, as suggested above. Nonetheless its historical roots in the meta-circular processor

procedures that, when invoked, are run

**not at the level at which the invocation occured, but one level higher, being given as
**

arguments those expressions that would have been passed around in the reflective processor, had it always been running explicitly. We present the code for the 3-LISP reflective processor here, to be contrasted only very approximately with 51-20 through 5122

**(the important line is underlined for emphasis):
**

{DEFINE NORMALISE (LAMBDA SIMPLE [EXP ENV CONT] (COND [(NORMAL EXP) (CONT EXP)] [(ATOM EXP) (CONT (BINDING EXP ENV»] [(RAIL EXP) (NORMALISE-RAIL EXP ENV CONT)] [(PAIR EXP) (REDUCE (CAR EXP) (CDR EXP) ENV CONT)]») (51-26)

(DEFINE REDUCE (51-21) (LAMBDA SIMPLE [PROC ARGS ENV CONT] (NORMALISE PRoe ENV (LAMBDA SIMPLE [PROCI] (SELECTQ (PROCEDURE-TYPE PROCt) [REfLECT «SIMPLE . • (CDR PROt!}) ARGS ENV CONT)l [SIMPLE (NOUMALISE ARGS ENV (MAKE-Cl PRoel CONT»]»») (DEFINE MAKE-Cl (St-28) (LAMBDA SIMPLE [PROCt CONT] (LAMBDA SIMPLE [ARGSI] (COND [(= PROCt tREfERENT) (NORMALISE ~(IST ARGS!) ~(2ND ARGSI) CONT)] [(PRIMITIVE PROC!) (CONT t(~PROCI . ~ARGS!»] [ST (NORMALISE (BODY PROCI) (BIND (PATTERN PR~C!) ARGSI (ENV PROC!» CONT)]»»

**What is important about the underlined line is this: when a rcdcx (application) is encountered whose
**

CAR

normalises to a reflective procedure, as opposed to a standard

procedure (the standard ones arc called SIt~PlE in this dialect), the corresponding function

1. Introduction

Procedural Reflection

78

(designated by the abstruse term (SIMPLE • .J.(CDR PROe!), but no matter) is run at the level

of the reflective processor, rather than by the processor.

In other words ths single

underlined line in

this in more depth.

51-27

on its own unleashes the full infinite reflective hierarchy.

Coping with that hierarchy will occupy part of chapter S, \vhere we explain all of Just this much of an introduction, however, should convey to the

**reader at least a glimpse of how reflection is possible.
**

1. e. iv. Two Views ofReflection

**lbe reader will note a certain tension between two ways in which we have
**

characterised this form of reflection. On the one hand we sometimes speak as if there were a primitive and noticeable; reflective act, which causes the processor to shift levels rather markedly (this is the explanation that best coheres with some of the pre-theoretic intuitions

**about reflective thinking in the se;nse of contemplation). On the other hand, we have also
**

just spoken of an infinite number of levels of re1ective processors, each essentially

implementing the one below, so that it is not coherent eithe.l° to ask at which level

Q

is

**running, or to ask how many reflective levels are running: in some sense they are all
**

running at once, in exactly the same sense that both the LISP processor inside your editor.

and your editor, are both running when you use that editor. In the editor case it is not, of

course, as if LISP and editor y,"erc both running together, in the sense of side-by-side or

**independently, rather, tile one, being interior to the other, in fact supplies the anima or
**

agency of the outer one.

It is just this sense in which the higher levels in our reflective each of them is in some sense withill the processor at the

hierarchy are always

~unning:

level below, so that it can thereby engender it. We will not take a principled view on which account they turn

OJlt,

**a single locus of agency
**

is correct:

stepping between lercls, or an infinite hierarchy of simultaneous processors -

rather curiously, to be behaviourally equivalent. For certain purposes one is

**simpler, for others the other.
**

To illustrate the "shir-Ling levels" account (which is more complex than the infinite

n~mber

**of levels story), we present the following account of what is involved in
**

In

**constnlctillg a reflective dialect, in part by way of review, and in part in order to suggest to
**

the reader how it is that a reflective dialect could in fact be finitely constructed.

1. Introduction

Procedural Reflection

79

particular, you have to provide a complete theory of the given calculus expressed within its own language (the reflective processor this is required on both accounts, obviously).

**Secondly, you have to arrange it so that, when the process reflects, all of the structures used
**

by the reflective processor (the fonnal structures designating the theoretical entities posited

by the theory) are available for inspection and manipulation, and correctly encode the state

that the interpreter was in prior to the reflective jump. Third, you have to make sure that when the process decides to "drop down again", the original base-level interpretation process is resumed in accordance with the facts encoded in those structures. In the minimal

**case, upon reflection the processor would merely interpret the reflective processor explicitly,
**

then at some furtller point would drop down and resume running non-reflectively. Such a

**situation, in fact, is so simple that it could not be distinguished (except perhaps in terms of
**

elapsed time) from pure non-reflective interpretation.

**The situation, however, would get more complex as soon as the user is given any
**

power. Two provisions in particular are crucial. First, the entire purpose of a reflective

**dialect is to allow the user to have his or her own programs run along with, or in place ot:
**

or between the steps ot: the reflective processor. We need in other words to provide an

abstract machine with the ability for the programmer to insert code and at convenient times -

in convenient ways

at any level of the reflective hierarchy. For example, suppose

that we wish to have a A-expression closed only in the dynamic environment of its use, rather than in the lexical environment of its definition. llte reflective model will of course contain code that pcrfonns the default lexical closure. The progranlmer can assume that

**the reflective code is being explicitly intcrprcte<L and can provide, for the lambda
**

expression in question, an alternate piece of code in which different action is taken. By simply inserting this code into the correct level, (s)hc can use variables bound by the reflective model in order to fit gracefully into the

ove~dll

regime. Appropriate hooks and

protocols for such insertion, of course, have to be provided, but they have to be provided only once. Furthermore, the reflective model will contain code showing how this hook is

nonnal1y treated. As well as providing for the arbitrary interpretation of special programs, at tile reflective level, we need in addition to enable the user to modify the explicitly available

structures that were provided by the reflective model.

Though this ability is easier to trickier. An example will

design than tile fomler, its correct implementation is

consid~rably

1. Introduction

make this clear. In the

tfJ

Procedural Reflection

LISP

80

**reflective model we will exhibit, the interpreter will be shown
**

Upon reflecting.

deal explicitly with both environment and continuation structures.

**programs can at will access these structures that, at the base level, are purely implicit
**

Suppose that the user's reflective code actualli modifies the environment structure (say to change the binding of a variable in some procedure somewhere up the stack. in the way

~ba:

**a debugging package might support), and also changes the continuation structure
**

When this reflective code "returns". so to speak, and drops back down. the

(designator of the continuation function) so as to cause some function return to bypass its caller. interpretation process dlat must then take effect must be the one In&ndated by these modified structures. not the one that would have been resumed prior to the reflection. These modifications, in other words, must be noticed. This is the causal connection aspect of self-reference that .is so crucial to true reflection.

**I.e. v. Some General Comments
**

The details of this architecture emerged from detailed considerations; it is interesting to draw back and see to what extent its global properties match our pre-theoretic intuitions about reflection. First, we can see very simply that it honours all

in section l.b.iii:

1.

Sil

requirements laid out

2.

3.

4. 6.

6.

It is causally connected and theory-relative; It is theory-relative; It involves an incrclnental "stepping back" rather than a true (and potentially vicious) instantaneous self-reference; Finer-grained control is provided over the processing of lower level structures; It is only partially detached (3-LISP reflective procedures are still in 3-LISP, they arc still animated by the same fundamental agency, since if one level stops processing the reflective model (or some analogue of it), all the processors "below" it cease to exist): and The reflective powers of 3 -l IS pare primitively provided.

11lus in this sense we can count our architecture a success.

I{cgarding other intuitions, such as the locus of self, the concern as to whether the potential to reflect requires that one always participate in the world indirectly rather than directly, and so forth, turn

Ollt

to be about as difficult to answer for

3-LISP

as they arc to

answer in the case of human reflection. In particular, our solution docs not answer the

1. Introduction

Procedural Reflection

p

81

question we posed earlier about the identity of the reflected processor: is it

that reflects,

or is it another process

Q that

reflects on p? The "reflected process" is neither quite the

same process, nor quite a different process; it is in some ways as different as an interior process, except that since it shares the same structural field it is not as different as an implementing process. No answer is forthcoming until we define much more precisely what the criteria of individuation on processes are, and, perhaps more strikingly, there seems no particular reason to answer the question one way or another. It is tempting (if dangerous) to speculate that the reason for these difficulties in the human case is exactly

why they do not have answers in the case of 3-LISP: they are not, in some sense, "real" questions. But it is premature to draw this kind of parallel; our present task is merely to

clarify the structure of proposed solution.

1. Introduction

~ocedural

Reflection

82

1.t: The Use of LISP as an Explanato'Y Vehicle There are any number of reasons why it is important to work with a specific

programming language, rather than abstractly and in general (for pedagogical accessibility,

as a repository for emergent results, as an example to test proposed technical solutions, and so forth). Furthennore, commonsense considerations suggest that a familiar dialect, rather than a totally new for.nalism, would better suit our purposes. On the other han~ there are

no current languages which are categorically and semantically rationalised in the way that

**our theories of reflection demand; therefore it is not an option to endow any extant system
**

with reflective capabilities, without first subjecting it to substantial modification. It would be possible simply to present some system embodying all the necessary modifications and

features, but it would be difficult for the reader to sort out which architectural features were due to what concern. In this dissertation, therefore, we have adopted the strategy of presenting a reflective calculus in two steps: first, by modifying an existing language to

conform to our semantical mandates, and second, by extending the resulting rationalised language with reflective capabilities. Once we have settled on this overall plan, the question arises as to what language

should be used as a basis for this' two-stage development Since our concern is with procedural rather than with general refloction, the class of languages that are relevant includes essentially all programming languages, but excludes exemplars of the declarative

tradition: logic, the A-calculus, specification and representation languages, and so forth (it is

important to recognise that the suggestion of constructing a reflective variant of the Acalculus represents a category error). Furthermore, we need a programming language - a procedural calculus 1.

with at least the following properties:

The language should be sitnple; reflection by itself is complicated enough that, especially for the first time, we should introduce it into a formalism of minimal internal complexity. 2. It must be possible to access program structures as first-class elements of the structu rat field. 3. Meta-structural primitives (th~ ability to mention structural field elements. such as data structures and variables, as well as to use them) mUfit be provided.

1. Introduction

4.

Procedural Reflection

83

The underlying architecture should facilitate the embedding, within the calculus, of the procedufDI components of its own meta-theory.

**The second property could be added to a language: we could devise a variant on ALGOL, for example, in which
**

ALGOL

programs were an extended data type, but

LISP

akeady possesses

**this feature. In addition, since we will use an extended A-calculus as our meta-language, it
**

is natural to use a procedural calculus that is functionally oriented. Finally, although full-

scale modem

LISPS

are as complex as any other languages, both

LISP 1.6

and

SCHEME· have

**the requisite simplicity.
**

LISP

has other recomendations as well: because of its support of accesssible program The explicit use of EVAL and APPLY, for

stnictures, it provides considerable evidence of exactly the sort of inchoate reflective

behaviour that we will want to reconstruct

**example, will provide considerable fodder for subsequent discussion, both in terms of what
**

they do well and how they are confused. In chapter 2, for example, we 'Nill describe a half

dozen types of situation in which a standard

LISP

programmer would be tempted to use

these meta-structural primitives, only two of whicb in the deepest sense have to do wittl the explicit manipulation of expressions; the other four, we will argue, ought to be treated

directly in the object language.

Finally, of course,

LISP

is the lingua franca of the AI

**community; this fact alone makes it an eminent candidate.
**

I.}:;'

!-LISP

**asa Distillation a/Currellt Practice
**

LISP

**lbc decision to use
**

"LISP"

as a base doesn't solve all of cur problems, since the name as a basis for further development, in part to have a

**still refers to rather a wide range of languages. It has seemed simplest to define a
**

LISP 1.6,

simple kernel, not unlike

fixed and well-defined target to set up and criticise, and in part so tllat we could collect into one dialect the features that will be filost important for our subsequent analysis. We

will tAke

LISP 1.6

**as our primary source, although some facilities we will ultimately want to
**

CATCH

**examine as examples of reflective behaviour - such as
**

Similarly,

VIC

and

TUROW

and

QUIT -

will

be added to the repertoire of behaviours manifested in McCarthy's originai design. will include macros as a prjrnitive procedure type, as well as intensional and

**extensional procedures of the standard variety ("call-by-valuc" and "caU"by-name", in
**

standard conlputer science parlance, although we 'Nill avoid these terms, since we will reject

the notion of "value" entirely).

1. Introduction

Procedural R~flcction

84

It will not be entirely simple to present I-LISP. given ot,r theoretical biases, since so much of what we will ultimately reject aoout it comes so quickly to the surface in

**explaining iL However it is important for us to present this formalism without modifying
**

it, because of the role it is to play in the structure of our overall argument We ask of the

dialect not that it be ctei\D or

coheren~

but rather that it serve as a vehicle in which to

**examine a body of practice suitable for subsequent reconstruction. To the extent that we
**

make empirical claims about our semantic reconstructions, we will point to 1" LISP practice (our model for all standard LISP practice) as evidence. Therefore.

rec~ived

fOT

IheoTelical reasons, ;;

is crucial that we leave that practice intact and free of our own biases. Thus, we will

uncritically adopt, in I-LISP, the

notions of evaluation, lists, free and global

variables, anci so forth, although we will of course be at considerable pains to document all of these features rather carefully.

As an example of the style of analysis we will engage in, we present here a diagram of the category structure of I-LISP that we will formulate ill preparation for the category alignment mandate dominating 2-L ISP:

(51-29)

l_exical

Numerals labels Dotted P.

"lis""

Structural

Numerals Atoms Pairs

Der. Str.

Numerals Atoms Pairs Lists

Procedural

Declarative

T.Values Numbers

Functions Sex rs Soquences

The intent of the diagram is to show that in I-tISP (as jn any computational calculus) there are a variety of ways in v/hich structures or s-exprcssions may be categorised; the point we are attcDipting to demonstrate is the (unnecessary) (;omplexity of interaction between these

**various categorical decompositions.
**

In particular, we may just briefly consider each of these various categorisations. The first (notational)

i~

t -L ISP

L terms of the lexical

catcgo~es

that arc accepted

by the reader (including strings lIlat are parsed into notations for nurnerals, lexical atoms,

and "list" and "doltt~d-pair" notations for p:drs). Another (structural) is in tenns of the

primitive types of s-expression (numerals, atoms, and pairs); this is the categorisation that is

typically revealed by the primitive structure typing predicates (we will ,-;all

tl~js

procedure

NIL. general lists (including the atoln signify enumerations (sequences): the numerals nunlbcls. Any reflective program in I-lISP would have tn know about all of these various different categorisations. and vi) other lists.:)) . v) lists whose first clement is the atom QUOTE. rather than a function (as for exatnplc in (APPl Y (CAR '( + . each handled differently. .n l' vafiablcs can signify semaIltical entities of arbitrary type except that the)J cannot designate jUnctions (since sig~ ~fy l-lI~P and NIL signify Truth a!ld Falsity. which are ~3cd to encode applicable functions. so fbrlh. Finall)'.lnporl) has to do with declarative semantics - what categories of structure signify aifferent sorts of scmantical entities. We need not dwell on the obv:ous fact that confusion is a outcome of this categorical disarray. X». . When the function is dc&. We mentioned above APPl \' ~~at l-L. the fifth taxonomy (declarative .pr than (+ X) or (+ . 2. and about the relationships between them (as presumably all human lik~ly LIStl programmers do).gnatcd by a v[triable rather than by a global const'lnt (thus one must us~ (LET «FUN '+) (APPLY r-UN t{l 2») rather than (LET { (rUN '+» (FUW 1 2»}. iii) the riiscriminated categories: i) the self-evaluating atoms other atoms.y of circumstances.ISP requires tIle explicit use of in a variet. When th" arguments to a multi-arguITJcnt procedure arc designated by a single term. depending on context. third traditional categorisation (derived structur'. When a'1 argument expression designates a ftlllction /laIne. which in evaluable positions represent function application.a category built up from some pairs NIL.1l) includes not only the primitive s- expression types but also the (those whose CORS notion of a lisl . recursively. ATOM and NUMBERP). used as variables or global function designators. one must usc (APPLY '+ X) ratl. are. lists) and the atom A fourth taxonomy (procedural I-lISP'S EVAL consequence) is embodied by the primitive processor: thus finds at the top of the meta-circular definition of EVAl T sorts strnctures into various categolies. ()nc other example of I-LISP behaviour will be illustrative.1. iv) !ists whose first clement is the atom LAMBDA. the atoms HI l) . This is the "dispatch" that one typically and and APPLY. ii) There are usually six the numerals. Introduction TYPE Procedural Reflection but it is traditionally encoded in an amalgam of d~rived 85 A in I-LISP. thes~ incllidc the fiil1owiJlg: 1. and so on and. rather than individually (thus if x evaluates to the list (3 4). 3. (2 3) ». Once again a different category structure emerges: applications and is first-order).

lJ» wuuld evaluate in 1-l I SP in z- . nonnalises to to SF (the primitive 2-lISP boolean constant rlesignating falsity). The Design OI2-LISP Though it meets our criterion of simplicity. Thus the quoted tcrm normaliscs to itscl r Similarly. because it deals inherently with the designation oth~r of expressions. even though the resulting calculus will still fail to meet the requirements of a procedurally reflective mandates are embodied in tIle design of 2-LISP. 'Nhere by nonr:alisalioll we refer to a tJarticu)af fonn of expression sinlpJification that takes each stnlcture into what we call a norlnal-form designator of that expression's referent (nonnalisation is thus designation preserving). which in I-LISP would evaluate to x. will occupy a substantial part of the dissertation. The adequately treated in the object language three will be I. On the other hand an obvious superficial difference is that meta. whereas 'X..fii. as described in the previous sectio. semantics in general. 2-lISP'3 processor is not called EVAL. but NORMALISE. IISP field) are treated in a Inanner that looks very and the ~xprcssion similar to (= 2 3) I-LISP.1. The details will emerge in chapter 4.I. we will. as the previous two examples will suggest. in 2-lISP (and 3-lISP) only the first of these wilt require explicitly m~ntioning the processor function by name. results. since rather than (EVAL (CONS '+ (LIST X Y» although itself extensional (is an EXPR). 96 When the arguments to a function are "already evaluated". Procedural Reflection APPLY.. Introduction 4.evaluatc the arguments even if the procedure being applied is an EXPR (thus one uses (APPLY '+ (LIST X Y». The expression (+ 2 3). Once we have introduced it. subject it to a scmantical analysis that will lead us into an examination ()f computational. for example. I-lISP wili provide more than ample material for further development. here will sketch how its evaluation in favour of independent notions of silnpJijicalioll and reference. The most striking difference between 1-LISP and 2-lISP is that the latter rejects We discussed what sClnantic rationalisation comes to itl the previous section. but a sense of the resulting architecture can be given here. 'Ibe search for semantical rationalisation. As we will see below.structural tenns are not autonlatically dc"refcrenccd. ». as mentioned earlier. in to 2-LISP At (CAR • (A . anl1 the exposition of the 2-lISP that dial~t. Thus. docs not re. Simple object Icvel computations in tenns designating other clements of the 2-lISP (those that qO not involve meta-structural 6. rather than with the designation of their referents.

(A z • »»" but into n(f • [At Az . not into tl Cf . I-LISP to (/\ ."s Declarative Atoms Booleans Hails Pairs Handles ~ Numbers T. So called "Quoted expressions" are primitive. illustrating once again thc category alignment that pcnncates the design.. and semantics.. • NIL) . (AI. not applications in de~ignated). in the corresponding expression would return ' (A From these trivial exampies.. but rather a primitive data structure called a rail tllat serves the function of designating a sequence of entities (pairs are still used to encode function applications). For one tIling 2-LISP is statically seoped (like SCUEME) and higher-order (function-designating expressions may be pas~ed as regular arguments). in particular. in terms of both structure. em~rgc in 2-LJSP as standard expressions. but rather the primitive notation for a handle that is the unique nonnal·fonn designator of the atom x. ... In fact. There are other notational differences as well: rails arc written with square brackets (thus the expression (. and all tcnn '''closure'' to refer to a norJnal-fonn [unction designator. At])". notates a rail of three numerals that designates a sequence of three At)" exp~nd numbers). an ill-advised way to think of the 2-LISP processor emerges: as if it were just like the 1-LISP processor except that it puts a quote back on before returning the result. however. tenns of a QUOTE procedure. • (At "[1 2 3]".. is not an abbreviation for (QUOTE X). which have historically been treated as rather curiously somewhere between functions and expressions. (CONS 'A 'B) would ev&1uate in • B). in fact we define the Closures are pairs. Introduction LISP it Procedural Refl. B)..Values Sequences Functions Structures Uandles Closures. Structurally 2-LISP is also rattlcr different from I-LISP: there is no derived notion of list. nonnal-fonn pairs are closures. and they are canonical (one per structure The notation •x. and expressions of the form "(F At Az .~tion 87 2-LISP would normalise to 'A.1.. The category structure of Lexical Numerals Atoms Booleans Rails Pairs Handles 2-LISP is sli~-11marised in the following diagram: (SI-30) Structural tJumeral s Procedural Numerals Atoms Booleans Rails Pai. procedural protocols. the differences are much more substantial.

lJ)' "level-crossing" expressions form the stock-in-trade of a reflective system designer. A variety of facts emerge from this result First. task adequately "til Primitive procedures called NAME and REFERENT (abbreviated as '3. If ']l1e issue of the explicit use of LISP ') APPL Y".FERENT "A) normalises to to 'A. as in the A-calculus. as it happens. is instructive to examine in EVAL 2-LISP. "apply" is a functional that maps 'functions and (sequences of) arguments onto the value of the function at that argument position - thus making it a second (or higher) order function. Much of the complexity in defining 2-LISP will emerge only wIlen we consider The intricacies of just suctl forms that designate other semantically significant fonns. and the semantic differences bctween functions and APPLY 2-lISP nnd its precursor dialect. and "-loU) are provided to mediate bctweeen sign and significant (they nlust be primitive (NAME 3) because otherwise the processor remains semantically flat). ftappl y" takes two expressions as arguments. but it rrJuch less clear what application is defined over. generating code such as macros and debuggers and so forth there is no need to worry about whether an expression has already been processed. On one view. thus and (RF. yielding a partially simplified expression that will have the same designation and same nonnal-form as the original. In 2LISP we will call the first of these application and the second reduction (the latter in part . Introduction Procedural Reflection 88 All 2-LISP normal-form designators are not only stable (self-normalising). since second and subsequent proccssings will never cause any harm (nor. and has as a value u third expression that designates the value of the function designated by the first argument at the argument position dcsignated by tile second. the primitive processor (NORMALISE) can be proved to be idelnpotent. and only setting such issues straight before we consider reflection proper will we face the latter pl~parcd. the result of normalising a constituent (in an extensional context) in a composite expression Catl be substituted back into the original expressiofi_ in In addition. in code- place of the un-nonnalised expression. Evaluation is IS uncritically thought to be defined over expressions. in tenns of both result and total effect: VS [(NORMALISE S) ~ (NORMALISE (NORMALISE S»] (51-31) Consequently. I-LISP. On another. will they take substantial time). the two mesh in a well-known mutually-recursive fashion. but are also side-effect free and context-independent.1. which we tncntioned !Jricfly in discussing since it manifests bo1l1 the In stru~tural 1- above.

APPLY (51-34) in contrast. Current (in MAClISP. since it is a Incta-structural function. 2. 0951 Application The procedure REDUCE. 2-LISP lAMDOA 2-lISP and 1-LISP is provided in is lexically scoped. and the value is not). ARGS) REDUCE. whereas the arguments The position we will adopt is depicted in the argument is not. the function position in an application (the CAR of a pair) is normalised just as other positions arc. Introduction Procedural Reflection ill 89 because the word suggests an operation over expressions. However it will function. since any tenn (APPLY FUN ARGS) would be entirely equivalent in effect to (51-33) (FUN .1. and may be designated by standard variables and argumCnLf). and in our construction of the reflective turn out that there is no reason to define a designator of the of the fonn APPLY 3-lISP. . part by analogy with the fJ- LISP systems are less than lucid regarding this distinction for example. following diagram (which we will explain more fully in chapter 3): (51-32) Reduction FD: Fune. Functions arc first-class semantical objects. in the sense that variables free in the body of a form take on the bindings in force in their statically enclosing context. A summary of the most salient differences between the following list: 1. the function argument is an expression. together with NORMALISE will of course play a major role in our characterisation of 2-lISP. and reduction of Church I6 ). is neither ti:: '/lal to define (as is) nor recursively empty. As a consequence. rather than frOITI th~ dynamically enclosing context at the time of function application.

that respectively encode function applications and sequence enumerations. form designators. in particular.. For example. the rails) and of functions (the pairs) are not. and handles) arc unique. with tlle result that intensional proccdllres bcconlc extremely . we wil~ not speak of a variable's value. 11. Procedural Reflection 90 Evaluation is rejected in favour of independent notions of simp/ifcalion and reference. r"ther that designative.e. Closures . Introduction 3. The usc of LAMBDA is purely an issue of abstraction and naming. it nonna/ises expressions. it \vin turn out that the clean sel11antical separation bctween meta-levels is not yet matched with a clean procedural separation. g. nOffilal-form designators nf sequcnces (i. "rhough we will speak of the binding of a variable.. and context independent. we wilt begin to fails to be reflective. Though not all nannal-form expressions arc canonical (functions. Variable binding is co-designative..are valid ar '"l inspectable sexpressions. side-effect free. in the sense that a variable nonnaJises to what it is bOlAhd to. therefore the question docs not arise in their case. 6. Identity considerations on nonnal-form designators arc as follows: the normalfonn designators of truth-values. 10. and s-exprcssions (i. intensional. too strong a separation between environments.1. numbers. in ctiticise it In particular. A number of problems in particular clnerge as trou'Jlcsome. The primitive processor is a particular kind of silnplijier. and is completely divorced from procedural type (extensional. rather than being an evaluator. nlacro. the boolcans. pairs and rails. 2-LISP is category-aligned (as indicated in 51-30 above): there are two distinct structural types. 6. returning for each input expression a normal-form co-designator. 4. rrherc is no distinguished atom NIL. in order to shift level of designation one of the explicit semantical primitives NAME or REFERENT must be applied. referent of the expression to Wl1icll it is bound. 7. since that tenn is ambiguous between these two.. 8. we will provide an analysis of how 2-lISP spite of its semanlical cleanliness. No atoms are nornlat. As soon as we have settled on the definition of 2-lISP. nUlnerats.nonnal-form function designators .e. prior to and independent of the specification of how they are treated by the processor function (this is a pre-requisite to any claim that the processor is designation-preserving):. In particular. A complete theory of declarative semantics is postulated for all s-exprcssions. nevertheless they are all stable (sclf-nonnalising). and of the referent of a variable. The primitive processor (NORMALISE) is selnantically flat. may have arbitrarily many distinct normal-fonn designators).. ll1cre is in addition a special two-clement structural class of boolean constants. First. however. and so forth). and L'1ercforc designates th.

a causally connected variant on tile meta-circular interpreter of 2-lISP. presented in chapter 5.. Once all these moves have been taken it will be possible to Inerge the explicit reflective version of SIMPLIFY and other words the 3-LISP REDUCE.ti. is tile 3-LISP reflective model. 2-LISP 3-lISP. as mentioned in the discussion eartier. J. differs Each reflective level is from in a variety of ways. we will demonstrate a meta-circular impleOlcntation of 2-lISP. a03 in we will provide REDUCE).:ndcrlying processor. It was a consequence of defining 2-lISP in terms of SIMPLIFY that the 2-LISP interpreter "Stays scolantically stable": the scmantical level of an input expression is always the same as that of the expression to which it simplifies. Surprisingly. 2-lISP with explicit names for its basic interpreter functions (NORMALISE and However these two facilities will remain utterly unconnected .. the integration of reflective power into the meta-circular (now reflective) m<Kfel is itself extremely simple (although to implel11ent the resulting machine is not trivial). since they can be the values of bound variables). awkward interactioiiS between the flluch 2-lISP control stacks of inter-level programs will show how. are theory relative: the (procedural) theory in question. with the environments and continuations of the levels below it accessible as first-class objects (Incriting a Quinean stamp of ontological approval. In 2-LISP reflective model unifies what in were separate: pritnitivc names for the t. insufficient causal connection. the semantical the result is also the same as titat of all of the argllmcnts. there is copoection. In addition. the fundamental reflective act is identified and accorded tbe centrality it deserves in the underlying definition.c. granted its own environment and continuation structure. 2-LISP'S Procedural Reflection 91 inchoate reflective facilities suffer from 100 On the other hand.1. An even stronger claim holds for function application: except in the case of tJ1C functions level ~f NAME and REFERENT. in one respect. lbese environments and cfJntinuations. The Procedurally Reflective 3-LISP From this last analysis will emerge L'le design of liSP 3-LISP. First. Introduction difficult tn u&e. and explicit meta-circular progrRms demonstrating the procedural structure of that processor. rfhjs is all evidence of the attempt to drive a wedge between si1nplijicatioIJ and de-referencing that we mentioned .an instance of a general problem we will have discussed in chapter 3 on reflection in general. a procedurally reflective and the last of the dialects we will consider. in other respccts. discussed in section l. and the similarly named primitive functions.. shows that.

in the case of reflective functions). will be provided by way of definition. however. ~oth the 3-LISP reflective model. we will present a number of examples of prL'grams defined in it: a variety of standard functions that make use (. In a more pragmatic vein.and of course this is one of the reasons we made 2-LISP this way .. or of showing that such models fit 3-LISP dialect naturally and slmply into the (as a simple condnujlion-passing str1c can for 111C claim is stronger: that they can be example be shown to be adapted in SCHEME). the correspondence is in fact asymetric: declarative levels can be crossed within a given reflective level. A fixed-level interpreter like this . theore~~.:al 3-lISP 3-LISP as a as a Nor is this siInply a matter of using vehicle to model these various constructs. Introduction Procedural Reflection 92 earlier.. at any point in the course of the conlpute'ltion t the continuation is explicitly available (upon reflection) for those programs . explicit evaluation. can be clnbcGdrd in "pure" programs recommends plausible dialect in its own right. This does not quite have the status of a claim. surprisingly. and in part to show how 3-lISP satisfies Inany of the desiderata that motivated the original definition of the concept of reflection. In addition.enables us to make an important move: becau~e we can approximately identify declarative meta levels with procedural reflective levels. 3-LISP inherits this se~nantical characterisation (it even remains true. it is virtually mandated by the knowledge representation hypothesis (furthermore. The suggestion will be Inadc that the case with which these power:. some hints will be presented of the style of semantical equations that a traditional denotational-scmantics account of 3-lISP would need to satisfy. nonetheless. what \\'as tacit prior to reflection is used upon reflection.1. we are able to lift structures that arc normally tacit into explicit view in one simple reflective step. more standard practic~. naturally embedded in a manner that allows them to be congenially mixed (wiLhout pre- compilation) with the simpler. But it is instructive to realise that we have been able to idcl1tify the reflective act (that makes available the structures encoding the int('rpretive state and so forth) with the shift from objects to their names. but reflective shifts always involve shifts of designation). access to the implementation (1cbuggers t "single-steppers". Although tIle user need nol use an explicit continuation-passing style. although a full semantical treatment of such a calculus has yet to be worked out. When this behaviour is combined with the ability for reflection to recurse. we can then obtain access to designators of those structures in another. and I' so forth)t and non-standard evaluation protocols. Thus what was used prior to reflection is lnenlioned upon reflecting. and a MAClISP implementation of it.

16 In spite of this difference.and tt'ic. Reconstruction Rather Thall Design 2-lISP and 3-lISP can claim to b~ dialects of LISP only on a generous LISP J.' interpretation. The resulting infinite abstract machine is wetl defined. pro~lems perhaps better suited for a certain class of than those that have gone before. MOL. is one of the reasons that the dissertation is as long as it is - that the architecture of these new dialects. 11le two dialects are unarguably more different from the original than are allY other dialects thaI have been pro/)osed.t. NIL.em as new variants in a grand tradition. and cannot tell that all infinitude of levels are not being run (tllC implementation surreptitiously constructs them and places thtm in view cactI time the user's program steps back to view them).e. including for example SEUS. the ic{inite characterisation is probably to be preferred. Since the user can write programs to be interpreted at any of these reflective levels. we claim Rather . psychologically intuitive reflection machine at some l~vel It is the goals of modelling based on a vague desire to locate the self of the or other - that will lead us usually to use the language of explicit shifts (this also more closely Inimics the implementation we will Ilave built). INTERlISP. MACLISP.1. we will already have laid For SOIne purposes this is the simplest way to describe 3-lISP. although if 3LISP were to be treated as a pur Jy fonnal object. however. Procedural Reflection 93 Similar remarks hold for other aspects of the control structure and environment One final comment on the architecture of 3-LISP will relate it to the "two views on reflection" that were mentioned at the end of section I. for it is of course 3-LISP behaviourally indistinguishable from the perfcctly finite out (and implemented). non-reflected ove~eeing non-reflective point. We do not simply propose L. and COMMON IISP. Introduction that wish to deal with it directly.j:iv. SCHEME. it is important to our enterprise to call these languages LISP. by aT' (infinitely fleet) processor. This fact allows us to posit that 3-LISP runs in virtue of an infinite number of levels of reflective model all running at once. in spite of its difference from that of standard . Interpretation mediated by the 3-LISP reflective model is guaranteed to yield indistinguishable behaviour (at least from a there are subtleties here) from basic. such a characterisatioH is sometimes more illuminating than talk of the processor "swi!Ching back and forth from one level to another". of view - interpretation. l.

. in other words . Whether better than previous LISPS 2-LISP or 3-lISP is is of course a matter of some interest on its own.1. Procedural Reflection 94 is Q more accurate reconstruction of the underlying coherence that organises our communal understandillg of what LISP is. Introduction LISPS. We are making a claim.a claim that should ultimately be judged as right or wrong. but it is not the thesis that this dissertation has set out to argue.

of infonnation about object-level structures. Similarly. used to guide a deduction process. a large body of prior work. and semantical studies of programming languages). and so forth. 2. conn~tions We will make detailed comments about our discussion (for example in chapter with such work throughout the ? we will compare our notion of self-reference with the bu~ traditional notion made here.g. l)oyle. 20 although declarative statements (for example about dependencies) are perhaps more common.cd in logic and tnathematics). the meta-level rules of Davis in his system. with respect to which particular procedural protocols are defined. of which the dependency-directed deduction protocols prcs~nted by Stallman and Sussmad. 17 This work depends on explicit TEIRESIUS encodings. Remarks I. Investigations into the meta-cognitive and intensional aspects of problem solving (this includes much of current research in artificial intelligence). and related to. General studies of semantics (including both natural language and logical theories of semantics. and including the formal study of the paradoAcs. and others arc an illustrative example. of the sort that have characterised much of metamathematics and theol . the research presented here is of course dependent on. 3.1.of computability throughout this century particularly since Russell.. McAllcster. The design of logical and procedural languages (including virtually all of programming language research. ~. Introduction Procedural Reflection 9S l. Some of these expressions are primarily procedural in intent. There are in particular fOUf general areas of study with which our project is best compared: 1..g. . the incompleteness results of Godel. some general comments should be Consider first the meta-cognitive aspects of problem-solving. and Studies of self-reference. 18 and tile use of meta-levels rules as an aid in planning. 19 can be vie\ved as examples of inchoate reflective problem solvers. 4. as well as the study of logics and other declarative calculi). in some form of mcta-Ianguag(.' Comparision with Other Work Although we know of no previous attempts to construct eitller a semantically rationalised or a reflective computational calculus.

independent of what such facilities are then used for. it is difficult. As vletl as these differences in goals there arc differences in content (we for example endorse a set uf reflective levels. without actually contributing solutions to any of his particular problems about how reflection should be effectively used. it is natural to ask whether it would be a suitable language for Doyle to use to implement his systcln. but rather if it allows them to forget that the techaical details of reflection were ever consicJer~d problematic. our 3-lISP is not a problem solver at all (it is a language very much in need of programming).. we attempt to provide a rigorous account of the particular issues that have to do simply with providing such reflective abilities. Given that 3-lISP is not a problem solver of the sort Doyle proposes. The "reflective problem-solver" reported by Doyle 21 deserves a special comment: again.vide variety of applications.edure3 will enable those who use 3-lISP or any subsequent reflective dialect to treat "backing-off' in the natural way. and LISP. since his report is than final. although the fact that others arc working in this area is a motivation for our research. and so forth. however. An analogy might be drawn to the development of the A-calculus. Rather. to embody complex theories of the world. symbolic computation. We do not present (or even hint at) problem solving strategies involving reflective manipulation. Doyle's envisaged machine is a full-scale problem solver.n treat the h -calculus in the natural way. it embodies only a small procedural theory of itself. depending 011 how he takes his . Introduction Procedural Reflection 96 The relationship of our project to this type of work is more accurately described as one of support. in relationship to tlie use of these fonnalisms in mathematics. and so fartlt: the fanner projects provide a language and architecture. it is also (at least so he argues) presumed to be large. or when its deployment is appropriate. 1bere arc two different kinds of answer to this question. to be used reliably and perhaps without much conscious thought. nnd it is really quite small. to determine with very much detail what his proposal comes to. The present diGsertation will be successful not so much if it forces everyone working in meta-cognitive areas to think about the architecture of reflective fonnalisms. recursive equations. as the basis for a . we provide an underlying architecture which might facilitate his project. In contrast. rather than any kind of true instantanr:ous more sugg~stivc sclf"referen~iat reflexive reasoning).1. Church's a-reduction was a successful manoeuvre precisely because it Oleans that one CC). we hope that our treatment of rt:flective proc. rather than of direct contribution.

but it is important to recognise that its reflective powers cannot be used direc:.. architect-Jre.. is first and foremost a scmantical phenomenon. a process reduced in tenns of an ingredient processor and a structural field). not limitations of our particular theory or dialect (i. one must make that architecture reflective on its own. and then use in d reflective POy.. the uniformity of a nOflnalisjng processor. then 3-LISP'S reflective powers will not in themselves immediately engender corresponding reflective powers in the virtual machine that he implements. What would presumably be an architecture and a concomitant set of useful to Doyle (or to anyone else in a parallel circumstance) is the detailed structure of a ~ reflective system that we explicate here theoretical terms m~gJlt 10 help hill' analyse and structure whatever architecture he adopts.e. 3-LISP. . the strategy of using a virtually infinite processor in a finite nlannCf. in other words. r(ither than defending a generic reflective . It is in . such a projcct tc the extent that it is generally a useful and powerful language.1. and thus usc the reflective There are. nc~ at this level that our contribution is primarily aiIncd. and wishes to implement it in some convenient underlying language. Reflection. they would be equally tfile of any other proposed architecture). the elegance of a category-aligned language. and so forth. furthermore. to encode a full descriptive language on top of 3-lISP.d not be possible. however. and sf/nanlica! properties nonnalisation protocols and reflection and the rest designation and would be useful in do not cross intplementation 3-LISP boundaries (this is one of the great powers of implelllentation).. they arc entailments of fundamental facts of computation and semantics.-crs to reflect general sense with these descriptive structures.-.ty to provide refle reflective capabilities in other architectures implemented on top of it Of course Doyle would have an alternative strategy open to him. consequences of this approach: he would have to accept 3-lISP structures and semantics. as we are at considerable pains to demonstrate. If one aims to construct a general or purely descriptive fonnalism. None of these conclusions stand as criticisms of 3-lISP. If. he could perhaps construct such behaviour in capabilities of that dialect rather directly. It woul. it is . the relationship between sClnantical levels and reflective ievels. including the fact that 3-lISP'S it is purely a procedural fonnalism. he more simply intended to show how a particular kind of reflective reasoning was useful. Introduction Procedural Reflection 97 Ilroject If he is proposing a design of a complete computational architecture (Le. the encoding of the reflective model within the calculus. .. by which (te could use 3-LISt>'S reflective powers more directly.. 111us we expect him to make usc of the vIc) distinction..

includes a meta-level debugging system that allo'ws for the inspection and incremental modification of code in the midst of a computation.~s for a variety of other projects trad~tion from the fO!ll1al statement of theories. no additional comment is r('quired here.. 2-lISP (in an early version of the dissertation I called SCHEME "1. the SMAllTALK languagc. the relationship between our notions of reflection and traditional concepts of self-reference are taken up in more detail in chapter 5. The PROLOG calculus. rather than presenting a given calculus under a unified theory.26 to mention just one example. (including logic and the A-calculus and virtually all of programming language research) that it might seem difficult to say anything specific.6 in many ways the most direct precursor of 2-lISP). \lIe compare our approach to this subject with model theories in logic. throughout the text.. must be discounted as a candidate. Unless a fannal system embodies a locus of active agency - the entire question of causal relationship between an encoding of self-referential theory and what we consider a genuine reflective model cannot .22 and also to the recent work of Steele and Sussman. The third and fourth classes of previous work where list·~d above have to do with general semantics and with self reference. we of course owe a trelnendcus debt to the LISP traditioll in general. internal processor of some sort ~onstraincd VIC ahnost entirely to an computational fonnalisms. Similarly. since it provides two calculi together. since it takes what I see as half the step from LISP to our semantically rationalised Second. Introduccon Procedural Reflection 98 this sense that the theory and understanding that 3-LISP embodies would (\ve hope) contribute to this variety of research. as docunlcntec. but a variety of comments can be nlade. the construction of computational We include here such a large processes. First. Finally. The second type of research with which our project has strong ties is the general tradition of providing fonnalisms to be used as languages and vehiciG.24 as \VC ntentioned the introduction. here merely conllncnt that our concerns are. our explicit attempt to unify the a project ill declarative and procedural aspects of this tradition has already been mentioned that is (as far as we know) without precedent. and the tradition of programming language semantics.. and so forth. inchoate reflective behaviour can be found in virtually all comers of computational practice. "fhe first of these is considered explicitly in chapter 3. the analysis of human language.7-LISP . perhaps surprisingly. 23 Particularly important is their SCHEME dialect 1. rather than the particular fonnalism we have demonstrated by way of illustration. semantics of the A-calculus.1.

There are no notions of next or of lvhen a certain deduction is made. First. however. Nevertheless Furthermore. it is our claim that the greatest power will arise fronl dismantling the difference between procedural and declarative calculi. Introd'Jction Procedural Reflection 99 even be asked.the distinction between declarative and procedural languages (first order logic and LISP. in the purely declarative tradition derivabillty is a simple fonnal relationship that holds between certain sentence types. however not merely in its cannot fairly reflective incarnation. for example. of a natural deduction "process" or some other kind of deductive apparatus making inferences over first-order sentences this he11ristic makes sense of the formal notion of derivability. and b) is not yet such a formalism. Weyhrauch claims that the power that emerges froln combining (although maintaining as distinct) tllcse L-S pairs ("Iangauge-simulation-structure" pairs) at each level in his meta hicl. it would appear in Wcyhrauch's systcins as if that particular seolantical relationship is abandoned in favour of internal . although reflective. no activity is involved. is a problem solver: it clnbodies a FOl'S theoreln-prover. adopts .1. Strictly speaking. since . rIlle resulting machine. but even prior to that. in particular).it is purely procedural.. but rather a full computational formalism of some sort. 3-lISP. then it is imaginable that one could include sentences (relative to some axiomatisation of that deductive process) in such a way that the operations of the deductive process were appropriately controlled by those sentences (this is tile suggestion we explored briefly in section l. in virtue of the addition of independent agency.bji).~rchy as one of his primary contributions. We conclude with one final comparison. FOl FOt is not a jJrogranlnlillg language. If one \vere to specify an active deductive precess over such first-order sentel!ces. We often infonnalty think. using the procedural calculus as a sinllllaliJII structure rather than as a descriptive or dcsignational language. like Doyle's system. Our position with respect to such an image rests on two observations: a) it would be an inllcrently computational artefact.26 although our project differs in several important FOl. technical ways from his. 1'here are other differences as well: the interpretation function that maps terms onto objects in the world outside the cOlnputational SystCITI (4) is cruch:l to us. although it is possible (through the use of Incta-levcls) to give it guidance about the deduction process. rIlle i':1rmalism closest in spirit to Richard Weyhrauch's FOl 3-LISP is system.in fact explicitly endorses . by including an attive agency - be considered simply a logic. Of course we believe that a reflective version of a descriptive system like this could be build (in fact we intend to construct just such a lnachine).

Furthermore. and we go to considerable trouble to maintain an approach in which all computational structures arc selllQntical in something like a linguistic sense. semantical meta-theories. and the theoretical analyses on which they are based are aimcst unrelated. that this is a limited view. When we type processor and it returns (+ 1 2) II "3" we are liable to take tllosC numerals not so much as designators of the respective numbers. although the actual structure of the descriptive language. rather than with deep ontological or cpi~temologica1 beliefs. There is no doubt that the input expression II is a linguistic artefact.in the sense of an (abstract) artefact whose structure or behaviour mimics that of sonle other world of interest. FOL In sum. and so forth. although there is some evidence 27 that this apparent difference may have to do with our respective uses of terminology. Introduction Procedural Reflection 100 relationships between one fannal system and another. and 3-LISP are technically quite distinct. 111cre arc nluny issues. It is clear franl Weyhrauch's system that he considers the procedural fomlalism to represent a kind of !!lode! of the \vorld . "(+ 1 2)" Under this approach the cOlnputntional behaviour can be taken in lieu of or ill place of the real behaviour in the world being Consider for example the numeral adJition that is the best approximation a to a LISP computer can tnake to actually adding numbers (whatever that might be). how such a system would differ from remains to be seen. on the view we will adopt in tilis "3" dissertation there is no doubt that the resultant numeral is also a linguistic artefact. having to do wittl . but instead as lnodels. intuitions. rather than the dual-calculus nature. Nevertheless at a more abstract level they are clearly based on similar and perhaps parallel. rather than sClving as lnodels. may also differ both in substance and in detail. but we want to admit here a not unnatural tendency to think of it as standing in place of the actual number. studied.1. would be the most obvious technical distinction. if not identical. in a different sense from standard designation. A more crucial distinction is hard to imagine. it is our explicit position that 3-LISP represents merely a first step in the development of a fully FOl reflective calculus based on a fully integrated theory of computation and representation. There is ho\vever one relnaining difference which is worth exploring in part because it reveals a deep but possibly distinctive character to our treatlnent of LISP. It seems likely that the resulting unified calculus. It is tJlis sense of silnulation rather than descriptio" It is our b~licf that underlies V/eyhrauch's usc of LISP.

. By" C S X R ]" we designate the (potentially infinite) set of all tuples whose first member is an clement of s and whose second member is an element of R. . Ak > . rather than over unstructured sets.1. 4. .. By "st" we refer to the i' th element of s. .. extended with some straightforward conventions (such as expressions of the fonn B]").. 11lus. ]]". A<A t . We in no way rule out computations that in different respects mimic the behaviour of the world they are about: it is clear that..A 2 . By" C A . B J" we refer to the domain of continuous functions from A to B.[AA 2 .A k • E" and by . by "AA t ... etc.A 2 . The Mathematical Meta. By "<5 1 . Parentheses and brackets are used interchangeably to indicate scope and function applications in the standard way. Bk )" we mean 6. ... certain fonns of human anlysis involve just this kind of thinking ("stepping througll" the transitions of some mechanism.. .. th~se: 3. ].Language Throughout the dissertation \\'e will employ an informal meta-language. By "r : C A -+ B 1" we mean that F is a function whose dGmain is A and whose range is B. 8. for . at worst it leads to a view of computational models in danger of being either radically solipsistic or even nihilist It is exactly the connection between a computational system and the world that motivates our entire approach. " j f P then A else a" as an abbreviation for "[P :J A] A [-'P :J Notationally we will use set-theoretic devices (union. We employ standard currying to deal with functions of several arguments. . built up from a rather eclectic combination of devices from quantificational logic. 2...lls in the Scott-tlteoretic sense. Similarly.C)2 is B). and "St".. and so forth. Introduction Procedural Reflection 101 such issues as truth.. OUf point is merely that such simulation is a kind of thinking about the world...[ .examlpe). .B.. [~Ak • E] . Sk)" we designate the mathematical sequence consisting of the designata of "St". The notations should by and large be self-explanatory: a few standard conventions worth noting are 1. completeness.. assuming that s is a sequence (thus <A.. "S2'" . that a simulation stance cannot deal with.. by . .). By "A·" we refer to the power domain of A: [ A U [A X A] U [A X A X A] U . a connection that can be ignored only at considerable peril. membership.. . it is not the world being thought about I. the lambda calculus.B 2 .5 2 . and lattice theory. 6.ii.. but these should be understood as defined over donla. En we mean "AA 1 .g. F(B 1 . 7.

Thus. but it would presumably be straightforward. as the preceding discussion will suggest. LISP The programming examples. in order that function continuity be maintained. were all tested on computer 2-lISP. and so forth. which can be approximately divided into two groups: formal statements about expressed in LISP LISP and about semantics expressed in the meta-language. and illustrative programs and structures itself (most of the latter are in one of the three LISP dialects. The meta-linguistic characterisations..Le.1'. though there are a few in stand&rd dialects as well). have not been checked by formal means for consistency or accuracy.1. the implclnclltation presented in the appendix is an actual computer listing). Any residual errors (it is hard to imagine every one has been eliminated) must have arisen either from typing errors or from mistakes in the implementation itself: "' .. It is not our intent here to make the mathematics rigourous. l.( (F(B t ) )Dz) . iii Examples and Implementations There are a considerable number of examples throughout the dissertation. the proofs and derivations were generated by the author using paper and pencil. )B t )" Procedural Reflection 102 If we were attempting to be more precise. although the examples in the text were typed in by the author as text . (a listing of the third of these is given in the appendix). we should use domains rather than sets. dialects of LISP and 3-LISP developed in the MAClISP and LISP MACHINE at M. implementations of 1-LISP. to take this extra step towards formal adequacy. on the other hand.g. Introduction "( ( .. the lines of characters in tllis document arc not actual photocopies of conlputer interaction nevertheless each was verified by these implementations (furthcnnorc.. given the accounts we will set down.I.

The most plausible extant candidates and Steele and Sunsman's SCHEME. would most naturally seem to be defined as higher order functions. I-LISP: A Basis Dialect Procedural Reflection 103 Chapter 2. with which to contrast the reconstructed and reflective dialects we will subsequently design. (LAMBDA ..2 the lexical scoping and "ful1-funarg"3 SCHEME recommend it both in tenns of theoretical cleanliness and in faithfulness to the A-calculus. since such "level-crossing" capabilities arc close to our primary subject matter. since much of how we understand are McCarthy's properties of LISP is most clearly revealed there. we -Nill ultimately want to look at user interaction. various versions have been reported.6 we would use (MAPCAR '(LAMUDA (X) (+ XI» '(2 3 4» (52-1) rather than (MAPCAR (LAMBDA (X) (+ X 1» '(2 3 4» MAPCAR (52-2) as a way of producing •(3 4 5).5 t "CONS" and are . and those functions that and APPLY. 4 SCHEME. since the first argument to rnust evaluaie to an expression (and designate an expression. LISP 1.are essentially first-order languages. expressions that we take to designate functions (like MAP employing meta-structural machinery to handle what is at heart higher order functionality. On the other hand EVAL SCHEME'S partial avoidance of such SCHEME. There is however a more serious difficulty witt1 semantics and reflection. although we have no way of saying dlat yet). ) It) cannot be used in regular argument position. . there is some ambiguity as to exactly what the teon "LIsprt denotes. In addition is not a fixed target. and will focus on the basic primitives.. like in fact defined over expressions. 1-LISP: ABasi') Dialect \Ve will base the technical analysis of subsequent chapters on a "standard" LISP.6 (and t11crcfore all in current use. There are o}ltions open regarding such a definition. as has often been remarked.6 Although LISP 1. LISP 1.. features as an explicitly available like IISP. not over functions as such. since they are all based on it) .6 has history and explicitly fonnulated semantics on its side. 1 Though we will initially be urlconcemed with issues of programming environments and input/output. for example. or APPLY weaken it for our purposes.2. In IISP 1. thus for example in LISP t. LISPS relating to our concern with As mentioned in the introduction.

in other words.~plicit functions EVAl since it is those support EVAL programmer to mimic higher-order functionality by SCHEME manipulating expressions in their place (current implementations of APPLY. since they arc typically neither meta-structural nor higher-order. is. is not meta- structural. whereas the A-calculus. in other words. language that it originally omitted the two functions that enable the and LISP 1. rather than as first-class procedures. the A-calculus.) The lambda Cal~ulus 3-LISP In spite of a certain cleanliness.'l 104 SCHEME by according functional arguments first class status (QUOTE. in spite SCHEME. however. (52-3) Meta-Structural f"irst Order Higher Order IISP 1. SCHEME as still de-references 111ela-slnlclural expressiolls upon evaluation (the A-calculus has no Incta-structural expressions. Procedural Reflection (S2-. in symmetric contrast. of course. but as "magic forms" like LAMBDA. 2. LISP 1. SCHEME takes a different stand in this space: it is both metaimportan~ structural and higher order. In particular. in other words. this is one of the reasons that it is them as distinct In fact it is plausibly because~ SCHEME in that it represents a first step towards including both of these functionalities. it would be . like will be meta-stnlctural and ~ighcr order. 2-tISP. whiie maintaining embraces a higher-order base and APPLY. so the issue docs not arise in its case). we will argue that the most natural separation between higher-order functionality and meta-structural PO\vcrs is not maintained in evaluation process - SCHEME'S that this Cilicial distinction.5 SCUEME.- calculus. occupy of their being extensional).5. it contains primitive operators in particular) that make the structural field (the syntactic domain) part of the standard model. Dnlike the ). traditional programming SCHEME.and 3-LISP. an untyped higher order formalism. are found in the fourth class. is only partially embraced in that dialect. LISP 1. like the A-calculus. is meta-structural but first-order.6 e).2. the separation of [ullction application from expression deSCHEME: referencing that arises naturally once one adopts the distinction is not reflected in we will make clear in chapter 3. is a valid expression). I-LISP: A Basis Dialect SCHEME. Since automatic dc-referencing is a practice we will argue against. but is higher order. These categorisations are summarised in the following diagram.5. Not Meta-Structural Standard Progranwing Languages (ALGOL etc. and languages~ three points in the four-way classification of programming languages generated by these two binary distinctions.

a designed to return a list constructed from the second argument. one must resort to the explicit use of APPLY and EVAl - in this respect SCHEME is like traditional lISPS. in order to apply a function to a sequence of argume. consider the following LISP number and a list 1. becadse of its higher-order orientation. It will. you would not have to quote the function APPL v: desigator. that is to say. in contrast with. and will ultimately (in 2-lISP) show hawaII standard objectifications can be adequately treated without requiring meta-structural designation.2. For example. SCHEME position is an intennediate one. but you would still have to use (lET «X '(3 4») (APPLY + X» . if that is not where we ourselves begin. I-lISP: A Basis Dialect SCHEME-like Procedural Reflection lOS confusing to base our analysis on a dialect located half-way between the firstand the position that on our view order (meta-structural) position taken by in other words. For example. There is a natural connection betweel1 the free vaiablc seoping protocols of a dialect and its functional "order". a parallel connection between lexical scoping and the adoption of a higher-order object language. Thus we find dynamic variable seoping protocols used in first-order languages that admit the meta-structural treatment of functions. This is SCHEME (52-5) We will be able to show how this property results from the lack of category correspondence shared by all these dialects. be easier to show that the LISP 1.6 (52-4) (LET «X '(3 4») (APPLY '+ X» in SCHEME. requiring meta-structural powers - machinery to deal with certain types of objectification and compositionality. rather than by a sequence of expressions.without. There is yet another advantage of starting with a first-order language. represents that natural semantical position once higher-order functions are admitted. whereas in LISP 1. but with each clement incrClncnted by the first argulnent: . For exanlple.6 (first-order) definition of a procedure of two arguments .nts when that sequence is designated by a single expression.6 one would use: This is LISP 1. There is another aspect of SCHEME against which we will argue: although it it still requires the use of meta-structural successfully deals with higher-order functionality in the base language .6.

. a higher order dialect such as definition: (DEFINE INCREASE (LAMBDA (NUN LIST) (MAPCAR (LAMBDA (EL) (+ EL NUM» (52-1) . 6 In a statically seoped (LAMBDA (EL) (+ EL NUM» dialect.2. 1-LISP: A. the expression passed to would be sep~ated completely from the context in which NUM was bouncL and the computation would fail. (Functional intensions are discussed more fully in chapter 4. In contrast. as well as standard EXPRS. the bindirlg of NUM would be found so long as MAPCAR did not itself use that variable name. and as long as the function designator was only passed downwards. SCHEME would support the following LIST») In this case. These issues relate as well to the question of whether the "function position" in an application ("F" in "( F A 8 C) It) is evaluated: lexically seoped higher-order languages typically evaluate that position just In addition. LISPS SCHEME and the A-calculus are are dynamically seoped and tirst There is no theoretical difficulty in defining. if the dialect were dynamically seoped. whereas all other order. mat . a lexica11y-scopcd first-order language. the only way in NUM which this natural use of the bound variable could work is for the dialect to be MAPCAR dynamically seoped. presumably correct (intended) function is designed in all cases. called I-LISP. It is by no means accidental. I-LISP supports what in are called FEXPRS and MACROS. Basis Dialect (DEFINE INCREASE (LAMBDA (NUM LIST) (MAPCAR '(LAMBDA (El) (+ EL NUM» LIST») Procedural Reflection 106 (52-6) Since MAPCAR requires an expression rather than a function as its argument. the as they do argument positons. first order languages naturally do not dynamic/lexical distinction relates to the question of what a calculus takes the intellsion of a function to be: dynamic scoping is closely associated with taking it to be an expression (againt consonant with a generally meta-structural stance). but such a calculus would be extremely awkward to usc. and so forth.e. We assume.) For all of these reasons we will base our progression of dynamically-scoped. first-order MAClISP liSP lISPS on a simple dialect. however. say. that the dialect is defined over numbers and truth-values as well as s-cxpressions (i. in other words. whereas lexical scoping associates with taking it to be something more abstract (consonant with a higher-order approach). as usual. that lexically seoped and higher order. If it were statically (lexically) seoped.

in other words. and also the investigations of Sussman and Steele. - In order to have a specific and structurally comparable dialect we will use tile name LISP" for our dialect of SCHEME structurally identical to SCHEME 1-LISP. etc.2. Winston.7- meta-circular interpreter cannot be straightforwardly encoded in a first-order dialect. however. the first element of which will be taken as signifying (in an as-yet unspecified way) a function. Allen. introducing function applications. We will in particular assume the discussions of IISP in McCarthy. 2-LISP and 3-LISP rThis task is taken up below. we will from time-to-time refer to SCHEME - dialect that supports higher-order functionality. as well as for general enumerations. in order to introduce the way that we will talk about fields in general. 7 We will depend particularly on the discussions of meta-circular interpreters and tail-recursion given by Steele and Sussman. and because it will be easiest to describe the fields with respect to this basis one. with 1. l'hus our trio of dialects is in fact a quartet. s What we will do. structural treatment: it is not in any foundational wayan issue of the manipulation of structures or expressions (as the existence of sound models for the untyped A-calculus of course has shown). meta-structural facilities. of course. practice of representing "applications" (what we will want to define an application to be will be taken up shortly) as lists. This syntactic form will be used in addition for what are called special forms6 such as lambda expressions. however. and Wciztnan. and a concomitant partial separatiOtl of meta-structural machinery SCHEME in part because the continuation-passing versions of the "1. We will show. In a fuller version of this dissertation it would be appropriate to define I-LISP completely. recursion. is one of freeing up the meta-structural capabilities of the calculus for use in reflection. We will not take up this task here. in other . but statically scoped and supporting functional arguments in the manner.. a As well as using I-LISP as a base. between 1-LISP and 2-lISP. that lligher-ordcr functionality is not inherently a subject requiring meta. and so forth.. I-LISP: A Basis Dialect T Procedural Reflection and NIL 107 numerals and the boolean constants We will adopt the standard LISP are elements of the l-LISP structural field).7-lISP/SCHEME sitting slightly to the side. seoping protocols. deferring the reader to the literature for most of these preparations. The overall mandate under Wllicll all of this is pursued. quotations. is to characterise the I-LISP structural field. unimpeded by intruding consequences of higher-order functionality and simple objectification. and the remaining elements as signifying arguments to that function. The fact that SCHEME only partially separates the two notions.

the basic intuition underlying how we understand the applies functions to arguments. is inherently concerned with expressions and their interpretation.2. on the other hand. the use of continuations. Included will be notions of THROW and CATCH (and other non-local control jumps). i-LISP: A Basis Dialect Procedural Reflection 108 words.in terms of a depth-first recursive tree walk. enabling him to build up wllat seem to be complex function definitions from simpler ones. nrogramming environment constructs that enable a user to manipt!late the stack and environment. For example. tail-recursion. In characterising 1-LISP. the expression returns 5. We will look at these two kinds of understanding in turn. For example.he number 16. Both and + are primitive functions. we must distinguish two kinds of understandings. 10 Reflection. First. tlle expression (52-8) (DEFINE INCREMENT (LAMBDA (X) (+ XI») defines a new function called INCREMENT in tcnns of the prhnitivc addition function. and so forth. In otllcr words. It is . discussions can again be found in the reports of Sussman and Steele. the expression ( INCREMENT 16) can be viewed as representing application of this new function to t.~e LISP community. the fact that evaluates to CARS. A is typically explained in tenns of (+ 2 3) a function from pairs to their CAR Similarly. because we understand it as representing the application of the addition function tv the numbers two and t1lree. After this deflnitio~ th~ has taken effect. Most of these are part of the accepted lore in. one a non-computational but powerful conception fonnulated in terms of function application. the syntactic methods of defining composite procedures facilitate the user thinking that he or . as well as being provided with this primitive set the programmer is provided with a variety of naming conventions and compositional construction techniques. the other a computational and complete but less convivial account in tenns of formal expression manipulationt . meta-circular interpreters. and thus will We will also depend on a variety of computational concepts and practices that will emerge in subsequent examples. will be shown to be an unnecessary aspect of its design necessarily involve the use of meta-structural machinery. One final remark. returning their values ( CAR • (A B» 1-LISP processor is that it IISP this is why CAR being is the paradigmatic example of what are called applicalive languages. but to confuse them can lead to misconceptions later in the anlaysis. to LISP'S credit tllat these two kinds of understanding can by and 'large be allied.

in various context-dependent ways. this taking of expressions to represent the application of functions to arguments is something we external observers do. function application is not what the lvhat we semantically take the LISP LISP processor actually does.a fact whose importance cannot be overestimated. That this is how we understand IISP procedures is reflected as well in the CAR naturalness of the view reflected in traditional semantics on which s-expressions like and ( LAMBDA (X) (+ Xl» are taken to designate functions. a serial processor - What the 1-lISP processor actually docs is of course Jonnal. I-LISP: A Basis Dialect Procedural Reflection 109 she is able to describe complex functions that. although it permeates our language and practice. ultimately e~·ccuting tile prhnitivc "instructions" or "procedures" whose primitively re. is nonetheless not a computational intuition . 11lc processor merely embodies a controlled set of state-changing operations guided by this recursive-descent control pattern. In simple cases we can substitute one understanding for another. but rather of designatioll of functional teons and application and so forth: all Platonic and mathematical abstractions. or complexities. LISP nor does it need any access - to that Rather. subtleties. or when we need to examine a particular implementation. since in in complex t:ases our basic attributed intuition may fail. we often tum to our understanding of how the interpreter works. it is processor to do. or when dealing with temporal considerations and so forth). it is defined to perform certain operations in a systematic manner depending on the fonn of the expression under "interpretation". Typically. can be applied to arguments. the processor itself doesn't have any access sign~ficance. it is only when it fails (as with side effects. rather. however. The reason is that the underlying intuition of function application. Function application is not a concept built up out of notions of formal "symbol" nlanipulation. not the mathematical function signified. Like all semantical attribution. It is the expression. although. roughly sumJnarisable performs a depth-first as follows: a' single-locus active agent - recursive tree-walk down "expressions".2. when tIle name of a "user-defined function" is encountered . For example. when we get to details. using non-primitive names that it encounters as standing in place of procedure definitions or values. like the primitive ones. that we make recourse to a tntly computational account In sum.cognised names arc found at the leaves of the resulting tree. that drives the interpretation process.

we will show how A-abstraction and recursion can be used to generate more complex procedures (like the (LAMBDA (X) (+ Xl» of our example). will organise our presentation of each of the LISPS. but a . tile primitive oncs. in terms of derivability (1-). our current task is merely to make manifest the primary fact that we understand LISP programs semantically.d machinery to make the distinction precise. Two additional distinctions. As we introduce and explain each of our LISP dialects. rather than on data structures. rather. Rather. The arguments for double semantics. methods of composition enabling the user to construct complex structures and behaviours out of simpler ones. to be examined chapter 3. The second is a three way distinction among the follo·Ning three kinds of facilities: primitive facilities provided by the basic calculus. that there are two natural kinds of attributed understanding. as well as formally. should not be confused with the more subst. we will discuss both the 1-LISP attributed kind of understanding and the Jonna! way in which the processor works. 1-lISP: A Basis Dialect Procedural Reflection 110 (like the INCREMENT of 52-a). of a very different kind from that between fonnal and attributed understanding.9 composite unities). and uses that expression «+ x in our example) to continue its tree walk (subject to certain modifications to its own internal state which we will environrneht modifications presently examine). and will just as in the case of show how a variety of naming conventions can be used to allow these cOlnplcx procedures to be invoked merely by using an atomic name (such as INCREMENT). however. The present claim that there are two different ways to explain 1-LISP. because we are not yet able to avail ourselves of the thcoretic.2.antive claim. and methods of abstraction than enable these composite constructions to be used and refered to as cohesive w1101es (mechanisms that make them. as mentioned above. it merely looks up the lambda expression associated with that name. the processor does not figure out what function is signified. in Maturana's phrase. and a clarification of the relationship between the fonnal LISP processor and these semantical treatments~ depend on the prior acceptance of the fact that computational systems are quintessentially semantical. 1). is not yet the phenomenon mentioned in chapter 1 requiring a double semantics. in other words. This double viewpoint. The first is the informal separation between programs and data structures - infonnal. in terms of entailment (t=). Our focus will be on programs. For example. as well as demonstrating a dozen simply named procedures provided primitively in 2-lISP. much in the way in which we understand logical deductions systems semantically.

however. There is a temptation to view pairs as cOlnposite objects. fonnally defined. These two mutable relationships arc the only mutable aspects of the field - . numeralE (also atomic. cannot associate a differellt list with an atom. again in the same way that primitive data types are utilised as if they were indivisible wholes. and you can and CDR without changing the pair). standing in some specified set of relationships with one a locality metric is defined. All three of these relationships are tolal functions: each and every pair has exactly one CAR and one CDR. With these preparatory remarks. show how arrangements of these primitive structures can be welded together into complex composite structures.the property-list relationship (which holds between an atom and an instance of the derived category of list. and .2. and each and every atom has one property list.review. as can the relationship The third (the property-list relationship). in tile sense can be changed. over which To . sil1ce the identity of the pair is not itself a function of the identity of \vhat would be called its constituents (distinguishable pairs can have the same change both CAR CAR and the same CDR. which we will define below). signifying nUlnbers). CAR Two of the three first-order relationships (the that the relationship between a pair and its between a pair and its CDR. 1-LISP: A Basis Dialect Procedural Reflection 111 parallel development for data structures is possible: we can demonstrate the primitive data structures. another. CAR and CDR) are 171utable. and show how naming conventions can be used so that these data abstractions can be treated as functional units. In the sense sketched in section I. and pairs.e. to specify a computational calculus is to specify a process functionally analysed in tenns of a structural field and the surface behaviour of an interpretive process defined over that field. is fixed: one there is no other v/ay in which the field can be changed. a structural field is a set of abstract objects. There are three first- order relationships defined on this field: the CAR-relations/rip and the CDR-relatiollShip (each of which holds between a pair and an arbitrary s-expression). S-expressions are of three disjoint kinds: atoms (atomic elements typically used as names or identifiers). and with respect to which a set of mutability constraints are specified. A I-LISP system consists of a structural field of s-expressions and a (behaviourally defined) i-LISP processor (our terminology for what is always called the 1-LISP interpreter). there remains only the task of characterising the LISP 1- field. but that is strictly false.

y constraints either. in defining the surface of the interpretation process. which at the present happens to be English.. and from an atonl its property list is locally accessible. EVAl~ APPLY.. which consists of these objects and of the three relationships (with appropriate constraints on mutability and locality). CONS. DEFINE. in virtue of the interaction of the I-LISP processor. 1:Jecause to do so would associate a notation with the structural iield elements.:ducc labels for them in the notation. NUMBERP. to specify as atomic operations only those that obey these locality consideration~. and the mutability properties. numerals. . and pairs) is and in there is no way in which elements can be added or removed (we will deal with CONS tenns of accessibility. since strings arc not (in the present account) a primitively supported data type. I-LISP has no individual-specific relationships at all. LAMBDA. we will not make those labels (often known as p-nanles for "print names") themselves elclnents of the st"!uctural field. called CAR. CDR. but no one of these relationships is local in the opposite direction. WIll I-lISP field. In addition. Locality is always defined over relationships (not objects). all of which would be misleading.Le. These names are for the present simply names we will use to identify them in the text . READ. is subject to change over the course of the computation. however. PRINT. and therefore no individual·specific localit. It T. I-LISP: A Basis Dialect Procedural Reflection COIlstaIlt. each of the category-specific locality metries is assymetric: from a pair both its CAR and CDR are locally accessible. names in our theoretical metalanguage. if we were presenting a complete characterisation of !lolation. after identifying the objects and relationships. We cannot (and need not) present a lexical grammar for this field stnlcture. +. and imply The foregoing describes only what we call "the CQtegory strnctu:e of the SOine structure for pairs to indicate their parts. the individual structure is as follows: there are twenty-one distinguished. of which in I-LISP we have identified three binary first-order types. which greatly simplifies the analysis. QUOTE. The field as a whole. -. and NIL. is to identify the salient locality constraints. I-LISP we would define them as part of the token structure of I-LISP Even when we intr. EQ. ATOM. The third requirement on specifying a field.2. COND. . not actual creation). SET. 112 Thus the set of structural field objects (the atoms. We will be restricted. (and of course distinct) atoms.

since two pairs could have the same elements.2. Thus all the I-LISP atoms taken together are the extension of the tl}is category. There is no immediate notion of type and token in the 1-LISP field.. Wf: do not have a notion of an th. we parenthetical fragment of this sentence). and thus a simple numerical ordering would be insufficiently structured. they would in general be identical to a different. of which the set is the extension. were of the same type. . although these notions will impinge on the discussion of notation below (and we will shortly define a derived notion of type over pairs. all the I-LISP pairs. over which it is meaningless to speak of an occurrence or token. constituted of two "ingredients": their CAR and their CDR (a temptation fe-infocced by the fact that procedural On the face of it. However in the case of pairs (as opposed to atoms and numerals) there is a temptation to define a different notion of type or category. and of instances of that type (such as one in the previous in other words. One would have to define the degree . .~ atom type. as an extension). as those terms are used in theories of language. I-LISP: A Basis Dialect Procedural Reflection 113 By the category"/individual distinction we refer implicitly on the one hand to sets of entities taken as a whole.are distinct individuals.individual atom of I-liSP The category atom is a theoretical abstraction. However even this suggestion would need further complication: even if a pair's CAR and COR were type- identical. Similarly. but rather to a concept in our theory of 1-LISP. because of the natural tendency. part not of the structural field but of the theory of I-LISP we are adopting to describe that field rtis distinction between the concepts of category and individual is different from that bt:tween the notions of type and token. and on the other iJand to their individual elements. We could define a hierarctlY of "type-ness" In which distinct pairs whose elClnents were typeidentical of some degree wouid in turn be type-identical of greater degree.At refer simply to a single atom: there is no sense to be made of such terminology as an all of the elements of the extension of the category pair . However we use the term "category" to refer not to a set of entities. or could have elements that. of type-identity of two pairs to be the ordered pair of type-identity of their CARS and CDRS. the way that we otlen speak of a word type (such as the type o"erry). to think of pairs as approximately composite objects. of which there are many tokens. mentioned above. intuition could lead to a whale range of degrees of type-identity. recursively. Cdtegory atom. each particular I-liSP atom is an . this naive consequence is most naturally defined over such types). -If we speak of some atom occu"ence of that atom. In other words. degree.

if their (recursively) type-identical. This definition will play a roje in the definition of type-identical lists in the following section. is that it leaves undefined the question of whether certain CAR circular structures are type-identical. which maintains tile intuition that distinct leaves indicate distinct types: All objects are type-identical with themselves. Distinct pairs are type-identical if and only. In particular. (52-9) CARS and CDRS are A problem with 52-9. No other distin~t s-expressions are type-identical. However there is a coarser variety of type-identity on pairs that is useful in characterising the t-LISP procedural component: a notion that is approximately embodied in the standard definition of a IISP identity predicate called EQUAL (in contrast with EQ the primitive identity predicate over objects in the field). the second clause in is ill-defined where each of two distinct pairs P1 and p 2 is its own CAR and (many other simple examples are possible). not a tree. 3. It is slightly coarser in grain than o~e might at first suspect. so as to distinguish the exa1l1ple just given.3 are typeidentical: 1.2. 1-LISP: A Basis Dialect Procedural Reflection 114 We will not pursue this fine-grained measure of type-equivalence. Revisions of 52 -10 are possible that establish finer-grained equivalence classes of structures. 4. however. No atom or numeral is type-identical with allY object other than itself. A better characterisation is the following (by type-distinct we mean not lype-identica1). we will rClnark explicitly when we arc using the telm "type" with respect to structural field . In spite of this definition of a structural (as opposed to a nota/iollal) notion of type. The intuition on which it is based is to say of two pairs that they are type identical just in case the non-pair lenninals in the tree formed by a pair and ils elements are the Same. 3. 1. However 52-10 will serve our purposes. (52-10) 2. in that it sets the PI of the previous paragraph as type-identical with a structure consisting of two dinstinct pairs P3 and p4' each of which is the otller's CAR and CDR. Any two pairs which are lIot shown to be type-distinct by rules 1 . The" problem is that a"the definition CDR 52-9 and CUR relationship on any given pair may yield an arbitrary graph. This intuiton suggests the folowing recursive definition of the notion type over structural field elements: All objects are type-idenfical with themselves: 2. Two pairs are type-distillct if either their CARS or their CDRs are type-distinct.

or a pair whose CDR is a list (52-11) The' ~ of a list L is said to be 0 if L is NIL. its primary meaning will remain a notion defined over lexical notations. There are two problems with 52-11 which need attent. atom. An obviollS way to revise the definition would be to define a list to be an abstract sequence of pairs. although the definition as given does not elem~nts. First. or else 1 greater than the length of its cdr. there is a derived notion of list . rather than pairs. nothing excludes a list from being one of its own just as a pair can be its own CAR. the distinguished atom NIL. and pair. for example. I-LISP: A Basis Dialect Procedural Reflection lIS objects. on this account a list is not a composite object containing its elements. since the list is identified with a single "head" pair.2. A list has as many elements as its length: we will say that its first element is its CAR. As well as the primitive notions of numeral. are by far the more commonly used structural abstraction. I~ follows that on this view one could change an element of a list without changing the list itself. CAR of some . which by our prior account of identity and mutability is not thereby changed. lbird.ion. and its Nth element is the <N-l>th element of the list that is its CDR. each of which was the CDR of the previous pair: in this way if one changed some element of a list (c]langed the CAR-relationship of one of the pClirs in the chain) one would on the theoretical account have a different list (we can't absorb the notion of change directly in a mathematical account. since mathematical entities are not subject to modification). unless "containing" is defined to include the transitive closure of the CDR relationship. admit lists of infinite length. 11tis is a mildly unhappy terminological consequence. Second. but not all pairs are lists.over which procedural consequence is most naturally defined. In actual use lists. First.'er arguing against this revision is the consequence that a list would then no longer be an element of the structural field: a list could not. numerals. A simple notion of a list can be inductively defined as follows: a list is either: 1. or lists: they may be non-list pairs. A number of properties of lists follows from this characterisation. it is not necessary that the elements of a list be atoms.. be the other pair. 2. there is a non-isomorphism between pairs and lists: al11ists but one (the empty list NIL) are pairs. Howe'.

No other atom or llumeral is a list: 3. even though this is virtually the only implementation widely utilised (although others . we will simply posit that the length of the list is infinite. Thus two sorts of stnlctural arrangelnents might be lists of infinite length: those consisting of an infinite number of pairs. the definition of lype"idelllical 52-10 applies directly to lists. the solution is to explicitly exclude all non-lists. If the CDR of a pair is not a list. All other pairs are lists. there is a natural sense in which some of them can be distinguished. it seems to lead field in ways that our present conceptual vocabulary is not to the awkward use of prior tenninology. (52-12) The definition of length given above can be retained for finite lists. As was the case with type-identical pairs. this trouble can be accomodated in a revj~ed definition. if the transitive closure of the CDR relationship of a list pair docs not tcnninate with NIL in a finite numLer of steps. Since we have continued to identify lists with pairs. and then to define the lists to be the complement of this set This approach can be effected as follows: The atom NIL is a list: 2.particularly ones with different temporal properties seems to take us out of the LISP are occasionally explored). with the consequence that all infinite-length lists with the same elements are type-identical. until that time we will accept the identification of a list with its head pair (or NIL). as mentioned above. On the other hand. suppose tllat pair . is the fact that lists are in essence an abstract data structure implemented as chains of pairs in the I-LISP field. For example. At the end of chapter 3 we will examine data abstraction explicitly. we would prefer to define a list as CDR'S either NIL or as a pair wllose transitive closure of included no numerals or atoms (other than NIL). characterising them abstractly equipped to handle. and those comprising a finite number of pairs where one of those pairs is the a pair in the transitive closure of its own given in CDR CDR of relationship (such as the P1 mentioned earlier). 1. of course. since that introduces fewer formal difficulties. As opposed to the foregoing difficulty. The other problem with 52-11 is that it excludes certain arrangements of pairs that we will want to consider circular lists. I-liSP: A Basis Dialect Procedural Reflection 116 What we are up against. Infonnally. the pair is not a Jist: 4. Furthennore.2. Characterising them in terms of their implementation is too detailed to be aestheticly satisfactory. even though.

This completes the account of I-LISP'S structural field. in part because the lexical notation is a more natural notation for lists than for arbitary pairs.2. and . In addition. Thus no notion of pointer will intrude on our discussion. atoms are used in I-LISP programs as identifiers and variables. it is po~sible to adopt a finer-grained type-identicality predicate to distinguish such cases. It is with. is part of the state of the processor. since we are dealing only with a behavioural specification of interpretive consequence. nor will the creation of atoms. We have of course dealt with it purely as an abstract collection of formal structure: neither notation. From these definitions it follows that a number of typically-available features are missing in I-LISP. This association. In addition. however. etc. and that pairs P2 and p3 each have the atom as their CAR and are each other's CDR. as we will describe in subsequent sections. or garbage collection. 1-LISP: A Basis Dialect Procedural Reflection 117 P1 A has the atom A as its CAR and is its own CDR. such any access to all atoms (the LISP oblist). this notion of list will serve. As we mentioned above. nor semantical import have yet been mentioned (and thus we are not yet in a position to raise any semantical queries). we have so far discussed primarily categorical structure: the only individual to play a role in describing distinguished atom NIL. procedural consequence. In addition. these structures would be notated as follows: Pl~ P2 P3 (52-13) ~ On the account we have adopted PI and P2' though distinct. and an association between them and their values (which are always clements of the field) is maintained. Using the graphical notation to be introduced in the next section. and not to pairs. however. ~"f)ed l-L ISP'S field is the field makes to define the derived notion of a list. are type-identical (and both are type-identical to P3)' and are of equal (infinite) length. that many aspects of both interpretive consequence and declarative import will be defined. we are I-LISP accepting the notion of an abstract virtual machine: the definition of the no comment on how I-LISP is implemented. As we have time and again remarked. reference to lists. such categorical ambiguity will make it very difficult to align the double semantical accounts we will in the end adopt For present purposes. but we will not need to do that here. as we will sh<?w in the next section.

ATOMS. thus any given state of the field is modelled as an element of stales of tile FIELDS. But the locality considerations outlined above will remain the same for the categories that are preserved. In 2. and NUMERALS of pairs. we will introduce two separate boolean constants that are not atoms. However all these modifications will be defined as changes with respect to this I-LISP field. and we will deal with quoted foons specially. The reason is that we define CARS to be the full set of CAR relationships. the set FIELDS is a set of fields. CDR. intended to include all possible I-LISP field. PROP. The basic character of the I-LISP structural field just outlined will be mainly pre~rved in subsequent dialects - atoms. The notational interpretation function 9 G (see chapter 3) will be modified. for example. and three relationships to model CAR. will receive the asymmetric accessibility relations of lists). intended to model changing CAR relationship. not a manifest aspect of the structural field.2. and In the earlier discussion we said that the First. nor will we store atom values under a "value" property of an atom's property list When we design 3-LISP we will have to have environment designators (structures that designate such assocations) available as full-fledged structural objects. in particular. This approach is an instance of a standard meta-theoretical manoeuvre to compensate for the fact that change cannot be absorbed into mathematics. numerals. I-LISP: A Basis Dialect as such is not encoded within the field itself: Procedural Reflection 118 Thus we have not identified a "value" mapping over the atoms. and numerals. and similar metries will be introduced on the new types (rails. and so forth. atoms. but until that time the information about atoms and their values is considered to remain a part of the internal state of the processor. and of course both declarative and procedural semantics will be adjusted. PROP to pairs. will remain unchanged. we define three sets relationship took atoms PAIRS. and pairs.and 3-LISP we will introduce a primitive syntactic type called a rail to serve in place of l-LISP·S derived notion of list. characteristics that are not again mentioned should be assumed to carry through intact We can model the I-LISP structural field as follows. PAIRS ATONS _ _ {p {A {N NUMERALS = I p is a pair } I A is an atom} I N is a numeral} - - the set ufpairs the set ofatoms the set of numerals (52-14) . Note as well that whereas s is a fixed set. but here we have corrected that so that it maps atoms onto lists.

. AI' A2. it can merely be modelled. There are some identity LISP inter~ctions between our English characterisations of the 1- field and these mathematical constructs.. at any operation. 51' 52' S'. 5... I-LISP: A Basis Dialect Procedural Reflection the structural field elements the "property-list" relationship the "CAR" relationship the "CDR" relationship the set ofstructural fields 119 s PROPS CARS CDRS e e a PAIRS U ATONS U IIU11ERALS CATOllS CPAIRS = a LISTS 1 S1 {PAIRS .. one of the questions that an account of such a mapping would have to answer is that of how objcct identity in the source domain is modelled in the target model. With respect to these definitions we can define the set LISTS of lists (given a field). Modelling is itself a scmantical of course not actually an ordered pair of sets and functions. etc. and yield that corresponding element of s in that field: : CL" F x PAIRS 1 a Af. range over ATOMS. since no po~sible mathematical entity can change. OUf first attempt. '. and PROP. S1 -+ -+ FIELDS S X PROPS X CARS X CDRS Furtherntore. and yet another intepretation function relates the domain being modelled with the model.. A. etc.AP • f'(P) . both for expl)jcit quantification and for lambda abstraction. in our mathematics. we will define three meta-theoretic functions CAR. range avet all elements of S.. S1 (52-16) CDR : CC F X PAIRS 1 -+ a AF . we will describe the state of the field with a new elements of FIELDS... in which lists were those pairs whose CDR'S were lists . A'. with such a mathelnatical abstraction.AA • F2 (A) (52-17) We will let variables P. etc. PI' P2' P'. each individual state is modelled with an element of that set In the mathematical characterisation of all operation (like RPlACA) that changes the field.. we model each change with a new mathematical object Thus the set FIELDS models the set of all states of a field. range over PAIRS..2. and so forth.AP • f4(p) s1 (S2-16) PROP == : CC F X ArONS 1 -+ LISTS 1 AF . deriving from the fact that a structural field is given moment. CDR. as suggested earlier. We have spoken of the 1-LISP field changing from time to time. that take an element of CAR s and a field.

definition we settled on. 1£ Vi 1 S 1 S k [ COR(S1' F)=St+1] A [[ CDR( Sit' F) = NIL] V [~DR( Sit' F) = 51' 1 S 1 S k ]]]} As mentioned in the discussion. S € S if [s E ATOMS V S else (52-22) E NUMERALS] then S ArOnS U NUNERALS U {s} .F» III However this is too computational an attempt to avoid infinite regress. The second suggestion. F) E LlSTS( F)} ] (52-18) This characterisation.-12.2. to identify those structures to which it is type-distinct.CAR(S2.CDR(S2. however..F). including the fact that it removed lists from the structural field. FALSE} 1 AF E FIELDS.{NIL} (52-20) U {p E PAIRS CDR(P. We can also define the type-identity predicate outlined in is: TYPE-EQUAL : A first suggestion == S x 5J -to {TRUE.F»] V [TYPE-EQUAl(F.F) E NON-LISTS(F)}] I LISTS AF E FIELDS [s - NON-LISTS( F) ] 52-10. The can be math:matical1y modelled as follows: == - AF E FIELDS [ArONS U NUMERALS . sequences of their elements. for each element. sketched in NON-LISTS 52. this too had a number of unacceptable consequences. in which we identified lists with. I-LISP: A Basis Dialect NIL Procedural Reflection 120 or the atom LISTS would be recursively defined as follows: == AF E FIELDS [{NIL} U {p € PAIRS I COR( p.CDR(Sl.CAR(Sl. as we noted. 51' S2 € S [if [51 = 52) elF x (52-21) then TRUE else1f [[ 51 f. and is undefined on just those cases we took pains to include: circular structures. s·1 == Af € FIELDS. was unacceptable in ignoring non-tree lists.F). PAIRS] V [52 (£ PAIRS]] then FALSE else[[TYPE-EQUAL(F. would be modelled as follows: LISTS a AF € FIELDS (52-19) Sit) [{<>} U {<51 52 .. and thell to define typeidentity with reference to this set: OI5TINCTS : CC F X S 1 -. A better approach is.

We will talk more simply and informally in tenns of the particular structural fields we will define. rather than the three primary binary relationships. A general defillition of a structural field . This characterisation will be of some use in subsequent proofs. In addition there are a handful of distinguished nodes. 51' 52 E S (52-24) [TYPE-EQUAL(F.St. numeral. but such general goals are not our present task.F»} U € DISTINCTS(F.S2) a TYPE-EQUAl(F. FALSE}} S2 [51 ( DISTINCTS{ F .2.S2. However we also have defined a locality or accessibility relationship over the elements (nodes) of s.F»} CC F == AS 1 . and property-list). consisting of three node types (atom. since the accessibility relationship must correspond topologically to a subset of the primary relationships.CAR{S. but it is a different arc from the other three .F) I CAR(P. If FIELDS were defined to be a graph of the first sort. X S x 1 -+ {TRUE.it is different in kind.52) ] s (52-23) From this definition the appropriate symmetry relationship can be proved: VF € FIELDS.cQuld be found in this direction. with the accessibility relationship as the directed arc. CDR.Sl)] It is clear that the structural field as defined is approximately a graph. with certain restrictions on the types of arcs.F) E DISTINCTS(F. which fonns a ditTerent but related graph: the accessibility relationship is a directed arc between nodes as well. rather than being a fourth variety. Of course FIELDS· would be highly dependend on FIELDS.CDR(S. and pair) and three asymmetric labelled arcs (CAR. then one could define a related graph FIELDS· consisting of the same nodes. . I-lISP: A Basis Dialect {p E PAIRS {p € PAIRS TYPE-EQUAL: Procedural Reflection 121 I CDR(P.

with the hope of clarifying A general introduction to our the assumptions and principles that underlie its design. as follows (here cI. we said that we would prove the following evaluation tlzeoreln for I-LISP (and therefore by implication for all standard c) ( LISPS. intended to cover the general computational circumstance. Semantic Rationalisation Our next task is to subject I-LISP to semantical scrutiny. computed by L. as we will show in tltis .'te language processor. and 'I' is the function fonnally Notation Nt Notation N2 e a With respect to this diagram.is the interpretation function from syntactic domain s to semantic domain D): I Syntactic Domain S I~ c)_ _ * Semantic Domain D I (S3-1. First. we said that in general we take a semantica! interpretation function to relate elements of a syntactic domain . (53-2) tit is the interpretation function making explicit our attributed semantics to stnlctural field elements. we will repeat here for reference four diagrams that summarise our main terminology. and so forth.. approach was given in section l. ) We then presented the following more complex version of this diagram. including SCHEME): (53-3) v5 E S [ 1f [~( S) € S] the n ['I' ( S) = else [cfJ('I'(S» S) ] = ~(S)]] In contrast.d.3.·ith corresponding elements of a semantic domain. where e is the interpretation function mapping notations into eleinents of the structural field. Semantic Rationalisation Procedural Reflection 122 Chapter 3. we are committed to the construction of a dialect satisfying the following equation (the nonna/isation property) much more similar to the procedural regimens defined over classical calculi (logic. the A-calculus.

of our basis dialect.3. turnh~g then to a consideration i-LISP of semantics in a computational setting. and then taking up the task of setting out a full account of the semantics. Semantic Rationalisation chapter): Procedural Reflection 123 vs € S [[ «la(S) = 4'(i'{S»] A NORMAL-FORM('I'(S})] (53-4) The procedural regime that it describes can be pictured as follows: Donnal fonn ~ (S3-6) In this present chapter we will investigate these semantical issues in detail. . beginning with an analysis of the semantical analysis of traditional systems. both declarative and procedural.

Thus we might say that the letter Q. If the conclusion (which we may call v) selllantical/y follows fronl the Y assumptions (x). To say that it is complete is to say that if x t= Y.and this is the point .Y. then x I. that in all cases the sentence that it yields will be true in those cases in which the sentences it uses are true. The Semantics of Traditional Formal Systems Diagram 53-2 is sufficiently general that we can characterise a variety of traditional fonnal systems in its teons. i. one lays out assumptions about the denotational import of the various predicate letters and terms. and so on.Y only if x t= Y. would yield Q. which is to say. beginning with logic and standard raodel theory.Q. To obey what are called inference rules that state which transformations are legal. Only after one has established consistency and cOlnpletcncss (possible only in some languages. in all extensional sense: .3.by the predicate letter Q is true P of the object designated by the term x. Logic When formalising the (declarative) semantics of.. that sentences of the fonn Truth. and of course proved impossible for all logics with the power of arithmetic) can one treat the entailtnen t relationship "F" and the derivability relationship "f-" as equivalent. we write x 1= v. Similarly we might add that sentences P A Q are true just in case p p is true and Q is true. typically . to be Fregean) just in case the of the form ::J Q are true (designate P designated . Such an inferential regime is defined to Modus pOllens. and s designate one-place predicates.Y. say. and then identifies (usually making use of the recursive compositionatity of the grammar) the semantical import of composite expressions as a function of the ingredients. Crucially.a.not with reference to the sematical weight they are taken to bear. . R. for example. Semantic Rationalisation Procedural Reflection 124 3. the inference rules are defined over the Jorm of the expressions involved .is that this inference rule is sound. B. is 8 rule that. What one then attempts to prove. a first-order language. and c designate objects' in the domain. and so forth. if the inference regime will produce given x we write x say of an inference regime that it is sound is to say tllat x I. the atomic tenns P(X) pr~dicate A. Independent of this scmantical account one defines an inferential regime that maps sentences or sets of sentences onto other sentences. given sentences P and P :J Q. that sentences of the form are true just in case is false or is true. 3.

is that it be definable purely in terms of 51. Being scmantical.we have reviewed it to set our understanding of LISP up against it for COmlJarison. 30). like derivability (.. and cI» alone. this is the standard \vay in which entailment is defined.3.). just in \IX is true in all models in which ::J DAYS-IN(X. The first is the relationship between symbols and their (lcsignations (analogous to what we will call «p). in other words. By~' (what in the philosophy of language is catled a satisfaction relationship) we refer to a relationship between sentences and models in which that sentence is true. 111c satisfaction relationship til. All this is of course well-known . Sentences 51 Sentence 52 (53-6) Entailment (t=) is not a relationship between models.. derivability fundamentally formal. 30) ] 52 51 is true. t= in a sense "reaches daVin t through the semantics" of the sentences involved. In particular it is crucial to t realise that entailment is fundamentally semantical.. the definition of 1= must not rest on the definition of 1-. if 51 is the sentence [ MONTH(X) A [ MONTH(FEBRUARY) ] and 52 is the 51 sentence DAYS- IN(FEBRUARY. and the derivability relationship 1-. These few points are illustrated in the following diagram. . the second is a formally-definable relationship between expressions (. must be independently definable. however. then is entailed by because in all models in which Febnlary is a month and all months have 30 days.-) it is a relationship betwen sentences.is a purely fornlal 52. Semantic Rationalisation Procedural Reflection 125 J- they relate the same sentences. it is in fact exactly because they are different that it is powerful to show that they arc extensionally the same. What is crucial about t= In contrast t. February is of 30 days duration as well. or on any of the machinery defined to implement it. They are of course different in meaning: saying that 51 52 is different from saying that 51 t== 52. Thus S1 F= 52 just in case lfl' (S 1) C 41' (52) case 52 that is. the third is a sCtnantical relationship between sentences (1=) that depends on their designations. With respect to such a comparison the following points are relevant: there are lhree relationships of interest mentioned in the preceding discussion. relationship that h:>lds between sentences solely in virtue of their grammatical strllcture.. For example.

53-2 is not simply The the type of N). at least for languages like LISP perfused with pre-computational semantical attribution. have tIle following equation saying that two expressions are the saine (i. to be precise. they are not [unctions: from any given sentence or set of sentences there are an infinite number of other sentences that can be derived. and entailm~nt relationships between the other elements of the figure. we do not have a situation in which. which says that two sets of expressions are the same: 'IS [{ x I 5 a X} = {X I s 'It X} ] (S3-8) . Two further points are notable regarding logic's 'I' the derivability and entailment relationships. Our criticism of standard programming language semantics. we will of course have to define a more narrowly constrained 'If that is at least approximately a function.3. in a sound and complete logic one instead proves the following. First. Semantic Rationalisation The proof of correctness of the fonnal relationship not co"ectly mimic tit. tit is necessary in order to define but 4' is not itself F. entailment takes it to a particular sentence. logic's ~. and derivability takes it to a particular sentence. and t11en the proofs of soundness and completeness show that this is the same sentence. to put this more formally. False for logic (S3-7) Instead. will be that the LISP analogues of ell and F= are unhelpfully conflated. the following equation is semantically ill-fonned. there is no distinction made between notation and abstract structure. Since entailment is not a function. We do not. however are these: satisfaction is (1=) is logic's and n - o. the entailment relationship is defined witllOUt reference to the derivability relationship. not with respect to an abstract structure or field into which sentences are Thus the Nt and 51 of figure 53-2 are coalesced into 51 in 53-6. the inference rules and the semantics arc defined with respect to sentences (sentence types. because 0 and '1' are not functions): . In our deterministic cOlnputational fonnalisms. as mentioned above. there are all infinite number of other sentences that are entailed. The comparison between 53-6 and 53-2 is clear: in logic. derivability (f-) is logic's it. Procedural Reflection 126 f- is that it correctly mimics 1=. but s in translated. for any given sentence. I. however. in contrast. Second.e.does 1=.

a. p. {J-reduct1on .X l. The A-calculus's '1'.3.x }. « A'[. ( AZ .and p-reduction.YW» Z)] (AG. iii other words. In the A-calculus.ZW)] (i\G.if. is mapped by the standard interpretation function therefore. which is defined in the A-calculus as being an expression to which no further p-reduction rule applies. suppo~e we have the expression [AZ. The A-Calculus In the A-calculus. For example. (AG. G) (S3-10) Then by a series of reductions we would be given the following derivation: [AZ. (AZ.W . standard denotational methods arc used to describe possible models of A-calculus expressions.X}] I (53-9) S~-1 In designing 2- and 3-LISP we will i18ve the stronger equation as our goal. this latter equation can be rewritten as (in fact there are subtleties: the statement [ s t= y X == S r. Semantic Rationalisation Procedural Reflection 127 Using the Dlore familiar labels peculiar to logic. transitive closure of a- «lJ is the interpretation function. «AY.reduct ion The last line designates the identity function in the standard model. in other words. following sense: every expression 8 The reductio" regimes defined over such A expressions (a.will fail to attain a computable version of 0 tllat is a function.G) (S3-11) (AW. as in logic.x ] is stronger than [ 1== X a J. « AY. the last line is in nomzal [onn. YZ » Z)] ~ AG •G) [Al. In addition. is proved in the tile reduction of a lambda-calculus expression there may be more than one option of 110W . is tllat cl! onto the identity fUllction. up to aChurch-l~osscr interconvertability. Wllat is true. (AW. Vl» Z)] (AG. (AW. although we too will fail to reach it . That 'It is approxiJnately a fUllction. since neither reduction nor p-rcduction changes designation.reduct ion . for example if s is infinite implying that { x I S 1== X} may be larger tJlan { x I S I.G)W) AW. which is to say. 3. typically) arc then shown to be sound and cODlplete. a-reduction .G) [Al. but the intent is clear): \IS [{ X S 1= X} I :I {X S I. and 'I' is the theorem: although at any given stage in and p-rcduction. a- each of the lines of 53-11 designates the same functio!l. is always designation preserving. p. in the to which an expression reduces can be shown to have tile same designation as A.

(Certainly no see AX.prior to the definition of 'It. otller possibilities are sometimes chosen. Semantic Rationalisation to Procedural Reflection 128 apply an a or p reduction rule.at least up to the identification of category. In contrast. or one convertible to it via a-reductions alone. in addition. example. the A'1'. for the Acalculus: although in what we will call standard models each lambda tenn designates a function. but the perlneating character of the A-calculus's reduction scheme is that expressions are taken by co-designating expressions that are not further reducible. such as that some wed-fonned expressions do not reduce to a nonnal fonn. There arc subtleties. and partially in tenns of the fonn of the original designator (51 in 53-2): no reference will be allowed to the mechanisms . we will require of 2-lISP that the definition of n be complete .3. via any other path of reduction steps. if an expression s reduces to nonnal fonn via one path of reduction steps.) The A-calculus differs from logic in two important ways: there is a much stronger sense that its 'it IISP aflcianado can easily takes expressions towards a definite goal (a non-reducible term) than is tile if case in logic. in 53-2). for the class of all sentences of tile lambdaa- and p-reduction (it is thus immediate that and p- reduction are designation preserving: this is one of this tnoders great conveniences). Nonetllcless we will assume the standard model. d~ffercnt OUf notion of nonnal form. where A-tcnns designate standard (continuous) functions. select as tile designation of a term calculus interconvertible with E by a- v towards a E Various proofs of consistency. calculus's '1' is stronger than is logic's On the other hand. not independently to any salient degree. the A-calculus docs not have a particularly well-specified 0: the concept of normal-form is defined with respect to the lack of further applicability of the inferential protocols. will be from that used in the A--calculus: we will define normal-form primarily in tcrrns of the type of tlle referent (Dl. There are various options open in defining an interpretation function cz. throughout our discussion. but what is different is 'I' '*' and Sl (t- and 1=) arc equivalent in restrictiveness: in the A-calculus is much more finely specified than is the n that makes no reference to tile reduction scheme (it merely says that designation is preserved). up to typeequivalence . for all but function designators. where (I-) leads to an infinite set In a certain sense. it will reduce to that normal fonn expression. in other words. One could argue that this 0 is no weaker than logic's that in logic n (entailment). and. x as designating anything but the identity function. and equivalently 02.

Semantic Rationalisation that transfonn that original expression.3. It follows. context independent. to the notion of the same name used in the A-calculus. 4» for PROLOG. without modification. one can then prove that implements a subset of logic's t=. it is our sense. that is not based on computational considerations. in that tile procedural consequence and declarative import are signified by what amount to different languages super-imposed one upon the other. l as our flfSt example of a computational formalism. one does 'I' not prove that correctly elnbodies t=. standard notions of entailment (1=) are defined. We too will introduce some new tcnninology. logic is not a computational system. of which "normal fonn" is a good example. PROLOG it~ It is instnlctive to look next at PROLOG. is at heart a dual-calculus fonnalism. then. in other words. but we arc being informal for the PROLOG processor: this is Because it inlterits tb from logic. Every writer faces the question of whether familiar or new terms will best convey a new understanding.are preserved in our extended notion. 3. since also has a formally-defined relationship among PROLOG'S '1'. iii. since PROLOG is widely advertised as semantically strict.is a subset (Hom clauses) of the first order quantificational logic: the declarative interpretation function is then inherited from logic directly.the one over which declarative semantics is defined . however. we signify a concept related. as mentioned in the introduction. Since entailment is not a functioll. properly. rather. and derivative from logic. time being) computed by the PROLOG'S 'It PROLOG sentences (among processor and field states. PROLOG. for example.IJ 4» from first-order logic. we will make every effort to note explicitly any circumstance in which we use a traditional tenn with other than received meaning. particularly when the essence or fundamental insight on which the original notion was based seems also to lie at the heart our new idea. but not identical. however. The reader will note that we are defining for our own purposes a variety of traditional technical tenns. a. is PROLOG'S c. One of these languages .being stable under processing. the PROLOG designers have proved that 'I' . frequently adopting SOine mixture. that the essential qualities of a A-calculus normal form expression . and in some informal sense minimal . In aid of the reader. Procedural Reflection 129 A comment in passing. but will also stretch some familiar tenns to fit our circumstances. Thus by "nonnal form".

a. designers. like the will be able to ask whether a proposed affirmatively answered. and PROLOG) are three: . the evaluation of the definition of EVAL will yield behaviour equivalent to tha·t of direct evaluation. In contrast to LISP. in terms of an independently specified truth theory (rnodel theory for first logic). then my original question is rendered circular. By analogy. COU'lnl 0 lIalities structures. PROLOG is defined in tenns of a pre-computational characterisation of what its processor is trying to do: it is trying to maintain truth. But this is not a proof that evaluation is ilselfcorrect. we too.limited because it does not deal with what subset of entailment the processor computes. processor is correct (it embodies a subset of ~) something that cannot be done for LISP. or programs that designate This allows a proof that the the the LISP evaluator. in any sense.and 'I' are independently defined. Semantic Rationalisation Procedural Reflection 130 embodies a subset of I=. and so forth. before my question would make sense. Thus. can be PROLOG IISP processor is correct. or nleta-linguistic characterisations of evaluation. In Gordon. given a meta-theoretic definition of LISP LISP 1.3. For we have no prior notion of what LISP should do: we can tllercfore prove correct only implementations of IISP. 2 for example. TIle crucial facts that permeate the discussions of the foregoing three systems (logic.(by showing that 'I' implements a subset of a provably sound 1-). because there is no pre-computational intuition as to what LISP evaluation should be.iv. for and 3-LISP.6 LISP evaluation. If my reply was only that it is designed to manifest its own behaviour. 3. the A-calculus. In chapters 4 and 5 it witl 2-LISP be required of us to demonstrate that this question. we find a proof that the meta-circular definition of EVAL as given in manual is correct: by this is meant that. or about side effects and so forth PROLOG'S PROLOG it is meaningful to ask whether + is correct IISP After spelling out the declarative semantics naturally attributed to and sketching the architecture of a rationalised design. in this limited sense . Thus PROLOG has a cleanliness that PROLOG IISP lacks: cz. you would have to ask me what it was supposed to do. if I asked 'you whether a device that I built in my backyard was correct.

not seman tical weight 3. stated in the third point listed above. mapping expressions onto other expressions with the same designation (or. we Ilave noted that LISP systems are not traditionally analysed in this manner. 111is is the direct manifestation of the fact that logic. 11le procedural function 'It was related to the attributed semanticat interpretation function cit in a particular way: '" was ib-preserving. Points 1 and 2 establish that semantical weight and procedural treatment are independently specified. This is the bottom line of this entire sketch of semantics as traditionally construed. 2. Defining a nonnalising or simplifying dialect of LISP. It is only because of this independently attributed semantics that tile procedural protocols could be semantically characterised: if it were not for the prior existence of (1'. Semantic Rationalisation 1. It should by this point be evident that to define a nonnalising dialect presupposes what we are calling a double semantics: that the notion of nonnalisation and co-designation makes sense only when a declarative semantics is fonnulated prior to and independent of the procedural treatment. In contrast with such similarities among these three systems. We have pointed out that reduction in the A-calculus . Procedural Reflection 131 Scmantical import was attributed to the expressions or structures of each fonnalism prior to the definition of a procedural regime over those expressions or structures. the relationsllip i' would simply be any relationship at all. It is for this reason that laying out the natural declarative semantics of LISP is a prerequisite to defining LISP 2-lISP. One final comment deserves to be made regarding traditional procedural treatments. onto expression with more inclusive designations). the Acalculus. The procedural treatment was defined independently of the semantic attribution. In constrast with tradition. and PROLOG are lonnal systems: how things go is defined in terms of fonnal structure. TIluS no true scmantical analysis of evaluation is possible under tile standard analysis. in logic's case. treatment: the import of consequence (the COITlmOn Evaluation is the procedural LISP constructs is characterised in tcnns of the procedural LISP'S QUOTE wisdom that is an operator that defers one level of evaluation is a classic example). is not straightforward: it requires the explicit formulation of an entire theory of semantics for stnlclures that is prior to and independent of any account of how the IISP processor is to function. in other words. and n would not exist.3. \ve have said that 2-LISP'S and 3-LISP'S procedural regimes will be based on a Ilomlalising processor: that the '1' of those dialects wilt take structures into normal-form codesignators.

we will have to make reference to the designation of c)-preserving behaviour. however.levcl symbolic behaviour constitutes the vast majority of linguistic and fannal practice. about-ness must be faced if we are to construct a reflective architecture. subject matter: the shift into talking about our communication is a less natural. because the defining quality of reflection is that one's thoughts are about one's own thought processes. show that. It is not is so 'I' unnatural to ask. why 1 ~-prcscrvation common a semalltical trait of procedural regimcns. especially if OIlC is primarily familiar with LISP. There are two parts to this answer to this query. and our formal attempts to define the notion succeed just to the extent that they rationally reconstruct lay intuitions. designation cannot be defined in arbitrary ways precisely because of this point. Nothing in points independent or 2 above requires ~ that '1' bear this particular relationship to 4»: all that they require is that and be Furthermore. and considerably more problematic. aesthetic considerations merely imply that sOlne coherent relationship between the two be honoured: «I--prescrvation is presumably just one of any number of alternatives (that v and til be identical would be even simpler. is by far the most natural kind. In addition.. tllut there is no great temptation to define the three systems we have just considered in any other way. however.defincd notion of designation is intended to capture. OUf concern Wittl it. on the standard interpretation. constant. not other expressions. A-calculus expressions designate infinite functions. the programs that 3-lISP TI1US in order to terms. in other words. As we have constantly said.. primarily. We communicate. Level crossing behaviours of all kinds . First. for example).L~ worl~ rather than about other language. as this dissertation is of course at pains to make clear. since anything otlter than c)-preservation would be impossible. For example. and it is straightforward that artificial formal systems should be defined in this way. Semantic Rationalisation Procedural Reflection 132 and derivability and proof procedures in logical systems are fIJ·preserving. So too are mathematical simplification rules over algebraic and arithmetic expressions. a valid and coherent subject matter of independent interest. must not mislead us into thinking that anything other than shnplc. Secondly. and there is simply no possibility of . It must be admitted in addition. when it reflects. "about-ness" is exactly what the formally. matter than simple linguistic behaviour that "stays at a given semantical level".from simple use/mention shifts to full reflection is. runs arc about its own operations and 3-LISP stnlctures.3. the great bulk of language speaks about the about SOIT.

as is indicated in 53-3 above. and the like . macros. It is our mandate to admit and welcome these meta-structural We adopt this mandate in part because of our recognition that into a system. which are themselves syntactic. e"plicit level-crossing and reflective behaviours are by far and away most easily introduced into a system that by default preserves designation - default remains semantically pat. . we will say. It is the introduction of such tenns - semantic domain . when we concentrate on that portion of the structural field embedded in programs. we deal almost exclusively with tenns whose referents arc other syntactic LISP'S expressions.that has apparently led to a temptation on the part of the fonnalism designers to make the formally defined expression processor (v) dc-reference those expressions for which de-referencing is possible (remains with the syntactic domain 5). however. that by levels of designation. designators deal with data structures.3. In programming languages.those deal with tenns whose referents are other pieces of program But virtually all tcnns in programs other than function and mathematical and the concomitant embedding of the syntactic domain within the structure. Semantic Rationalisation Procedural Reflection 133 having the syntactic transformation function be a de-referencing function. while preserving the basic co-designation processing that characterises these simpler systems. This is not merely the case with such complex facilities as FEXPRS.

that a mat11ematical account of the semantics of a programming language can provide a rigorous test of how well that language is understood. and we do not want to argue with what traditional semantical treatments formalise. can provide a basis on which proofs about the properties of programs may be constructed. is not so. since the differences between standard denotational semantics and the semantics we will ultimately adopt are crucially important. i.b. for example. It is suggested. lbis analysis vlill be undertaken with some care. and arguing for the increased clarity of a rationalised dialect. especially in what is so widely taken to be a purely procedural formalism. To show this.a we applied the terms of diagram 53-2 to traditional systems. we will argue. and so forth. we are concerned with a rather different matter: it is our claim that what arises from our attribution of declarative semantics to its structures - LISP. But this. and will look instead at what traditional programming language semantics is concerned with. In our study of the semantics of however. The Semantics ofComputational Calculi Showing that the evaluation theorem holds for I-LISP. where by "meaning" is implied a general account of the total role that they playas ingredients in a functioning system. but nonetheless rather subtle. Semantic Rationalisation Procedural Reflection 134 3. once the interpretation functions tit and 'I' have been made clear for LISP'S circumstances. Standard Progralllming Language Semantics Discussions that defend the utility of formal semantical treatments of programming languages typically cite a number of benefits of this kind of analysis. we will for a moment set that diagram aside. may enable theorists to prove that implementations of it are correct. we next need to examine their applicability to computational calculi in general. It is convincingly argued that only a clear scmantical fOffiluJation can render explicit \¥hat the formal structures in a computational system are intended to mean. 'Ibcrc can be no quarrel with intellectual hygiene. In section 3.3. It might seem that programming language semantics would provide the formulation of ~ and/or 'I' in the computational case. LISP is that the . 3. of which intcltectual hygiene is often an underlying theme. The difficult task is to demonstrate the coherence of defining these two functions independently. are straightforward tasks. b.

We arc attempting. in the sense that very little attention is paid to the question of the relationship between symbols and the external world in which the processes are embedded.. Similarly. to make explicit not only what computational structures "meall". In order to make clear how our approach will differ from this tradition. between what is designated and what is returned is not ntaintained: the entire analysis is carried out in a mathetnatical domain where ttlose two entities are typically identified. computations.. for example. although it penncates those fonnulated in what is called the dellotational style. and because it is accepted as tile standard designator of that abstract truth value. We are trying to get hold of and explicate the understanding that led to the definitions that would be characterised in a semantics of the standard variety. it is well to make some comments on the received understanding of "semantics" in the computational community. but why they are intended to mean what they mean. As the tClm is typically used. in the sense of articulating their complete behavioural or computational consequence. We will not be satisfied. in other words.3. that the programmer is expected to attribute to the LISP structures and programs he or she writes. the setnantics of an expression refers to the l~hus cOlnplcte computational consequences that the expression will have for arbitrary computer science is by and large bchaviourist and solipsistic. in such a way that what a structure is taken to designate is lost in a much larger account of the complete effects a structure may have on the course of an arbitrary computation. and because allY expression that designates a truth value evaluates to the standard designator of that true value. Thus the main scmantical . This prior attribution is not explicitly reconstructed in typical semantical accounts. the difference. 11owever. processor. with a crystal clear statement that the atom things as that NIL NIL evaluates to itself in all environments with no side effects: we \vant to be able to say such evaluates to itself because it is taken to designate falsity in all contexts. All side effects to environment. field. which is far too broad and inclusive a notion to satisfy our particular requirements. . what we will call the designation of symbols is mixed in with a total account of their computational significance. are manifested in the single notion of denotation. represents an attempt to embed in a formal system a variety of intuitions and understandings about symbols and functions already possessed by the typical programmer. Even there. Semantic Rationalisation PrL-:~dural Reflection 135 programrrling language. as it has been fomlalised. even in an applicativc language like LISP. and so forth.

which must be brougllt out. certainly not mine. which deal not with what we take computational structures to designate. However the \vard "tire" designates nothing whatsoever about my cognitive apparatus: rather. TItis is Quite evidently an account framed in terms of internal computational consequence. It will turn out. This tendency is illustrated by so-called semantic interpretation rules for compilers. The two subjects are related: a considerable literature. he or she wilt typically respond with an account of ho\v such expressions arc treated by the primitive language processor. but rather with what behaviour they engender (a compilation is clearly judged correct on operational grounds.e. For an English expression the analogous cognitive significa/lce of an expressioIl the complete account of the effects on my head is by no means the same as the designation or reference of that tenn. Furthennorc. it designates high-intensity oxidation. The meaning of QUOTE in LISP is a telling example: the ncar universal claim as to its "meaning" is that it is a primitive function that defers one level of evaluation. if we analyse progranls in temlS of their attributed designation (i. In contrast. not in terms of semantic attribution). for· example. and not of the world either. be explained solely in terms of behaviour. or wllether it will be possible to account for the internal cognitive consequences without knowing the designation. causing me to abort any other ratiocination I am in the midst ot: to send emergency signals to my leg muscles. as many have argued. However. Semantic Rationalisation Procedural Reflection 136 function is typically of a type that takes complete fJJachine states into complete machine states. the fact that it designates fire for me cannot. Thus people argue as to whether an account of the psychological significance of the term "water" will have anything. is devoted to the question of whether cognitive significance will in genel(lj have to be accounted for expressly in terms of such designation.3.to do with water. if we recast computational semantics on our own tcrnls). if one asks of a programmer what the semantics are of some primitive. that many of the lenns (object designating expressions) of a program will tum out to be designators of ele~ents of the structural field . the sentence "Fire!" may have all kinds of consequences on my mental machinery. We may note in passing that this is not the way semantics is construed for natural language. In fairness. there are two subtleties here. and so forth. certainly no one assumes the two subjects can be iden/ified. For example.

they are in some sense meta-structural). incapable. for an internal model of semantics for the base level structural field is simply impossible. Stoy. Gordon. but without a crisp analysis of whether they arc designators or designated. in other words. x words. it is apparently consonant with our intuitions to assume that all natural semantics remains within the boundaries of computational systems. facilities. it seems the easiest move to make an apparently successful story complete. which are not quite functions and not quite expressions. tllCY are posited as the "semantics" of procedures. the fundamental contradictions and inadequacies of such an approach emerge. most programming languages arc typically used in a first-order fashion.. which are typically On our account. it goes too far. Once one moves to higher order languages and mcta-structur. however. for example. for example. implemented in terms of binary numerals of a certain precision. to the point of losing the original intuitions. The embedding world of a progratn. denotational semantics in the Scott-Strachey tradition (as explicated. the variables and identifiers of. is another set of computational this was the import of the process model of computation sketched in section I. are the boolean constants and the numerals. of explaining that designates the identity function. attributed understanding. a FORTRAN program designate the data structures that form the field of structures over which the structures FORTRAN program computes. thus the explicit designation of terms designating functions can be sidestepped in a semantical account that treats procedure applications as a whole.e. What remains. Once one attempts. although this last is a little embarassing. Consider for example the numbers. Equally cmbarassing are such constructs as closures.functions and nUlnbers and trUtll values and so forth. in other It is has to do with addition. of course. or that AX. From this fact it is easy to see why.3.. making abstract everything about the machine. In addition. (+ 2 3) standard denotational semantics is close in style to the sort of semantics we are in search ot: However there is an odd sense in which. for example. In this respect A purely "internal" semantics. also. In a simple case. Semantic R~tionalisation Procedural Reflection 137 of anotller computational process (i. is simply inadequate as a way of explicating. for our purposes. Not all computational scmantical accounts are internal. which can be approximately identified with their referents (the truth-values and the numbers). and others3) deal explicitly with abstract designations . typically. to integrate a representational or descriptive formalism with a procedural onc. by rfennent. say.e. . the same problems come to the surface. if we are not careful.

the kind of semantics we are looking for would make explicit the fact that what was returned would be so constituted 19. A standard programming language account (except for context rclativisation) would also map such an expression (lnto tbe real number five. In such a circumstance.000) rewrncd rather than NIL. 000. however. 111at this is true is evidenced in tltc fact (and this is perhaps the clearest way to understand our complaint) that there is no way. even when one is given a ccmpletc dcnotational semantics of a language. the full designation if that semantics were precise - designated the application of a modified kind of addition to the numbers 18 a modified additioc function that yielded the answer -27 on such million and 19 million - arguments. in other words. is that they don't identify attribution independent of all the other aspects of an expression's computational significance. Rather.0 might evaluate to rather than because of the imprecision of the underlying ~id implementation. Consider however a case of roundoff error. 000. so that we can decide whether the behaviour is appropriate. IISP dialect in which T. is to make behaviour subservient to semantics.000. our goal.000) 27 (+ designates 3'} million. but not at the expense of formulating the pre-computational intuition that enables us to ask whether the result is co-designating or not.000.3. .. and they do not identify that aspect of it that is independent of a procedural or computational processing of the structures.000. because of overflow. Thus we want to know that 18. or where (= 1.no way.0» -27.000. so that we can decide whether the numeral - is an appropriate thing to return. but we will not use the word designatioll to refer to tIle abstract functions that this mathematical structures maps expressions onto.000.0 (I 3. we will say that . to ask whether the Innguage processor is designation preserving .000) not exactly match what was designated.000 On a standard dcnotational programming language account. we arc happy to allow that to be said.. in fact. thus in this instance they would be allied.000 19.000. in contrast. 31. We might for example have a the numeral 3. to ask about the semantic character of tile processing regimen at all. to ensure tl'iat (+ 18. We too will erect an edifice of the standard denotational variety. The problem with dcnotational accounts. If a particular architecture is not constnlcted so that co-designating numerals are always returned. Semantic Rationalisauon Procedural Reflection 138 expressions like (+ 2 3) will designate five: the computational consequence of such a term may be that a co-designating numeral is returned. because its goal is to explain behaviour. Thus the semantics is formulated in service of behaviour. or a situation in which integer numerals of only a certain size were supported.000 19. (+ 18.

4 As we have said before. We reserve the word "designation" because we will formulate an account of that as well.3.. 6 . However. Denotational semantics would indeed if il look olltologically prior to its reconstruction. jUlnps out of the function's body. 1101 0/ what those Slr:.. we have no complaint with formulating sufficiently cOlup!ex mathematical entities to facilitate the behavioural consequences of code that engenders sideeffects and jumps. Such an objection. we have surely wandered far from any natural notion of what anything stands for. if our mathematics makes the numeral 6 denote an infinite function from tuples of input/output-streams. however.lures are pre-computationally taken to signify. Semantic Rationalisation Procedural Reflection 139 such a theory mathematically manifests the fUll computational significance of a symbol. but it is the semantics of what happens 10 structures. as cu"ently practiced in computer science is denotational in style. elc. It should take considerable argument to convince any of us that the numeral stands for anything other than the Ilunlber thaI is the successor of four. We too will rest on this work. onto a function from continuations to outputted answers.. In point of fact. however. Consider for example this quote from a recent introductory text: ''It will not be satisfactory to take the denotalioll oJ" a function COllstruet to be the nlathematical function defined by its input/output behaviour. the accepted technique appears to be this: we are allowed to make the denotation of a computational structure be whatever is required to enable us to characterise mathcmaticallywhatcver it is we are studying. Denotational sflnan/ics. and so forth. and will use sue)l techniques. would misunderstand our criticism. in sum. we tvill need 1nore complicated denotations. The point is that "designation" is an English word having to do with what things stand for study the proper designation of computational symbols a term that arises from the that designatiolJ as unexplained but unarguable human use of symbols. Because it is esselltially operational in character. To handle side-effects. and that any attempt to discriminate between designation and dellotation is surely splitting hairs. processor states. it does lIot deal with Ivhat programs are about A reader may object that this is too strong a statement: that surely denotational semantics deals tautologically with what computational structures denote.l. we will then be able to ask how the computational significance accords with the prior attribution of meaning formulated in teons of the independent notion of designation.

from rhetoric or invective). in the quote just presented. rather t11an the other way around. we claim.3. it is only reasonable to be generous. behaviour should be designed to honour it What we understand symbolic structures to signify is primary: we then arrange their procedural treatment to honour this attribution. It is not. in spite of these pages. adlnitting car mechanics on . that is. an equal footing with echt computational practices. The reconstruction of lay understanding is thus our task: a goal once again subsumed under our aesthetic of category alignment. and semantics follows. if we are within computer science. this time of a methodological flavour. we have denied that standard semantical practice reconstructs what we are calling designation. The trouble takes a particular fonn: the apparent causal relationships - the dependences between theory and practice behaviour lules. We lose that innocence at the expense of the natural boundaries of the field. . Again. we have used tHO words with approximately equivalent meaning: "denotation" and "designation". Our th~oretical account should cohere . so much that folk pratice is problematic. The input/output behaviour is "what we intended" just in case it honours it correctly. with tile fonnert therefore. everyone knows that T stands for tnlth. Semantic Rationalisation Procedural R~f1ection 140 Note in addition. in other words. where we talk of formal symbol manipulation.should correspond in the boundaries it draws and the patterns it finds with that of the attributed if tacit understanding that defines the subject matter. It is the latter on which we are staking our claims. the phrase the mathematical function defined by its input/output behaviour. is foundational. this betrays a loss of innocence. Although these problems infect our theoretical accounts. Therefore. ~at First. it should be subservient to semantics (as proof theory and derivability and inference rules and so forth are subservient to truth-preservation and entailment and so forth). lay practicioners have not lost the clarity of semantic innocence. Since the power of our argument wilt emerge from the increased power of reconstructed systems (not. Note. Surely the input/output behaviour is defmed to honour the mapping appropriate for whatever fullction the construct signifies. as that our mathematical meta-theory has lost contact with that native understanding. are unnaturally inverted. however. in deference to current practice. Everyone knows that the numeral 6 stands for the number five. it is fair to ask what the consequences will be of accepting our view. In presel1t practice The structure we argue for is the reverse: semantics. Surely.

of the model theory that it is not given a name on its own. in other words. the analysed notion of denotation has anything to do with the at3ibution of significance or designation. of which two figure predominantly: one of declarative import (~) and one of procedural consequence ('1').l-tis comparison is too facile. In our . and that a proper reconstruction of IISP requires both such treaUDents. especially one famiiiar with the logical traditions. Model theory. In our own analysis we will present a variety of denotational accounts. and so purely a corollary of the main declarative semantical treatments i. what we arc calling procedural semantics is what in that tradition is called proof theory. that Tarski-Iike model theories i'or logical languages (such as for the first. More particularly.3. in particular. In order to demonstrate that We have satisfied the third mandate listed at the beginning of this chapter. in which structures are assigned an interpretation in a mathematical metalanguage. Semantic Rationalisation Procedural Reflection 141 we will use the tenn denotational semantics to characterise a style of mathematical treatment. order predicate calculus)6 are denotational semantics of declarative irtlport. to call the relationship 'I' a selnantical one. It may seem odd to the reader.e. after all. and fails to recognise a cnlcial point Perhaps in part because derivability is not a [unctioll. refer to a mathematical treabnent of the situation pictured in diagram unspecified is what kind of i. we 53-1. in other words. and in which the fonnal relationships between StIch structures are explicitly treated in tenns of such interpretations. It is the first that must. arc calling declarative senlalltics is merely what in logic is called model theory. there is no tendency to treat the procedural relationship in logic in tenns of attributed understanding: rather. formulate the designation of all expressions. we submit. we will have to have both semantical treatments explicitly available. it might appear that what 'de ~:iJ. TIle entailment relationship is in contrast semantically characterised. that operational accounts are dcnotational accounts of procedural consequence. easily stated. deals with the declarative interpretation function and \vith satisfaction and designation and all the rest. proof theory deals with the relationship between sentences provided by the inference processes. However t. We will argue that denotational semantics of the standard programming language sort is denotational semantics of full procedural consequence mixed with some amoant of declarative import.lltcrpretation is thereby analysed - What is left whether. one formulates and understands it purely in terms of the nlcchanisms that implement it.. By denotational semantics. but it is so simple.

~fa1"subtraction 2-LISP.4 2» presumably. Rather. probably compositional and so forth. It is 4». function to the same two numerals. and function application is an essentially non-computational. none of whicll makes reference to the notions of functions and application at all.4 2» that would characterise the relationship between (. Semantic Rationalisation Procedural Reflection 142 computational formalisms. and therefore attributed. 4 2) (. it is 'It (+ 4 2) (. yielding in the enod the numeral meta-theory to specify the designation - This last is not the designation function (even though analogous function applications are used in the an entirely different affair). C()nsider the expression (. understanding. deserving of its own semantical analysis.3. which has to do. Finally.4 2». specify in fact what happens when (. (+ 4 2) (. The procedural semantic characttrisation in. followed by the application of the 12. will penncate the discussions throughout the entire dissertation. Neither. These three related but independent stories and of iJnpJementatioIJ - of designatio1l. as we have said so often. however. we do understand procedural consequence in tenns of attributed understanding: as we made clear at the olltset. it is a semantical account. we understand LISP in terms of jUnetioll application. it is the computational account (+ 4 2) 0/ the implementation that would is processed: an account. of what happens. however. is it the Jonnal symbol manipulation account that is the true computational story of what happens. in other words. An example will make this clear. The declarative semantics will tell us ttlat this structure designates tlle number twelve. would say that this generates the application of the 4 numeral-adrlition function to the the numerals and 2. a depth-first left-to-right designation-preserving computational systerrt like nUfi1.4 2» onto the number twelve. followed by the numeral- multiplication of the resulting numerals. provably equivalent to that semantically specified in the formulation of v. and the correspondence between the two constitutes the proofs of soundness and completeness and the rest for the relationship '1'. that would map (. . ( + 12. since it talks of operations and results and temporal ordering and so forth. and the resultant co-designating numeral in tenns of nonnal-fonn codcsignators and function application. ( . of procedural consequence. say. There is an entirely non-attributed understanding of how the procedural treatment works. with structure and environments and processor states and intermediate results.

in other words. however. We make the atom evaluate to itself: and 6 for truth. a function that one necessarily must contend with . Nothing but confusion would result if the interpreter in a way that bore no relationship were treated by the IISP with our understanding of that expression as a ternl designating the sum of five and six. exactly when one succeeds in developing a semantically rationalised system. LISP but in fact it is straightforward. that making constant reference to both of ell and it becomes Ullnecessary if f) and 'It it quickly becomes cumbersome in dealing with a real LISP system . More importantly. because of the semantical type theorem. but the fact remains that it is . once it is LISP examples will illustrate.so consonant with eft that it can be safely in most of our thinking about 1= in other words. as the reader will see in the first parts of chapter 4. it is always natural to talk only of the designation (ell) of fonnal Front this fact. are sufficiently closely allied that talk of one can always it is made unnecessary. Similarly. Our ability to ignore it if is irrelevant: the very point is to make 2-LISP. signifies tl'le first element of whatever list x signifies. the situation is just (EQUAL •A •A) reverse. treated by the LISP "addition" function.ii.even one as limited as the pure be simply converted to talk of the other - dialects we will develop. just as the ability to prove that r. the luxury of using just one cannot be achieved 3. their procedural import '1' is so readily obtainable from their declarative import that intricate discussions of the former are happily dispensed with. the expression expression (EQUAL •A •A) T (CAR X) IISP. for example. The 6 atom T. For example. b. will be our great success.. In dialects in which procedural treatment docs not parallel the declarative treatment in systematic ways.and are equivalent in complete logical systems allows one to think in tenns of just one. Declarative Selllantics in LISP It might seem to take some care to show that programmers bring a precomputational attribution of significance to clear what the endeavour is. it should not be concluded that ignored. is taken to signify tntth. the numeral expression (+ 5 6) because T slands docs not signify the number five because of how it is evaluate to T. Semantic Rationalisation Procedural Reflection 143 It will turn out.3. and the numeral to signify the number five. Some simple Similarly. 'I' - expressions. and because of the category alignment it between and . tile T11cse claims do not rest on the fact that the atom T evaluates to itself: or that the evaluates to that atoln. in 2LISP. 'Ibcre is nothing saying that liSP has to be defined this way. rather.

stands We live happily with the fact that LISP deals with numerals (and not with numbers) because we can satisfy ourselves that things have been arranged so that no differences in behaviour arise. expression IISP to signify the first element SElF interpreter will return the first element of procedure (recently (SErf x 4) is that list when it evaluates the expression. we need to remember that II name of procedures. not as the And. before attempting to explain why the expression (EQUAL 3 4) evaluates to NIL. which again betrays the fact that in our usc of the tenns and "CDR". and that the first half of such a cell is called its "CAR". (SElF (CADR Y) Z) is equivalent to (RPlACA (CDR Y) Z). is provided by tile (SElF (CAR X) <EXP» A generalised assignment operator is defined such that the is equivalent to (RPlACA x <EXP» (similarly equivalent to (SETQ x 4). thell we kllow that the list represents a june/ioll .3. at the risk of being repetitious. it is enonnollsly useful that we define its behaviour so that we can make use of our externally attributed understanding that for five. prior to our understanding that the introduced in MACLISp6). and that we understand one as standing for the otllcr. N desCnpliolls and functions are different categories of object l'he phrase the largest illteger such that N is its own square" is a description. and so forth. (CAR X) A striking piece of evidence that we understand of a list. . "If the CAR of this list is the "CAR" alonl LAMBDA. This is an entirely natural way to speak. if the student did not realise it straight away. a computational language) . the second halt: its "CDR". at least so far as anyone has shown. Semantic Rationalisation Procedural Reflection LISP 144 designed in this waYt and for good reason.. so to speak. One would clearly mention the fact. But to be able to say "it is just the same either way" implies that we know the difference. we think of them as concepts ullder which to form descriptions. but invokes no procedure. Imagine instructing a novice in the use of IISP - a useful gedanken experiment because it provides a natural setting in which one's pre-theoretic intuitions need articulation. it is a complex macro that unwinds its first argument. Similarly. one might say that the LISP field of data structures included linked structures called "cons-cells". By using such tennillology in English the paradigmatically referential language (and not.one legitimates the use of such descriptive phrases as "the CDR of CElL-20 tl . and so forth). that the atom T stood for "true". Thus we might say to him or her. SElf doesn't evaluate its arguments - ratllec. Even though the interpreter does not 5 know that the numeral 6 designates five. ". constructing a modified compositional structure that will effect the change on the proper structure. and NIL for "false"..

it would be odd.3. • (4 6 A better account. however. is an admission of defeat: the name of a mechanism used to implement a simple intuition is used as the theoretical vocabulary in terms of which it is defined. or why it was defined. but this could is far too non-specific to capture its meaning. or what was (SElF A B) in the mind of the person who defined it One sometimes hears the explanation that is a procedure such that after evaluating then evaluating or (SElQ A will return (1. the LISP concept of locations would seem to arise from Von Neuman architectures. to think that tllC natural explanatioll of inaccessible underlying architecture. Furthermore. expand into either of {DEFINE CAR (LAMBDA (X) 4» x '(4 In response to such criticisms. and is probably inadequate no matter how it is construed. One sometimes hears of left-hand side values and right-hand side values. that again betrays the fact SErF that we use our understanding of language to understand formal systems. Semantic Rationalisation The code for SETF Procedural Reflection SElF 145 could be used as a way of explaining what SElF means. . We did not need any notion of location in defining LISP in the previous chapter. expression used for suetl assignment. in saIne sense los other than what it evaluates Another way in which such constructs are sometimes explained is in tcnns of how they work. Furthermore. but one still tied unnecessarily and unhelpfully to the (SETF mechanics of implementation. partisans sometimes offer the reply that effect the minilnal change necessary to make the first argument evaluate to the second. is inelegant in the extreme. among other reasons. uses a notion of a locative: thus x in the expression x 6» would be used as a locative to identify a location to be set to the quoted list. but this SErF doesn't answer the question of how is understood. therefore. works in . and is powerfltl for. By this account SElF (SElF (CAR X) 4) 6 6». but of course the notion of minirnality would have to be discharged. the actual code that implements SETF docs not make reference to the fact that SElF liSP is imp/eltlellted in terms of locations on such a Von Neuman maclline. In sum. all of this kind of talk is an inadequate reconstruction of the intuitive feeling that SETF should change the stlUcture that the first argulnenl points to. since the the non-evaluative situation typically occurs on the left: hand side of the grammatical . This too. of course. l~hcre would need to depend on this is a much simpler explanation of SElF than its code. it would be odd to introduce one at suctl a point. the fact that its abstract virtual machine is in no way dependent on notions derivative from this class of computational device. Such a characterisation. for lack of a better alternative.

issue of intcnsionality. in what Donellan has called an attributed sense. we are adnliJling the pre-computational (and language derived) attribution of meaning 10 conlputalional structures. given some value of x. where we mean to decrease the compensation of whoever holds the office. not of the person who is currently President independent of occupation.3. this would be a difficult protocol to defend or explain. we mean something like. But to accept this means we accept accepting SETF. in intensional contexts. of course. we mean to refer to something like whoever salisfies the description lithe President".manner to another (such as assigning y to "always" be X where that is intended to mean that Y should be constrained to be one greater than x. This dissertation constantly skirts the crucial . All of these are practices lifted from the . because of the fact that we understand to be a composite term . fact tllat (CAR X) is a designative term. Rather. for example. Semantic Rationalisation Procedural Reflection 146 the way that it does because it treats its first argument as an intensional description.' in one reading of the sentence Lower the Presidellt-s salary to $30. + 1. is not used purely extensionally. similarly uses computational structures Similarly. whereby one variable is hooked in some . By in other words. that y should track x. rClnaining exactly languages8 1 greater than it).a description of the first element of the list x. The phrase "the President". If (CAR X) (SElF (CAR X) 3). 7 It It is just like the use of the phrase "the President. in this construction. it would not (at least on the reading we are considering) mean that we specifically meant to lower that fellow's salary. construct. The term (CAR X) is being used intensionally The in the SETF context. Similarly. But it is undeniable that we do use language this way.000". We don't. (CAR X) make the minimal change such tJlat the intensional liescriptiolJ was meaningful only in (CAR X) will designate the temlS of its behaviour under EVAl. no matter what x subsequently beCOlncs . are rife with designative expressions. the recently emergent constraint as descriptions. There arc other such examples throughout computation. and it therefore becomes perfectly natural to invent computational constructs (like SErF) that usc other computational descriptions in an tlle analogous fashion. if Mr. know what it is to usc a description intensionally: the answer awaits the millenial epistemologist.e. Glasscock were President when the phrase was uttered. But it is easily comprellcnsible to a human. (CAR X) is not used in a purely denotational sense in numeral 3. not simply a procedurally defined form that returns the first element of a list.i.but yet to be understood . which permeates this example.

) . without making reference to EVAL or to how the interpreter works in establishing this semantical attribution. in other words. exprssions will fail. a calculus in its very design should facilitate such declarative attribution. what. even those that are computationally oriente·d. so far as it is possible. thereby Dlaking our programming languages more like natural this practice should be admitted. tlle point is that we have to establish the semantical import separately.3. As we understand how to embed them coherently into computation systems. Semantic Rationalisation Procedural Reflection 147 lay use of language. for example. We cannot. answer a student's question of the form "What does the expression (LAMBDA (X) (+ X Y)) nlea~ given the occurrence of the free variable y?" with the response "WeIL if we look at the defillition of EVAL we can see that it notices that the first element is the alOlll LAMBDA and constructs a closure". and furthermore. to make explicit that prior understanding. for example. The evaluation process is elegant to the extent that it does something that and as we will see in this chapter. therefore. The morc important lesson is that. failing particularly in meta-structural circumstances. Even in the expressions just given. the construct NIL) LISP (GO lOOP) or (QUIT) designates. or (THRO~1 'E XIT Sometimes this search for a purely declarative reading of It is difficult to say. if anything. and then to use the best understanding theories and conceptual analyses language~ and therefore making computational systems easier to use. since it is apparently part of our natural way of comprehending formal systc!ns. Rather. rather than structures with natural procedural consequence.f . we will attempt to do as thorougll a declarative UlfCC treatm(~nt as seems part of our natural understanding. we do so. that the study of human language will play a role in uncovering that prior ascription. to the maxinlum extent possible. Our present claim is merely that the best of linguistic and epistemological phenomena in understanding that computational practice. The moral of these few examples is that we have an understanding of what expressions signify that is prior to our understanding LISP 0/ how they are evalualed. I-lISP'S does a coheres with that prior understanding - reasonable but not excellent job. the arguments are clearly first and foremost designators. Nonetheless. is. Our primary task. in order then to be able to characterise the evaluation process in terms of it Unless we can do this we will have no principled reply to our student's next question: "Why does EVAL work ill this lvay?".

and this is why the A -calculus is lexically scoped it is the only obvious protocol in a fonnalism with declaratively specified function designators. the function computed by EVAl is clearly 'It. to include other aspects of the natural structure of 11uman language. that this correlation includes natural language fonnations of a wider diversity than The obvious extension of the approach we have followed here. It is clear. since. Thus we have little to say of interest about side-effect operators in LISP. it is in their tacit correlation with natural language that much of their coherence lies. Our basic moral is that computational concepts should be related to natural language constructs. particular. taking expressions to be lenns. + might be the correct It will be at this point in the analysis that tIle fonn of tile cvalutaion . simple designating nominal phrases. iii. declarative import and statically (pre-computationally) specifiable semantics are independent notions. dynamically seoped variables will not Admittedly. like SET and so forth - constructs unarguably closer in intended interpretation to verb phrases in natural language. b. as discussed in more detail in section 3.3.v.c. Semantic Rationalisation Procedural Reflection 148 (In order to avoid confusion. Our strategy will first be to articulate a I-lISP'S 4». therefore.) A final comment There can be no argument that our focus on an applicative calculus - and on designational attribution - betrays the fact that we are allying We are. the seman tical function formalised by standard mathematical semantics is a mixture of designation function 4» ~ and n. Summary In LISP'S case. and functions are playing the kind of role that descriptive concepts do in English. however. a pre-procedural treatment of designation is possible for the A-calculus. we should remark here that the foregoing argument does not imply that whereas statically scoped free variables will succumb to a declarative treatment. in computational constructs with pre-computational notions of noun phrases. tIle pure is not normally formulated. defensible account of then to explicate I-LISP'S 'If with reference to the operational style of account given in the previous chapter. 3. and then finally to inquire as to what semantically-definable function () the procedural function embodiment of. Nonetheless. autllor This has long felt that a Gricean9 speech act analysis of ALGOL would uncover much of the tacit structure of computational practice. would extend the style of analysis that we have given to nominal designation. the present investigation can be viewed as a tentative step towards such a full reconstruction. on our view.

and then a rationalised '¥ that provably implements it.and fl- reduc~on Nonnal-form (preserves 4».o{Formal Systems System c) (53-12) '1' (J A-calculus: Logic: 1-LISP. summarises the characterisations we have made about a variety of systems. SCHEME: 2-. by way of review. satisfying the normalisation theorem. 149 It is the inelegance of will lead to the suggested design for a clean prior defmition of an appropriate 0. no further reductions apply) 1= I- interprelation function ? Evaluation Normalisation ? Normal-fonn(preserves~. and are not so much new as they are traditional. 3-LISP: Declarative interpretation function Decl~rative a. form determined by semantic type) Declarative interpretation function .3. The following table. A Semantical Characterisation ola Variety. in postulating interpretation functions of the classic sort. Note in particuar that I-LISP and SCHEME (and by 2- implication all extant 3-LISP LISP dialects) are without well-specified versions of «) and 0. Semantic Rationalisation theorem will be articulated and shown to hold of traditional I-LISP'S 0 that Procedural Reflection LISPS.

Durine the course of the processing. and will say that x returns V(X). an environment. Local and Full Procedural Consequence We have presented the function 'It as if it were the function that made manifest the full procedural consequence of each symbolic structure. but also of "the rest of the Inachine": usually a memory. and alterations to the pr<. can be treated by including some appropriate abstract objcct . will have to reflect not only what result is returned when the expression is processed but also any effects it may have had on these other componcnlc. In point of tcnninologYt we will call the result of x. and a continuation (inpuVoutput effects. there may in addition be what are known as side-effects on the state of the machine. Some of these have to do with general 4» issues. it will make the subsequent technical manoeuvring much more straightforward. A mathematical treatment of the full procedural consequence of an expression. Two kinds of side effect. some with the relationship between and Y. but that is an over-simplification. some with LISP'S particular circumstances.. we can see how this standard .~essor. in addition. and that 'It defines the local (procedllraQ consequence of an expression. therefore. Though it is unfortunate to spend an entire section constructing machinery. such effects arc ijealt willl by making tlle main scmantical function be a function not only of the formal structure. as intimated in chapter 1: alterations to the structural field F. Given t\yO reconstruction of computational processes as consisting of a structural field and a l processor and our claim that the theoretical entities of an environment and a continution adequately characterise the state of a processor. Semantic Rationalisation Procedural Reflection ISO 3. In a standard semantics of a programming language. of the abstract l machine. as expressed in the environment E and the continuation c.e.c Preparations for 1-LISP Semantics There are still a few preparations to be made before we can sketch appropriate declarative and procedural semantics for LISP. need to be handled.3. however. l. if is the function computed by the language processor that takes each expression or fannal this is at the crux of 'I'(X) structure into the expression returned as its "value" or whatever LISP being an applicative language. in particular.such as streams o~r but we will ignore peripheral behaviour at present).

in the general case. such as non-local control operators FRETURN). such a semantical function will necessarily be sufficiently powerful to allow arbitrary computational consequences to emerge from the processing of expressions or structures. and a continuation (continuations are of type ces x ENVS x FIELDSl -. VF E FIELDS. and our models for ". f')]) . In addition. since it is with respect will be fonnulated. \IE E ENVS. with the fact that the processing of the A to expression alters the structural field in such a way that CAR of the first argument is changed from the atom the atom C. We too will have to fannulate such a complete state-transfonning function in order to characterise the full procedural consequence of function r. We have no I-LISP to this simpler function that our criticisms of (RPlACA '( A B) 'C) I-LISP in other words. We will call such a CONTS1 -+ {S X ENVS (THROW res x ENVS x FIELDS X and RPLACO). as of course may reasonably be expected. yields for our purposes too coarse an analysis. C E CONTS [ 35' E S. and it is unarguable tllat this fact can only be OUf only comment is that it is important to made explicit when looking at f{RPLACA). however. it will turn out that our attempts to defme a variant on r - I) and 'I' independently of r will founder over the questions 1: of side-effects. retain the function'!' as a valid subject of study. In addition. Semantic Rationalisation Procedural Reflection lSI treatment effectively makes tIle main semantical function take complete machine states into complete machine states. we will attempt to formulate r in such a way that the function 'If will play a self-evident role as an ingredient The complete state-ta-state transfonnation function. since it is the coherence of it with 4l that we wish to scrutinise. E' E ENVS. if our field and processor model of computation is adequate. emerge only from a finer grained decomposition of a computational symbol's full significance. in our second pass (section 3. in other words. [5 X ENVS x FIELDSlJ): (53-13) vs E S. On OUf initial attenlpt. In other words. our complaints with IISP. an environment. will be comprehensible only in terms of their full r-characterisation. F' E FIELDS [ r ( S . and CATCH and structure modifiers 'If in (RPlACA and so forth.3. reconstruction. C) = <S " E'. E. Certain types of expressions. our initial version will be of type X FIELDS11. r. I-LISP processing.e) we will define a more complex function with cIJ and v integrated more fully into it. However we will try to focus primarily on the simpler function complain~ analysing I-LISP evaluation. r will be given an expression. a field.

E. E E ENVS. if an expression s has a control side-effect. C E CONTS [r(s.3. . in so far as we are able to avoid complexities. Our main interest in r. C € CONTS [f(S. f. 'IF E FIELDS. E. E E ENVS. E E ENVS. F) for some E' E] Similarly. [3F' E FIELDS. In the first case we say that an expression has a field side-effect. F. In particular. F') for some F' (S3-16) ¢ F] Processor side-effects are of two types: those that affect the environment. More precisely. C E COIITS [f(S. E € ENVS. E. F.. E E ENVS . Et . F)] There are two ways in which an expression s can fail to be side-effect free: it can affect the field and it can affect the processor. however. C) (53-16) ¢ = C('I'EF(S). E' E ENVS ['Ie E CONTS [res. F')lll At various points we will hint at the appropriate mathematical characterisation of tJle full procedural consequence of side-effect expressions (non side-effect ones need be characterised only in terms of 'It since 53-14 supplies the remaining information). C) This does not. VF E FIELDS. capture the intuition. C) We need instead the following: (53-18) = C(i'EF(S). E. since too InallY functions c' can be found for side-effect free expressions. C) (53-14) = C(1J'EF(S). we (. C € CONTS [f(S. Semantic Rationalisation Procedural Reflection 152 Given this general characterisation. will be in sllowing that all nonnal-foml designators are side-effect free.. it is too liberal. E. however. and those that do not invoke the regular continuation. F. F) for some C' =I: VF E FIELDS.. E'. we would characterise this as follows: (53-17) E.:an make precise some of the ingredient concepts we will ultimately use in defining an adequate notion of normal-fonn. if an expression has a environment side-effect then the environnlcnt yielded up as a result of processing will be differcl1t from that in which it was processed: VF € FIELDS. E. then the continuation c would not be the function given the result Informally. an expression s will be called side-effect /ree just in case its r-characterisation is as follows (we often write respectively): ifEF«exp» and tfJEF«exp» for «i'E)f)«exp» and «i'E)F)«exp». C) = C' ('I'EF(S). its full procedural consequence would .have the following structure: 'IF E FIELDS. F. C) = C('tEF(S). E.

1o No worthy account of the distinction between the two concepts prograln and data.3. is distinguished partly because it does not make this distinction.ii. and consequently gives a program the ability to manipulate program structures dircctly. . is to raise a question as to whether a subsidiary distinction between program and data structure can be raised in particular. will have to refer to r. it is clear. it is tempting to define as a progmn. For the time being. we will ignore these potential interactions. for example. It is of some interest. In particular. 3.z. is in terms of r. it is not incidental. therefore. however. Semantic Rationalisation Procedural Reflection IS3 It will tum out. Declarative Semanticsfbr Data Structures In most programming languages. if indeed tlley arc coherent and exclusive. 4l of all tcnns within the fragment maps tenns onto We have in other words the following claim: All tenns in programs aTe lnela-struclural designators. however. Can we. to note that tlle present endeavour of making explicit the attributed semantics to all computational structures may in fact serve to reconstruct this notion as well. that the ultimate definition of. in otlter words. has been formulated. however. that we are studying a language What this does. they will surface in section 3.e. will have to be admitted as designating the number five. any section of structural field with two propclties: procedural consequencei' is defined over the fragment. and the declarative import other structural field elements. rather than the number three: (LET «A 1» (+ 2 (PROG (SETQ A 3) A») (53-19) The. because of interactions between the declarative import of composite expressions and the potential side effects engendered by the procedural treatment of their consituents.e. of course. distinguish a particular structural field fragment that is intended to be a "program" from one intended to be "data"? A considerable literature documents the fact that making such a distinction is problematic at best. LISP. Such a capability is clearly a prerequisite to the construction of a reflective dialect with such a property. The following expression. the set of expressions that are programs and the set that are data structures are kept distinct. in other words. only way in which this can be made explicit. and possibly ill-Founded.

and lists used to encode function applications. procedural functions 'I'. {Juradigmatic data structures do not bear procedural consequence. the foregoing example would be expressed using the enumerative . This is in fact the tack we The situation with respect to 4. It seems particularly troublesome regarding the S11Ch The simplest approach is to posit a function defined over all structures as are intended to have ~tructures. which is of course nonsense. if we adopt the view that our declarative interpretation function applies unifonnly to all structures. semantically. to ignore what it maps them into. each element of this list designated the value of the function designated by the social security number applied to tile grade point average. and to ignore whether or not it is defined over data will adopt. Suppose for example. For present purposes.0) . but to use it in our analysis only over procedural consequence. there is a question as to whether we want the theory of declarative import we use to explain terms in program to hold of all data structures as well. Thus we might have «234-23-2344 3. we will not make any such distinction. ). structures. if we say that the structure (CAR A) designates the value of the function designated by the atom A. regarding '1'. of which the first element is the student's social security number.esis. however. Semantic Rationalisation Such speculation.. or. that it would claim that. It would SCCln. or merely to those "considered to be programs" or "considered to be data structures". a problem thereby arises in our formulation of semantica1 interpretation functions. CAR applied to the (F G) referent of the tenn are we committed to saying of any data structure F that it J designates the value of the function designated by applied to the referent of G.is more complex. First is the standard confusion between lists being used to designate scqllcnces or enumerations. if it happens to be defmed..is beyond the scope of this th. as to whether they should apply to all structural field elements. - Procedural Reflection 154 as to whether such a definition adequately captures the persistent lay notion . In other words. that a user of the language sets up a list of students and grade point averages.3. While it is clear that straightforward. Although this undifferentiated position is in some ways simple. of the following format: the whole list consists of a list of two-clement lists. However there are two reasons this need not bother us as much as it might seem. and the second element is grade.96) (021-99-8276 4. Once we have tnade this into a structural distinction.

and each constant to signify SOllie object in Ule scmantical domain. we are 'I' implicitly admitting that the class of structures falling in the natural domain of «) is wider than that falling under '1'. structural field elements intepr~tation filn(.iii.3.or represented. sets. as well as . Extens. TypicaJ.e. Semantic Rationalisation type of data structure. the model theorist has no idea and no interest in what parlieular predicates and objects the user of the language will employ. First.ture for which one could claim to understand it. but c~uld say nothing about what it stood for . subjecting data structures to a declarative semantics is still far removed from making the data structures an adequate declarative language. As discussed in section 3.1y.. this last move of including all user data structures under its purview means that we will have to allow it to include the user's world of objects and relationshipfJ. The second reason suggesting that it is indeed appropriate to posit the declarative semantics over all data structures comes from our general endeavour to unify procedural and representational systems into a coherent single framework. below. . whereas the range of the function (since 'I' is the set of s is of type [S ~ -+ Sj)t the range of the declarative -to will be much larger (since is of type [S 01). There are some consequences of this approach deserving notice. in 2-LISP Procedural Reflection ISS it would be expressed as the structure [[234-23-2344 2-LISP) 3. ]. 111 the elements of s. Already we have assumed that the semantical domain D includes numbers. Recursive COlnpositiollality. 3.c. but it is nonetheless a valid first step in that direction.v. however..0] . poses no particular problem.96] [021-99-8276 4. in fonnulating the semantics of a base level language. The standard semantics (for will say or each doublet in this structure that it designates the abstract sequence consisting of the referent of the symbol encoding the social sccuri~y number and the referent of the numeral encoding the grade point average. and Accessibility The third comment has to do with what is known as recursive compositiullality. This. and functions. which is just what one would like.cnality. The task of the model theorist is generally taken to be one of showing how the significance uf composite expressions arises froTn the significance of tllose expressions' constituents.~un ell Secondly. It is much clearer in the case of data structures than in the case of programs that we always understand them by attributing declarative import to them: it is inconceivable that there could be a useful data struc. 'lne mathematical semantics merely assumes that each predicate Jetter is taken to sienify sonle predicate.

and similarly wiLi '1' and r. ingredients. formulating all of . such as on the thne of day or on x's . It is different to say of a cOlnposite expression x. the semantics of (QUOTE X) is still compositional.3. then an expression x' formed from x D with \vould have the same interpretation under 4». It follows that if some 0 further expression by replacing A had the same fit-semantics as A. A. will be on the various different semantica1 relationships. cI»(D). In addition. 8. however. and c are said to occur within x in an extensional context. then if4»(x) is a function only Off)(A). and c. but there is certainly some sense in which this kind of compositionality at least roughly holds in natural language. 0. in the traditional fashion. 4 1) (+ 2 3) and (+ 2 (. B. the single argument fJl( X) p~sition expression (QUOTE X) is not extensional. and 4>(C). that the meaning of the whole is in any systematic way determinable from the meanings of the parts. recursive compositionality semantics of this sort is a powerful way of fonnalising meaning. Semantic Rationalisation Procedural Reflection 156 There is no guarantee for all meaningful languages. and it is made to be true in all formal languages. but also We will say that in this case the selnantics of x arc stiJl of A. B. then each of A. For example. If x is a composite expression cOlnprising three ingreedicnt expressions A. that its interpretation under some semantical function is a function of itc. in The bulk of the emphasis. III of a composite expression will be defined in tenns of 41 ~f its constitutents. H(. and cI>(C). to use the previous example. tf»(B). pardcularly in this chapter. but that X is not extensional (more precisely: that the constituents and c do not occur in extellsional contexts). and c themselves. and (- signifies the same number as does the numeral 3. and there are various devices (passing environments and continuations explicitly in programming language semantics is a good example) by which a great deal of con~cxt-relativity of the meaning of an expression can be captured within the basic compositional framework.. and f. unless otherwise noted. in the LISP For example. recursively compositional. since that means.4 1» signfiy the same number 5. as we attempt to formulate the style of remantics we want to adopt in the remainder of t"te dissertation. nonetheless.wever the reader can expect that. that tI»(X) could be a function not only of «Il(A). In order for x to fail to be recursively CODlpositional would have to depend on some quite other factors. Recursive compositionality should not be confused with what is known as an extensional semantics. of course. since arguments to the addition function are extensional. '1'. We too will adopt a recursively compositional stance.

for example. However it is not immediately obvious that the notion of ingredient or constituent is in general defined over arbitrary structural field fragments (and. Thus the notion of compositional semantics is at best partially defined in the case. Note as well that we cannot ask of a particular token structural field fragment whether it occurs in an extensional context or an intensional context. The recursive definition of a multiplier given in LISP 52-111. Nor is this restricted to atoms. 157 In lexical systems. A given expression may occur ill marc than one context. where these notions have been developed. as if a single answer were al\vays forthcoming. Even in as simple a structure as (CONS X (QUOTE X» (the expansion of (C(\NS x 'X». it is the structural field. rather than the notation used to signify it.3.given for example by the derivation tree of the lexical grammar. however. although we will want to say of that its semantics arc compositional. however. as we have several times pointed out. Without it both concepts of compositionality and of LISP extensional contexts are ill-formed. for a structure to be accessible from itself . 52 E S [[ 51 E ACCESSIBlE(S2)] /\ [51 ¢ PROP(Sz) n (53-20) Sut:h an accessibility relationship. we need to It happens that in the IISP SllOW that such a claim is meaningful. one cannot ask whether x occurs extensionally or intensionally. since it may be accessible from more than one other structure. Semantic Rationalisation position in a data base - Procedural Reflection facts that arc not part of its own constitution. the notion of an "ingredient" is clear . for example.many examples were givel1 in the last chapter. does not include the accessibility derived from the environment: thus in a recursive definition the binding of the recursive name within the body does not yield a circular constituent structure. In the previous chapter we discussed the accessibility relationship on tlle field: we can say of expression S that its constituents are those structural field clements accessible from it (except for the property lists accessible from atoms): CONSTITUENT : CC S x s 1 -to {Truth. Falsity}] =: AS!. that is the source domain of both if and c)). Thus. in the structure which would be printed as: (CONS (CAR '(A B» '(CAR '(A B») (53-21) . is by this definition one of its O\Vll constituents. case we have a relatively straightforward answer to this issue. It is possible. there is only a single atom x.

being a semantical function. It is traditional to have the Incta-Ianguage include the object language.e.i. where the quoted fragment is I-lISP notation. distinction is not simply one of treating the notational structures abstractly (i.and 'It. Semantic Rationalisation where the two lists beginning with diagrammed in 53-22 below CAR Procedural Reflection IS8 are the same . The elements of s. or at least to enable meta-linguistic expressions to contain quoted fragments of the object language.3. 1-LISP. this the case in logic and traditional programming language semantics. 53-2. as we have already seen in detail for and as was pictured in into elements of S. The source domain in this case win be the structural field s. but we cannot quote s-exprcssions in lambda-calculus notation. The temptation is to use I-LISP lexical nolatioll. There is a minor difficulty arising from the &1Ct that it is the stluctural field over which our scn!antical functions should range. As we suggested in that chapter. rather than as concrete lexical items: S is not merely the abstract syntax of L. having to do with the form of our meta- language. I-Iowever if we were to proceed itl this way we . Structure vs. where there are shared tails. as is more commonly Furthennore. as for example in AF..iv. are not even type-identical with derivation trees for the grammar of the lexical notation. 4». as the very same token s"expression is both extensionally and intensionally used (53-22) 3. since s-expressiolls are 1101 /lola/iollal objects.c. YS where s is to range over s-cxpressions.F{"(CONS 'A '8)").. Notation The fourth comment has to do with the source domains of cI. Similarly. not the notational domain L. as lexical types).e. '1' maps elements of s not elements of into elements of L. It is straightforward to say AS. there is an entire independent semantical account e relating L notational expressions to clements of the structural field. maps format strucnlres onto a signified world.

In addition.. Semantic Rationalisation Procedural Reflection 159 would have to embed the entire theory of notational semantics 8 L within the accounts of . notatable .3. Although in our brief sketches in the present document we will not require systematic meta-linguistic reference to non. in other words. such as in cases where the lexical notation is ambiguous or incOlnplete. especially marked.. OUf solution - albeit a partial one LISP'S will be to use a single occurence of a double quote mark (by analogy with LISP internal quotation) own single occurence of a single quote mark to notate 1-LISP in the meta-language. TIle similarity between this mcta. will be taken We will note where this convention is insufficient.Unguistic protocol and tile backquote LISPS mechanisms in the we consider is striking: in both cases a quasi-quotational style is used. which would complicate matters tremendously. VX [[ x € {At B}] ::> [F(fG(!)l)]] Thus for example. 11 to quote those expressions in the nzeta-!anguage with schematic variables.. "X [[ x € {" A• "B}] :J [F ( r" (G Thus . and c). followed by italicised 1-LISP notation. occurrences of the variables in question within the scope of the quasi"quotation will be underlined. we will use Quinean "corner-quotes. "X.53-26) !) 1) J] is extensionally equivalent to [F("(G A)] A [F("(G 8)] (53-26) It follows that the previous convention would more properly be stated as follows: meta- linguistic expressions of the form r" ~l will be taken as abbreviatory for expressions of the form fO l ('!')1.. There are structural field elements for which no lexical notation exists. with those elcJncnts that are tertns from tile meta-language. the expression (53-23) is extensionally equivalent to [F('G(A)')] A [F('G(B)')] (53-24) In addition.s the lexical notation. it follows that the protocol just adopted is not fully general. The meta-linguistic phrase meta-linguistic abbreviation for 9 L ('X'). not from the quoted expression. as a structural device intended to express a designator of the as ~ s-expressions for which tllat lIolation . we will usc a combination of the corner quotes and the double quote mark convention just established in an obvious way.

If (G could equivalently be expressed. It: for example. then after processing x. [ ('{ F. Thus pronouns in natural languages. a more cumbersome but fully general device is always available. x is bound in E1 to (RPLACO X '(Y (3») Y and y to (1 2). (3)}. Semantic Rationalisation Procedural Reflection 160 structures.13 and the ensuing ability to deal with compositional semantics of sentences formed of open as wen as closed constituents. rather than using the pseudo-quotation operator just introduced. Tarski's introduction of the satisfaction relationship. If the compositional style of semantics just discussed can be viewed as a kind of "bottoln up" style of semantics - a regimen whereby the ingredients contribute to the meaning of the whole that embeds tJlcm . All of this wilt fail out of the semantics. '1nc advent of computational fonnalisms has made the potential contextual dependence of palticular structures more powcrfuf and more complex: mucll of the debate among various proposed variable scoping protocols. paradigmatically acquire what meaning they carry from the environment in which they are used. Since Frege's work in 188412 we have been exhorted to study the meaning of individual linguistic structures with this contextual relativity in mind. The compositional bent of sttrmuard scmantical accounts is ainled at least in part at making clear this pervasive contextual relativity. was a landmark step in formulating an explicit account of 110W an essentially cOlnpositional trcatlncnt could accomodatc and that made up a explain the interactions among ingredients . Y would be changed to the latter value. however.e. not (1 3). to illustrate such an example. we would have to use the notational style of 53-27. for examplc. x will be {RPlACD Y After a second processing of x.it is equally true that the structure of a composite whole affects the particular meanings of the ingredients. v. but will still be (1 2). using explicit CARS and CORS. Since those functions are encoded in the meta-language as the first and CAR second coordinates of fields (neither A B) ) ] nor CDR is a valid meta-linguistic function).3. given an appropriate as: (53-21) 3S [[ P( S)] 1\ [F 1 ( S ) G A [F 1 ( F ( S » • [ F1 ( f 2 ( f 2 ( S) » = "B] A [F Z( F2 ( F2 ( S ) » =" 1 2 "A] A :a " NIL ]) 1ltis is also relevant if there are side effects to the code itself. 3.bctwcn wholes and parts - particular fonnal system. and variables in fonnal systems. and argulDcnts for and . Context Relativity A fundamental fact about the use of language is that the semantical bearing of an expression is by and large a function of the context of its use.

Under one strategy - exemplified by the standard substitutional semantics for the A-calculus.the meta-linguistic operators re-arrange the ingredients of the fonnal symbols so as to reduce their contextual relativity. the meaning of a contextually relative expression is then described not in terms of another possible sentence. In such an approach to the A-calculus example just given.F(X»P]. and by substitutional semantical accounts of quantification in logic . where one A expect~ A to range over designators of all possible objects in the semantical domain. Actual applications are described in terms of· particular substitutions. a sentence "VX[P{X)]" is taken to be true just in case all sentences of the form r"p{~)"l are true.language. is intended to range over syntactic entities. we wilt refer to their bindings in the contextual environments. for example. Another strategy is to make the context of use into an explicit. referred to by tenns in the meta-. thus [(AX. can best be seen as having to do with the proper protocols for establishing powerful yet controlable contextualisation mechanisms.1ld designate the value of the function designated by the binding of F F(X) .i'l the environl11enl of ~se applied to the referent of x again as delemlilled by the binding ill the enVir01l11lellt of use. instead. and in the meta-circular processors and reflective models we embed in the dialects \ve study. the body expression of the i\-. F( X) wo '.tenn would not serve as a template for an indefinite number of substitution instances. for example. In a substitutional semantical account of universal quantification. As the reader will cxpec~ it is the latter strategy that we "'ill adop~ both in our meta-theoretic characterisations. but by making explicit reference to this theoretical posit It is under this approach that the notion of an environment emerges. F(X) is described in tenns of possible substitutions into the "x" position of the body expression of all possible argument expressions. in the A-. There are a variety of techniques available for treating this contextual relativity in a formal mcdel theory. therefore. reified entity. for example. for example. the tenn AX. we win again refer to the enviroluncnts in place at the . Semantic Rationalisation Procedural Reflection 161 against side effects and global identifiers. itself. is taken to signify F(P). Thus [( AX. often at the expense of a potentially infinite number of virtual expressions. In discussing the declarative semantics of atolns. Similarly.calculus. F(X) ) P] would signify was bl1und to whatever P in an environment in which x designated in the environment in which the whole was being examined.3. in discussing Aabstraction and procedure bodies.

for a variety of reasons. it turns out ~hat is. there is a natural tendency to think that the declarative import of an expression would depend. ill-founded. A reflective process. to the extent that it is contextually relative. clearly. rib is apparent correlation between two Gistinctions - on the course of the computation up procedural/declarative semantics. Semantic Rationalisation point of use. and static/dynamic context First. can itself generate program structures which have never been nalated. however. However the field (as manifested in the behaviour of CAR and CDR) can equally exert an effect as crucial as that of the environment (the binding of identifiers).3. after all. however. Procedural Reflection 162 There are three possible confusions we need to attend to regarding the use of this notion of environment A failure to recognise these distinctions can lead to substantial confusion later in the midst of technical details. the very notion of static environment is not without its problems: the Etructural field. there are two different ways in which a LISP expression can depend on the context of its use: it may depend on the state of the processor. the nlore discriminating terms will be employed when we want to refer to one or the other independently. including . it can as well alter the structural field. only on an environment defined by the static structure ~. for although a processor state consists of both an enVirOJlment and a continuation. but until the point of use. Second.might well depend not only on the static linguistic structures surrounding it.lJrrounding it as an expression. . Certainly our constant insistence on a discrimination bet'Ne~n lexical notation and structural field implies that no dependence on lexically enclosing notation can possibly serve as criterial in dctcnnining the semantical import of an expression (thus we avoid the term "lexical scoping" entirely). the latter theoretical posit affects what expressions are procedurally treate~ but does not itself directly influence the significance of a given expression. can itself be modified in the course of a computation. and it may depend on the state of the structural field in which it is embedded. We will by the term context refer to both the processor environment and the field that obtain at the point Df use. The former we model with the notion of an environment. rrhe procedural consequence. and only the structural field is available as a possible ground against which to define the notion of static context.at least so it seem at first blush . First.

In this way we have dynamically agreed to alter the undeniably declarative import we attribute to static expressions. however. we would merely be in the familiar situation of I-LISP. \vherc knowledge of the state of the processor at time of use is required in order to know the scmantical inlport of any given fragment There is no incoherence in a position requiring us to know tIle etynamic state of the processor before being able to determine the declarative import of a structure. It is unarguably· true that an additional benefit of this design choice is that the seman tical import of a structural field fragment is less dependent on the course of the computation. Nothing. First. In is 2-lISP and 3-lISP we will adopt a static variable scoping protocol: not because it nec~ssary in order to make sense of the notions of declarative designation. as a consequence. we have the question cf whether ? single . however. for ITIOst expressions reflection alters the program structure itself providing no subsequent the semantical type of various variables will be readily dctcmlinablc without having to dctenninc control flow.. we will define as static those seoping protocols that depend only on the state of the sllUctural field. it is not even completely clear to what we refer. immune to subsequent modification by sufficiently reflective manipuation. If we were to tnakc tIle other choice. Semantic Rationalisation Procedural Reflection 163 the embedding structure of a program fragment There is no way in which the context of any structural field element is irremediably frozen. whereas dynamic of the processor (once again the processor/field distinction bears the weight of subsequent theoretical cuts). will prevent us from taking the declarative import of symbols to depend on the siale protocols will depend by definition on the dynamic state of the computation. and have declarative import determined by dynamic context. The consequences of this insight are several.3. but beCc:1use it facilitates the use of a base language for higher order functionality. Related to this move of separating the distinction between declarative and procedural semantics from the question of tile context of usc. Suppose I say to you that for the next five minutes we will mutually agree that each numeral will designate the number one less than that which we have always assumed. in other words. without resort to mctastructural facilities. By static environment. Thus during that five minute time interval we could both agree to the sentence "3 times 3 equals 6". it is no less happy than having to know the surrounding conversation in order to detennine the truth of the Perry sentence "He's just lvroflgf".

that while it is only procedural import that affects the temporal aspect of a fragment's context. or whether they describe what will happen 10 the symbol in virtue of being processed in that context. it might ceem that since the first form in the scope of the BLOCK operator is entirety procedural in nature. A third and final preparatory comment needs to be Inade regarding these environments. In consequence. however. a procedural environment and a declarative environment. however. co~ceptuany VAR in the last line will still have a declarative designation of six. although we have a double semantics. to be handled independently throughout the meta-language characterisations). both procedural and declarative significance are thereby affecled.3. even if we accept an objectified environment as part of our ontological . counter to our purposes. The natural understanding of 53-28 above is that designed to handle. we will maintain only a single environment structure in our meta-theory. Declarative and procedural semantics differ on what they describe· about the expression with respect to that full context: whether they describe the designation of the expression in the context. in a controllable way. one of the demands of reflection will be to effect just such modifications to internal expressions. Semantic Rationalisation Procedural Reflection 164 environment can be used for both the declarative and procedural semantics. At first blush. Consider the following example I-lISP fragment: (53-28) (LET «VAR 6» (BLOCK (SETO VAR 7) VAR» The question is whether this code designates the number six or the l1umber seven. Not only is this by far the simplest approach (any other protocol would require two different objects. (SETQ VAR 7) fann changes VAR so that it henceforth (within the scope in which it is bound) designates 7. It should be observed. Another way to put the same point is this: the context of use for all expressions includes both their structural and their temporal location. There are a variety of ways in which we as external theorists can treat context-relativity. as the foregoing discussions imply: there is nothing incoherent about allowing SETQ to have a dynamic effect on the declarative import of subsequently interpreted structures. It is this intuition that our approach is TIluS our semantics is not an attempt to mitigate against practices which actually alter the meaning of extant structure: indeed. it is also the only one that coheres with intuitive practice. This is.

that function (if it could be fonnalised). This.e. vallie is not the function itself - . ill that praglnatic and structural context. as we have pointed out before. The basic insight throughout the semantica1 treatment of LISP atoms is that an atom's designation depends on the context of evaluation. so that the Ineaning (we will use the terms "meaning" and "significance" to refer to what such accounts specify of an expression. 'rhis distinction is maintained by the mathclnatical vocabulary. is that the primary notions of value (and later. In a traditional programming language semantics. if carefully used. and its contents change over the course of the computation. to Bob structural An analogous situation holds regarding pronouns in natural language: in the sentence "Bob said he would bring the ice-crean'" the pronoun "he" refers it docs not refer to a function from pragmatic and structural contexts onto contcx~ objects. are similarly outside the contexts of their use. and procedural consequence) of an atom (in general. the cost in ontological comnlitment is substantive. 111is technique of taking the meaning of an expression to be a corriplex function that incorporates the environment and state of the machine in such a way as to enable the complete articulation of the context-relativity and potential side-effects of an expression is extremely powerful. of an identifier) would be said to be a function from environments to values. We could say that an atom has a value.3. There are two ways in which we can put this preciset:!. and to say that in a given environment an atom has a particular value. the pronoun refers. Rather. This way of speaking similar to how one might speak of the value cell of an identifier in an implementation: i. value. Though its formal embodiment would seem no more serious than to affect the order of arguments to a multi"argument function. Wilat it should not lead us to tllink. there is a value cell. Happier for our purposes is to make the entire notion of having a value itself dependent on environment. The Inealling of a variable x is taken to be a function from environments to values. of reference and of sbnplification). the function takes the atom to different values. however. Semantic Rationalisation Procedural Reflection 165 repertoire.of the space of all possible values abstracted over all possible contexts. and mathematically compact. We are using the function if to relate expressions to their values: the claim. applied in a given pragmatic and would tell you to what object. thus the rather. the interpretation function (we will caU it r) is always kept over-arching. is tllat 'It is environment-relalive. therefore. but that that value changes in dif)erent contexls.. however. is an unnecessary objectification . to be distinguished from what we are calling desigllation.

OUf semantical functions. Semantic Rationalisation Procedural Reflection 166 depending on environment The confusion arises from casual use of the natural English idiom in saying that the referent of an identifier is a "function of the environment": a phrase that is ambiguous. adequate to capture what we intuitively take to be the notion of "method or "algorithm". (By such usage. in quantificational logic. to refer to the clement of its range ~or a given argument Furthermore. we have been lax in our use of the terms "evaluation" and "value". until then we will avoid the former term. it is notable that our initial analysis is of applicative calculi ill general: we will want to talk.e. what the referent of an identifier is. is environment-relative.t succumbs to format.i we will examine this vocabulary with some care. etc. that we take to designate a function. We will also reserve tile tenn "function" for the nlathematical abstraction.3. First. the environment component will be used by identifiers (atoms). therefore. will be of the folJowing type: ENVS X FIELDS ENVS X FIELDS + : CC -» : CC 1 J -to -to CS CS ~ D -+ s 11 CAR 11 and CDR (S3-29) The field component. especially since we would like these tenns to support the design of new calculi satisfying some new mandates. On one reading. on the other. however. it is clear. In order to avoid the ambiguity. We therefore cannot afford to define our analytic tCffilS (like binding or application) with respect to any single calculus (such as for example the x-calculus).'. a few additional comments should be made. in standard mathematics. and will use "value" only with reference to a mathematical function. will be used only by the and PROP procedures. like many in this . for example. assumed to comprise an infinite set of ordered pairs in the usual fashion. By procedure we will refer to a fragment of the stlllctl1ral field. computational treatment. In section 3.entificr has a referent that is a function whose source domain is the environment. This is yet another point. and th(l. we do not intend to convey the impression that a language-free Cl and therefore processor independent - notion of procedure should not be devised. it means that an id.e. about how bound variables arc trcat~d in tile "'-calculus. Terminology and Standard Models While we are on the subject of the careful use of tenninology.5. since we want to take the latter reading. . vi. in IISP 1. we will avoid the use of this apparently hannlcss phrase. 3.

in other words. there is a standard model one of a possibly infinite set of objects that everyone agrees to be the standard or default mapping of the atomic tenns onto clements of an accepted semantic domain. In particular. for example. interchangeably. they arc not first-class bearers of semantic weight. 'rhus for elementary arithmetic. to such results as the Lowcnhcim-Skolcm theorem) it is possible to show that any given model theoretic characterisation of a domain will adtnit of an infinite number of different models. This fact is recognised in standard semantics. the standard model for the signs 1. where the question of the identity of a function in intension skirted. Furthennorc (by referring. as explained in the previous section. itself in need of interpretation. for 0. morc literally. and that the symbol "'I'" denotes the procedural processing function. indefinitely many other interpretations for meta-structural terms. The model theory typically makes explicit what the designation of composite expressions is. and so forth) is the numbers as we know them. for example. in this vein.3.) lHarginally There is another apparently terminological issue.2. 'I1lis fact arises from the fact that if the model theory is admitted to be a model theory for a given set of syntactic expressions. that hides some substantive issues regarding causal theories of reference. in tl)e sense that the relationship between sign and signified inheres not in the sign or in the object signified. Model theories arc not causally grounded. to refer to the object that a sign is taken have said. It is crucial to realise that the model theory cannot itself specify the interpretation of a formalism. however. to point to or name. We We have used the tenns 6 ndesignation" and "denotation". 5(5(0». Semantic Rationalisation Procedural Reflection i~ 167 dissertation. significance is attributed. about possible models for meta- linguistic expressions. but rather in the interpreter that understands the significance relationship. and so forth (Of. given a basic interpretation function that takes the atomic icrms onto their designata. and it is effectively admitted by the analysis that an interpreter may establish one or more of a variety of basic Inodels for the signs in question. t11en . although other possible models are often explored. for example. There is a curious point to be made here. S(O). that the numeral designates the number All such five. because the model theory is merely a linguistic artefact. all satisfying the specitled constraints. Typically. the standard model for mela·slructural expressions is in fact specifiable by tile model theory there arc not.

There are a variety of minor issues. is as uncollvincing as (ATOM tAl. since ex hypothesi Y is a term that refers to 52. They remain detached expressions.no for LISt' structures carrying assumption by users. there is still no way to sayall)'lhing! No in any way that cmbod~cs expression can be written down with any conviction - a claim. vii. In sum. but that fact must be determined from the outside. Suppose further than the meta-language posits that 51 designates 52' by asserting 4l(X) = Y. Suppose in particular that some tenn x in the meta-language is taken to Y denote syntactic expression 51 in the object language. and no room in the semantics - . there is no l1:1cchanism . But adding this expression to the field doesn't say that (ATOM I is an atom. Declarative . But t"tere is a much more serious matter that field. no other interpretation is possible. This. tllat is to say. 3. it too could be tru~~ or false (we could equally well hav~ (EQUAL T (ATOM '(A B e»).e.. we A say of atom A that it is an atom. rather. of course.')emantics and Asserlional Force There is a slight tendency to suppose that the suggestion that we accord LISP structures declarative semantics amounts to a suggestion that LISP be viewed as a full declarative) descriptive language.11 force. (A B C». however. Even with a full declarative semantics erected on the 2-LISP LIS? and 3-LISP. Suppose. such as that the language we are describing has' variables but no quantification: such a LISP would lack. for example. and that we wish to Rather. is false. 'Nould have to use (ATOM' A). is far from the case. and that some tenn denotes syntactic expression 52. for t. Nor can that fact about the truth of (EQUAL T (A'.3.) not accorded meta-syntactic status by that model theory. A docs not even refer to the correct entity: it refers to whatever designates. applies only to those tenl'L. since the problem recurses. The single argument in tile redex (ATOM AJ. of the sort we will depend on in LISP distinguishes a full fledged descriptive langua~e from LISP: that of asserlioll. Then it follows that 51 must in fact designate 52. but without any force of saying anything. Semantic Rationalisation it is perforce admitted to contain a nl~:rlbef Procedural Reflection 168 of terms that designate those syntactic expressions. with potentially attributed designation.OM 'A» (ATOM I A) itself be stated. in ou'1er words. certain kinds of expressive power (it would be what is called algebraic). that variable x designates some atom A. such a fragment could be either true or false.xarnple. The freedom of inte11lretation inherent in the model theory. and (ATOM' A) is true.

a reconstruction . rather. Semantic Rationalisation ProcedurmReflection 169 assertional force~ A full reflective cal!:ulus addition to ttle n~'1le one based on \~hich any aIt integrated descriptive 1a!!~~Llage - '''QuId have to differ in this crucial respect LISP. t~or can one imagine this change as an To add assertional force to LIsp-like LISP there is no sense in resultant fonnalism could imaginably merit IISP any longer. structures are best understood in terms of a declarative semaIi. for this is a radical cha~lge.tics is. structures would be to desIgn a fundamentally new architecture: uur claim that of what we claim to be present practice.3.

and if involves in general. t since the latter function is more familiar in computational contexts (the latter.3. We will at times like this dip into mathematical characterisations in order to convey a feel for how they would go. . SOlne stemming froln peculiarities of I-LISP'S design. to no particular point. with suggestions as to ho\v complete proofs of the main results could be based on such a fonnulation. is by way of prepara. to do so is a substantial task. and procedural semantics for in section 3.=ertain particular points. and to illustrate .yin be presented in two passes. Semantic Rationalisation Procedural Reflection 170 J.tion for our primary investigation of reflection.d.c we will show how this approached is doomed for a variety of reasons. the discussion was not particutarised to a particular dialect. we will look rather independently at the natural declarative I-lISP. how an accurate account of I-LISP'S semantics would require over-riding a great many natural assumptions. and a . First. OUf goals instead arc to convince the reader tllat such a projcct is at least approximately possible. In that section we will present a morc complex. In the first. section. in particular. Second. Such fonnalisation as we do take up. In addition. Nonetheless we will not present a full mathematical semantics for I-LISP. for several reasons. but nlore adequate. for example is the function computed by the meta-circular processor). revision of the two scmantical functions. In the present section we will begin to sketch those semantical functions for I-LISP. to show what would be involved in doing the mathematics. in order to encode the semantically anolnolous behaviour of 1-lISP'S EVAl within the c1J-'I' framework. it is instructive to denlonstrate the formal structure of (). The Semantics of 1-LIS P: First Attempt The previous sections have examined what the fonnulatjon of. it must be kept in mind. I-LISP is semantically rather inelegant. . occupying the pr~scn( . We will show. and some for deep reasons about the temporal aspects of any structure's context of usc. full characterisation of it in our declarative terms would be messy. in contrast with it. well beyond the scope of this dissertation: this entire semantical analysis. and to make self-evident the truth of our main scmantical result: that evaluation conflatcs expression sirnplification with tenn de- referencing.

3. although it inherits no designation from that role. In 2. E E ENV.' Declarative Semanlics(<<-) Procedural Reflection 171 We start simply. If another noun phrase was substituted for "John". of course: it is among other things an un-interpreted NIL syntactic marker used as part of the encoding of lists within pairs.typically called an of thi~ argu111ellt." "he" designat~s . () is a function not only of expressions but of fields and environments. As mentioned above. for these two simple cases. up presently. The next simplest class of structural entities are the rest of the atoms. the pronoun "he" \vould similarly designate that n~w te. in the sentence "After John capsized he swarn to shore. which. white our struclural characterisation made T and NIL atoms (NIL is both an atom and a list).and 3-LISP we will correct this discrepancy. property lists. f E FIELDS [cI»EF(N) = M(N)] [cfJEF(B) (53-30) (53-31) VB € BOOLEANS. is used for other purposes. which we will take . such context-rclativisation is ignored: VN € NUMERALS. but it is true in the meta-circular processors we demonstrated in implementations. This is false by the defmition given in the last chapter. our procedural taxonomies exclude it from the set of identifiers. '-fhe basic intuition governing names and bound variables is this: they designate the same referent as was designated by sonle other expression in another environment . E € ENV. In other words. pronoun "he" refers to the same entity as the antececient noun phrase "John". the two atoms T and NIL clearly signify truth and falsity. is also the empty sequence designator. however. Semantic Rationalisation 3. shore. F E FIELDS = T(B)] are available in I-LISP It follows from these equations that neither regular atoms - T nor NIL for usc as for binding. with the numerals.m's referent 111us in the sentence "After the ragalnu!fin capsized he swaIn to the referent of tile phrase "the ragamuffin". and it is true of most standard class of atoms. and so forth. which designate numbers NIL of this there can hardly be any doubt In addition. from an informal point of view. Examples the co-designative protocol can b~ found in both formal systems and in natural II language. having a syntactic class of two boolean constants separate from the LISP chapter 2. For example.d. are used as context-relative names.

(body»E). we will adopt the theoretical posit of an environment as an explanatory mechanism with which to explain this contextual relativisauol.3. for example. however. giving us some confidence) that. in the environments established by the varia~lc applications just illustrated. between bound occurcnccs of a formal name and some external expression taken up from the context.er is taken to be the argument expression itself: or the referent of the argument expression (by argument we refer to the contextually determined expression with which tile variable is assumed to be co-designative). 11lis question is indepcJldent of the clear fact (this is tnlc in mathematics and logic as well.t:i). semantically. lbc problem. acquires the designation of that argument. in contextually dependent ways. or to a desig1lator of that number. For example. after reduction (by substitution or environment E. free occurences of x in <body> are assumed.v. We will not. the x is bound to the actual number four. no notion of environment is required: instead a full substitutional protocol is adopted in which the contextual term is substituted for the appropriate occurrences of the variable WitJliu the expression in question. :)f variable designations. adopt a notion of value with respect to variables. How this intuition is embodied in the forntal treatment is open to a variety of alternatives: in the A-calculus. that the variable x is intended in each case to designate the number four. however. relative analysis) to designate the referent of Thus the ground intuition is that the use of <:ontext-relative naming schemes provides a mechanism for establishing co-designation. in the following two expressions. «LAMBDA (X) (+ XI» «LAMBDA (X) (+ X 1» 4) (+ (53-32) 2 2» We will.c. variable binding is co-referential in the sense that the variable. For compatibility with our theoretical reconstructions of dynamic seoping protocols. need to decide what sort of entity the environment establisllCS as the lJinding of a variable. because of the use/mcntil)n confusions that attend common use of that term (see section 3. there can be no doubt. is whether the value of a variable or formal paramet. TIle question is whether. as we discussed in section 3. however. in a word. Semantic Rationalisation Procedural Reflection 172 Similarly in the lambda calculus: in an expreSSiOJl of the fonn «AX. in virtue of being bound to an argument expression. and in order to establish close alignment between our metatheoretical accounts and our subsequent reflective models. . in the contexts in which (+ Xl) has its intended nleaning.

that the expression to which variable is bound is not itself nonnally thought to be preserved in the binding.. not to the numeral 11 This is not a problem in the meta-language. S 1 in 53-34): -to 'VA E ATONS. In fact has the odd consequence that in any environment the designation of tIle binding of a variable (not what the variable is bound to.e. No environment. as we will throughout. not 110W or (+ 2 2) in the examples in 53-34 53-32 above).tcr-intuitive. LISP structure we would '-rhus if x were bound tD the then a sequence of two designators.i.e. ».3. not in general be s-expressions. This is exactly the extensional point just made: if we adopt we would say that x was bound to the flU111ber four. that the only natural 4 expression to which the variable should be bound is the one occuring in context when the binding takes place (i. in other words. the environment designator might consist of the tuple 'x (' x. The two candidate equations are these (assuming.we have to make one decision or the other. Semantic Rationalisation Procedural Reflection 173 If we are to write down fit for atoms . The only difficulty with this counter suggestion is that those designators might themselves be environment relative: if x were bound to fOUf. and furthennorc. 1-LISP variables will 4 ". It would seem.. \vould serve as the environment structure. arguing for the second alternative that bindings are expressions) is the fact that under the first alternative the bindings of 53-33. This would seem wildly Co'}. that environments arc functions from atoms to bindings . that E : C ATOllS D 1 in 53-33 and that E : C ATONS -. the only likely want is a structural designator of an environment.. but what entity is the referent of the expression that the variable is bound to) is potentially a function of the environ. E E ENV. F E FIELDS VA € ATOMS. as we . F E FIELDS [cI»EF(A) :I E(A)] (53-33) [«I>EF(A) = cIlEF(E(A»] (53-33 - (53-34) An apparent argument for the first option that bindings are designations) is the fact that variable binding as normally conceived is extensional. and this is certainly binding is presumed to work. (53-34 - On the other hand.LISP'S variables . can be a LISP object.. E E ENV. A possiolc reply to ulis last objection is that we would not expect environments tlzelnselves to consist of pairs of s-expressions: rather. one designating x and the other designating four. if the second proposal were adopted. and ([VAL X) will not be able to return x's binding.ment ill which the variable is itself used or looked up (this is because the outer term of 53-34 is tI>Ef( . but it makes for odd consequences for the metacircular processor (and later for reflective machinations). nunlber fOUf..

in other words. against the objection that binding. is coherent. discussion of the proper designation ([VAL X) brings to the fore the question of whether the declarative and procedural environments can be considered to be the same. The second alternative.c. by which bindings are designative. so that instead of the designation of a variablc being fIlEF(E(A»). ([VAL X) EVAL is IISP'S it: even if EVAl is in declaratively extensional. v of a variable. is a natural designator of the atom x) and the expression two. Furthermore. It might scenl that the environment could "record" the context in which tI1C binding took place. cannot be its binding. we would expect other \vords. should be w~ to designate the procedural consequence cIlE F( " (EVAL X). dcsignational» alternative. Semantic Rationalisation Procedural Reflection (+ 114 will see. it would be . we would have to choose the second of the two alternatives. y Y). on this reading. then. In sum. (EVAl X) cannot return x's binding we have (EVAL X) the following rejoinder: there is a mistake in the intuition that should return x's if binding is taken to be desigllQtional. i'EF(tI»EF(" x». not ~EF(tI>EF(" x». This last find ourselves in the thick of issue discussed in section 3. rather than simply deferring it onto another context. by which bindings arc co-designative. of the referent of x. the first option. 2. in which the context relativity of both declarative and procedural import come into tension. not the declarative import of the referent of x. It is unclear what expression the binding should be: the contextually relative argument expression Incans that the semantics of the binding is potentially a function cf' the enVirOl1lTICnt at the point where the variable was bound. although it is affected by 1. If there is any hope of letting a single theoretical entity serve a double role as both procedural and declarative context.3. This would seem an unhappy pratice. if Y designates It seems not unreasonable to require that environments encode the full context-relativity of a variable's binding. LISP tw~ complications: encodings of environments may use context-relative designators of the bindings. It is clear - since 'I' maps structures onto structures - that from a procedural point 0/ view the environment cannot be the first. has in contrast the following apparent difficulty: 1. Bindings so construed Catlnot be taken to be the procedural consequence of variables.v.

in the axiomatisation of the semantics. and so forth. designational.3. except more complexly formulated. Nonetheless. Any choice of binding satisfying the equations will be accepted as valid. thus for example a regimen that identified a particular special symbol. however. when we tum to object on semantical grounds. However it would be premature to adopt this suggestion yet: we haven't yet defined normal-form designators. In fact there is a third option: variables could be taken to be bound to co· designative expressions. Procedural Reflection 175 where Ee is the environment at the point of binding. the declarative import of the binding. but not to the expression occuring in the binding context. alternative. Thus we are adopting: [~EF(A) VA E ATOMS.c. one per object in the semantical domain. the mandate adopted in 3. from the point of view of the declarative semantics. \vould suffice. This. hence the additional context arguments to ell in S3-34 are provably ignored (being required only to Thus in those satisfy the category requricments of the meta-theoretic characterisation). and to make this suggestion work we have to prove that they arc environment independent. F E FIELDS = (flEF(E(A})] (53-35) . Semantic Rationalisation fIlEeFe(E(A». this requirement alone rejects the first. dialects we will adopt the second equation without difficulty. E E ENV.v requires that a single theoretical posit serve as bOtll declarative and procedural environment. we will defend that dialect's choice of such an We will therefore proceed under the second equation. and we will merely dc~larative assert. WIlen we get to the I-LISP procedural semantics we willtnakc plain what object is in fact bound 2-LISP to each variable. because in those dialects all are bound instead to a nonnal-fonn expression having the same referent as that of the primary argument nannal-fonn designators are context-independent (in terms of declarative designation). standard LISPS In no such expression presents itself: but in 2-LISP we will posit that variables This avoids the trouble just discussed. and Fe the state of the field. is an empty proposal: it is effectively indistinguishable in effect from the first. What we will adopt is the following rather mixed protocol: we will assume that I-LISP variables are bound to sOlne expression. by which environments are taken in the meta-language to be functions from variables to expressions co-designative with the argument expressions.

. There are two further categories of symbol to look at. is this: a list will be taken to designate the value of the function designated by its first element applied to the arguments designated by its remaining elements: 'IS E S..iv.. at least. an example will illustrate..1-LISP the' standard sense. (COR{S) ) . Since all primitive atoms are bound to procedures (i. F 1 CAR is not a function in the meta-language (recaU that by F. Sit)' (S3-36) where by S :: r" (SI 52 S3 .. [ E ENV. rather than those used as enumerators).. Because is closer in spirit to the later dialects we will deal i-LISP. a list (those. we will tum to pairs next There is a choice here: as noted in the previous chapter..7-LISP. (F 2 (S» .. used to or . Sk]] ») " (53-37) or more prcci3cly.. and because it is more general than we will consider it Pairs. of course. = Sk]] (53-38) ») luis is just the sort of semantical equation for applications one would expc:t in any semantical treatment.c.. and the atoms in general..· are not quite the right category to examine: we 'want instead to focus on lists.. The simplest suggestion for the designation . since fields arc of type [CARS x F): CDRS X is the CAR relationship of field [[ Fi(S) = S1 ] A [F 1 (F 2 (S» = S2] A . and + is bound to a designator of the addition function. signify function applications.. from 1. and the procedur~s). before turning to cOlnpositional q~cstions: the bindings of the primitive atoms in the initial environment. ep EF( Sk) >)] if S = r" (51 52 S3 .. we usc a single double quote mark and an italic .: ( S) = ep EF( S1) « «l» EF( S2)... \Vc would have the following (as discussed in section 3. designation of pajrs. the numerals.. 1\ [F 1 (F 2 (F 2 . tile I-LISP differs substantially latter evaluating the frrst position in a function application designator in 1.. since general mean the PROPS].e. all twenty-nine atoms that have bindings in the initial context are bound to and since the scmantical import of procedures is best revealed in terms of their participation in the encoding of "function applications". Semantic Rationalisation Procedural Reflection 176 We have discussed the booleans T and NIL. 4JEF( S3)' . Sk)l we will in general mean: [[ CAR(S) = 51] A [CAR(COR(S» = 52] A . Suppose we inquire about the designation of the expression (+ 3 Y) in an environment Eo in which Y is bound to a designator of the number four. F E FIELDS [ 4» E.3. A [CAR(CDR( CDR . Ft we in i' th element of sequence thus. with..

section 3. We will explore the language of functions and applications more fully in section 3. example.. 4'E oFo(E o("Y»] = +[3. for the time being we will call lists of this variety (i. that the expression designates an abstract number.f. pai:s are not themselves function applications either. not the numeral which has not once been mentioned in this analysis. J4ists.AF . all non-italicised items. Note that in 53-39 we expanded the composit~ term in the first line under a "substitution semantics" .F{S3)' cl»EF(St)])EoF o][" (+ 3 V)] = [(AF.i we \vill replace the tenn Although we are not dealing in this dissertation with notions of intension. therefore we cannot strictly say that it designates an application of the addition function to 3 and Y. are 3 V)~ (53-39) = 4»E oFo("+) [C))E oFo("3). Only when we describe the procedural treatment v of ( + 3 4) will the numeral 7 enter into the analysis. cannot be said to designate function applications. Semantic Rationalisation Procedural Reflection n+" 177 font to mention object-level structures.i. since the of the list. The importance of 53-39 is. tIlEoFo("Y)] = 4»E oFo( Eo( "+» [C)EoF o(" 3) flJEoF o( = +[N("3). ettE oFo(S3)' .4] t 4»EF(Sl) [tI»EF(S2)' fIlI:. in other words.ion (+ 3 Y) designates seven in an environment in which Y is bound to four.AS Y)] :I 1 of~.3. still It is to be noted.AS cIlE oF(Sl) [~EoF(S2)' tl»E oF(S3). apart from any notion of how it is to be treated by the processor. what we would ultimately like to say is that the intension of a procedure application is a function application. in line with our general conception La indicate that the express. ~EoFo(Sk)]) ["(+ 3 V)] II = [(AE. we are using an extended version of the lambda calculus with identifiers as our meta-language. The second comment is this: As is clear from the examples. The first is tcnninological: the tenn (+ designates seven. for 7. lists whose significance is explained in terms of the application of the de~ignation of their first element to the argtlments encoded in the rest of the list) procedure h~ applications. not a function. such as terms in the meta-language): ~EoFo("(+ and "7". In deference to such a wish. 4»E oF(St)])F ol ["(+ 3 YJ] = (AS fl'EoFo(St) [tIlE oFo(S2). although after the discussion "application" with "reduction".e..f. and in what must for now remain a rather informal usage. the extension is the value of the function applied to the arguments.. for example) is a function designator. 3 Y) Two comments in passing. CAR On the other hand. we will sometimes say that lists signify function applications.

we need to know the context it appears in . but this is .drift away from our lay understanding. but also that 3 tllat 4JE F( " (PLUS 3 4J) (IE F( " (3 4) designated the fOUf. but to do so is would be to begin to let 4. There may be other reasons for "evaluating" the arguments to a procedure in fact there are several.. But tails of lists in would imply not only I-LISP are themselves lists. a semantic import conveyed by the following scmantical equation: vs E S. we ~ust acknowledge an inconsistency in the account we have given: we have said that the designation of lists is the value of the fitDction designated by the first element applied to the designations of the remaining elements. value of the function designated by the numeral there is no such value: the numeral a function at all. The resulting expression is of course still extensional in that position into which Eo was substituted..whatever that means . a strict reading of our analysis = 7. however.tc apptiications to be extensional. made explicit in section 1. We could try to complicate our definition of ~ so as to restrict its application to lists which really lvere intended to signify function applications. 111esc troubles are merely evidence of the lack of type-type correspondence. ~EF(Sk» ] if S = r"(Sl S2 53 . It should be clear from the fact that our meta-language is well- fonned that there is no need for an evaluation process to de-reference the argument. it designates a sequence of integers. The expression not a functional tcrm to us.fJ. as LISP'S EVAL is sometimes thought to do. of course..or the contexts. F E Fl£LDS (<lJEF(S) :: <cIJEF(Sl)' 4>Ef(S2)' «I>Ef(Sa) . E E ENV. as we will see .. We could define 3 el) applied to the number S3-30) However designates (by to take (3 4) the number three.the tenn Eo before evaluating the body of the procedure. is not one of them.but a need to de-reference. which is not (3 4) into 1. as this example shows. In point of fact. or into an error. and therefore we should not let our semantical characterisation treat it as one.3. To return to the main discussion. however. 1LISP of course would evaluate . Semantic Rationalisation regime: occurences of the bound variable E w~re Procedural Reflection 178 replaced by the term Eo.. since a given s-cxpression call occur as the ingredient in more than one larger expression. entails violating recursive compositionality of the selnantics.. Such a move. Sk)l (S3-40) In order to know when a list is intended to designate a sequence. which is highly inelegant in a formal system. between the syntactic categorization of the structural field S and its semantical interpretation. in order for composj.

not the category of the referent.and 3-LISP. given the semantics of T and NIL.3. however.will receive special attention later. of these we have already and and and CONO) 'fhree OtllCrs (QUOTE t LAMBDA.) 4»E oFo{" CAR) cflEoF c(" CDR) tf»EoF 0(" PRDP) 4lE oFo( n EQ) 4lE oFo{"+) «I»EoFo{" -) = = :: FOI F0 2 Fo3 A(St . but rather the category into which the semantical function c) sorts syntactic entities requirement. we can LISP look at some of the standard extensional primitives. We can never require that it be possible to tell syntactically what every expression's seman tical imporl is: for all formalisnls of any substantial power such a question is intractable. READ. Semantic Rationalisation Procedural Reflection 179 of course impossible: intention is not sonlcthing a formally defined procedure can unravel.5 2 > + since F = (CAR o• CDR o• PROP o> simi 1arly s im. Of the remaining twelve. so will be discussed later. EVAL importance in our overall drive for reflection. since rf /\ Q1 is said to be true just is case p is true and Q is true. NUMBfRP) «PE oFo{ " ATOM) = • = I = = AS _ [S € INTEGERS] AS _ [5 E ATOMS] Five of these functions are effectively absorbed in our meta-Iangauge. The consequence is not minor: for i-LISP it is in general impossible to tell syntactically what the semantic type of an s-expression is (or even whether it bears semantic weight). However requiring that structures wear their semantic category . this is an inelegance we will correct in 2. 1arly [51 (53-41) = 52] c1tE oFo{n_) c1JE oFo{ " /) cIlE oFo{ . (SET. I-LISP. ten would have the following designations in the initial environment Eo and the initial field Fo. which is motivating all of this semantical analysis . Finally.(Note that we use 4>E oFo( "X) rather than the equivalent but more cumbersome «I>EoFo( EoC" X) ). before revising it in order to handle them. l~his is analogous to the . in the sense that tlle same concept is used in the meta-language as is being explained in the object language. There are twenty-three distinguished atoms in .. The foregoing extensional reading of procedure applications will fail when we get to LISP'S so"called ~!Jecial forms. thus these semantical characterisations are not Hlluninating. is typically absorbed in a first-order semantics. . DEFINE. will be dealt with are significant of particularly separately in a moment. for example. and four more PRINT) APPLY - primarily procedurally. )n their sleeve is neitllcr an impossible nor an unreasonable Again. ([hough the term is ours. the practice is not: conjunction.

and as illustrated in the example in 53-39. not to actually layout a valid semantics. are simply simple type predicates liesignating truth or falsity depending on the designations of their argu!11ents. Two others Finally. but 1- since our goal is to indicate a style of semantical analysis. Semantic Rationalisation Procedural Reflection 180 use of the term "reflection" in iogicts reflection principles. CDR. .3. as that task is perfonned in general by the semantics of applications. Note that none of these procedures need to "de-reference'" their arguments. as stated in 53-36.) Axioms constraining them IISP cou~d of course be formulated. we will simply assume that these functions are clearly defined. and PROP) are simply the relationships extracted from the FIELD argument to <1'. these in fact are the only procedures that access that crucial constituent in describing the field. three (CAR. although we of course must avoid that term in this context.

so that they themselves can de- reference their arguments when appropriate. to use I~JTERlISP terminology. We would also have to redefine these functions to accept the environments as an explicit argument... and COND. Sk)l .cflE oFo("(+ X 1»]] 53-36 (53-43) [(tIJEoFo("LAMBDA» A candidate solution would be to rework "t so as not to de-reference its arguments. and CAR. E E ENVS. There are a variety of such forms. represented by the first meta-circular I-LISP interpreter we demonstrated in chapter 2. for the present we will call them intensional procedures). then to redefine the functions designated by the atoms move explicitly. and f): (53-44) VS E S. E... and first layout a protocol for dealing with intensional procedures in general. In particular: (S3-4Z) [~EoFo("(QUOTE ¢ HELLO)] '·QUOTE» [fI»EoF 0(" HELLO)]] [~EoFo("(LAMBDA * (X) (+ X 1)))] [4)E oFo("(X». and to make explicit what applications fanned in terms of them designate. [(~EoF o( is an NlAMBDA). CDR. ~AMBDA. which we adopted in our second meta-circular interpreter. only those we explicitly indicate as extensional will be so. Since this is both cleaner and will put us in a better position to handle subsequent developments. is to consider a certain number of atoms as specially marked..e. Semantic Rationalisation Procedural Reflection 181 We look next at what in the community are sometimes called special fonns: lists whose first element designates something other than an extensional function. is to identify a special class of procedures (called MACLISP FEXPRS in and NLAMBOAS in INTERlISP - in 3-lISP they will be subsumed by the general class of reflective procedures. F E FIELDS [fI»EF(S) = [(4)Ef(Sl) )EF] <52' 53' . The first. and two ways in which we could proceed to analyse them. do not satisfy the mandate laid down in claiming that tllcir designation is the value of the function designated LAMBDA by the first element of the list applied to the designations of the remaining clemcnt4) (i. Sk>] if S = r" (SI 52 53 . and so forth.3. The second. and then subsequently define the particular semantics of the three primitive intensional procedures TIlC QUOTE. identifying the category restrictions on 1l1US we would have (we will cease explicitly S. we will adopt this latter stance.. such as (QUOTE IIEllO) or (LAMBDA (X) (+ X 1». problem 53-36 \VitlI intension:}} procedures is of course that applications formed in temlS of tllcm. to make this Then applications in general will not be extensional.

Y/ould have the following designation in the illitial environment: tl'EoFo{E o{"+» = AE .quire that tltEoF oC QUOTE) It = "X: = AE . • [·(~EF(X).X] :J IT ~EF(" (QUOTE (THIS A LIST))} = [4»EF("QUDTE)EF] ("(THIS IS A LISf) !. AF.AF . Y) (53-46) = +(c)E oFo("3).Y AE. tltEoF(Y»)Fol ("3. we could First we take the atom QUOTE.AX .AF. c1tEf (" (QUOTE X) l which clearly designates the name of its argumc&t.AX. we can show how the list VE (THIS IS . Y +(~EF(X). tty) = [(AE. to define some intensional procedures. designates h.AF.AX. AE.~X.~ple. under this approach.AF. 4) =7 In an analogous fashion we could redefine the other primitives of 53-41: = t)EOF o( "CAR) fIlEoF 0(" CDR) cIlE oFDC" PROP) = 4»E oFo( " EQ) cl»EoF o{" -) cItEoF o{" .AF . ~EF(Y»] AE.AX. ny) :: [(AF. J = [(XE.AX.X] ("(THIS IS A LIST» : The context is thrown away = "( THI 5 IS A LIS T) ]] .AX .AF. AE.Y +[fIlEF(X).AF.AF.Y • [-(~EF(X). . cl»EF{Y)] (53-46) That this would be correct is shown by redoing the example of 53-39: t)EoF o("(+ 3 V)~ :: [{cIlE oFo("+»E oFol ("3.. F E FIELDS [l 4JEF( "QUOTE) = AE .AF. AE.Y [Fl(~fF(X»] (53-47) [F2(~EF{X»] [F3(~EF(X»] [~EF(X) = ~EF(Y)] ~EF(Y»] AE.X)EF] ("(THIS IS A LIST) = [(AF. .X)F] ("(THIS IS A LIST) [AX.AX. c)EQFOC"Y» = +( 3. [/(~EF(X).Y . Y + Cc) Eo f 0 ( x) t filE 0 f 0 ( Y) )] (" 3 .AX.. [~EF(X) E ATONS] beg~"l Given this change in approach.AX .AX. C)EF(Y»)Eorol ("3. WEoF o( Eo(" Y») = +(3.\ LIST). ~EFCY»] AE. for all expressions x we will rt.AX.AX. Semantic Rationalisation Procedural Reflection As an eXCh. AF •AX.3.AF. x tile structure (QUOTE (TUIS IS A LIST» (53-48) Given this equation. 182 the OUf primitive functions would have to 1:'e redefined appropriatelY:a atom +.ill envirunmcnts in which QUOTE has this meaning: (53-49) E ENVS.AF. In other words.) 4»E oFo("/) = ~EoF o( "NUMBERP) = epEofoC" ATOM) AE.AX • [cI»EF(X) E InTEGERS] AE..AF .Y +(fIlEoF(X). "Y) = [AX..AX. "Y» = [cIlEoFo{Eo{"+»EoFol ("3.

would be to define a meta-linguistic predicate. Rationalisation Procedural Reflection 183 Since this derivation makes no claim upon the structure of its argument.i. F E FIELDS U()EF("QUOTf) = AE. once we have t~rnlS have not yet considered. eJlEF(Sk)] . whcthc. it can be generalised to the following theorem: 'IS E J. tile problem is that in spite of its increased power there is something inelegant about this move of having all function designators designate intensional functions..c the manner in whic~ "QUOTE" by the interpreter is consonant with the definition just During all of this arti~ulatcd. characterized liSP'S notion of evaluation in of the seman tical framework we are is ~land~~d currently erecting..e.~~.X] :J [cIlEF(r"(OUOTE ~)1) (53-60) :r S]] Note that we have quite reasonably assumed that the IISP operator '''QUOTE'' designates the definition of hyper·int~nsional identity function.. it would seen).AX. E E ENVS. de-referencing any of their arguments: -IS E S. functions with arbitrary "de-rcfcrcnciug" power. as the designation of t-lISP proct:durcs. whereas in tact and these that arc not (IMPRS). A certain amount of "semantic innocence·" has been lost in making tile simple procedures complex. ~lUS givin~ fr~m the ill/ellsional functions the cnvirunlncnt as an argument. A cleaner stratI 'V. in order to make more complex procedures simple. II should be absolutely clear that this "QUOTE" makes no reference at all to any concept of evaluation.. Furthermore. this approach is too general: it allows us to posit. cIlEF(S3)' .. VIC S<1y. INTEGERS1].. EXT?. which was true of extensional functions and false of in(cns~onal ones. it designates a function from contcAts to a function from structures to numbers .on \VC have used the sut>junctive. we could recast the declarative semantics of lists as follows. F E FIELDS ~~[f(f) preventing them (53-61) :: if [XT?(~EF(S» then 4»E~(S\) [llEF(Sz. it is of type CC ENVS x FIELDS J . [S ..3. ctiscuc. i-LISP procedures must be of only two varieties: those that arc extensional in their argulllcnts (EXPRS}.. 'IE E ENV.AF . for example). If \\'itJ1QUt could do thl[. there is no way to define a it~ l-lISP procedure of inlennediale extensionality (one that dc-references just une of two arguments. Note that we have now said tl\at the atom "+" does not designate the addition function: rather. Semantic. an issue we It will be a matter of some interest to see. called.

a function into where + in the functions that pick up an cnvironlncnt but ignore it. The difficulty is illustrated by the following: (DEfINE F1 (LAMBDA EXPR (A) (CAR A») (DEFINE Fz (LAMBDA IMPR (A) (CAR A») (53-62) For example. Sit] r (SI 52 S3 . Sk)l dcfil1c~ EVlIS (53-64) INT = UfO skI fun~tions.one that in the meta-theoretic language maintains lhe clarity of our first suggcstiun. INPRS. rather it is only to procedures (or to some other more intensional object) that we can property apply these terms.AE.. that transfom~s them into functions that pick up an cnvironnlcnt and de·rcfcrcP(~~ the arguments first.ion functions (these can be understood as the dcsignational analogues of tile procedural in McCarthy's original rcport 14 ): EXT AG.ollalisa. {53-56) EXT is a functional: a function \Jver other INT. it is :10t jUllctions that are intensional or extensional. in spite of our use of what is common terminology. th':.3. For these reasons we will adopt a third possibility .. G[tIJEF(St).. applying the original function to the arguments as is. Another way to sec this is to realise that. where S :I r" (51 52 S3 .. in particular. (IlEF (F 1) cIlE F(F 2) would both have to be the function. Since they are identical. G[SI' 52.. Semantic RatIonalisation Procedural Reflection 184 it s z elS8 c1tEF(Sl) [52' 53' . .AE.on and . eJ»EF(Sz) .AF . that adequately treats docs not provide as much generality as the option just explored. and that The approach is to mediate between the tY/a previous proposals. and then apply tran~"')nns the original function to the resulting referents.AF.. we would have the following behaviour: ( F1 (CONS 3 4» (F 2 (CONS 3 4» 3 CONS 53-61 (53-63) Under the treatment suggested in above. by contrast.AS.AS . fI)EF(Sk)] where S = f" (51 52 53 .e is therefore no way in which (EXT? F1) can be true and (EXT? F2) be false. however. both and F1 and F2 would be required to have CAR the same denotation..ntens... Sk)l AG. i~ that such a predicate (EXl?) is impossible. which we call the extensional[sat. as follows. SIt)1 h The problem. First we define the following two mcta·linguistic functions. We can now say that in Eo the atom "+" dcsignatts EXT(+)....

mantic Rationalisatif)n Procedural Reflection 185 latter tenn is the meta-linguistic name for the real addition function. we can now set do\vn the equations that must be satisfied by the initial environment (Note that CAR Eo for the primitive procedures we have looked at so far.. V). EXT. [(cf>EF(Sl»EF] (Sz) where S = r"(Sl . = +[3.AF. 4] =7 (53-67) l "( 3 Y) and: ~EIFl("(QUOTE (HELLO THERE»)) (53-68) = [( (ll[t F1( "QUOTE) ) E1F1] "( (HELLO THERE)) = [(INT(i\X. on the other hand. since they arc in fact still .X)[St])F 1] "((HELLO rHERE») "((HELLO THERE» THERE) Note how in the thirci fro.) We will not consider this a violation of our convention. We will then require.. designates INT(AY. which has been carefully passed in to the function..AS. 4» EF( 5 z). Sk])AX. the new (I» of 53-66 is adequate for batll extensional and intensional procedures. however. ACl.X)E 1 Ft ] "«(HELLO = [(AE. Szjl (53-66) That this works is shown by the following two examples: cl»E 1 F1 ("(+ 3 Y) . which is whac we wantcn of it.i\E. fragment for pairs): 4- straightforward and perspicuous.AF. C)E 1 F(Sz)])F t ] "(3 Y) = [AS +[cflE 1 F1(Sl)' 4lE t Ft (S2)]j "(3 Y) = +[cIlE 1 Ft ("3)..X)(Sl»] [(AF.ordingly. 52 . and CDR cannot be defined in tcnns of EXT( F1 ) even though they arc F extensional.AS +[4lE 1 F(Sl). . where Y designates 4 in E1 = [(cIlE t Ft ("+»E t Ft ] "(3 Y) = [(EXT(+»E 1 Ft "(3 Y) = [( ( AG • AE• AF • AS G[ c{) EF( S1 ).i\F .AS +[cflEF(Sl). 4»E 1 F1( EI (" Y»] = +[3.X»E 1 F11 "((HELLO THERE) = [«i\G. tI» EF( Sk ) ] ) +) ElF 1] = [(AE. «I»EF(Sz)])E 1 F1] "(3 Y) = [(AF. It is alsCt meta"malhematically perspicuous. In other words... QUOTE.n last Hoe the cnvironIncnt El .3. that all These are both function designators be restricted to those built from EXT or I NT.AS (AX. S<. because they need access to the: is ill-formed since is not bound. 4lE t F1 ("Y)] .X) "(HELLO = "(HELLO THERE) = [(AS (i\X. as is the new (recursive) definition of til (we show just the == ~E. and it is of just the right power.X}[Sl])EtF t ] "«(HELLO THERE)) = THERE») = (AX. as a meta-linguistic convention.AS (AX.AS G[5 1 .Af. is ignored by the "intcnsionalised" function.

.S € INTEGERS) = EXT(AS.AX .S) where X =.2 then XZ.AF.AS [~EF(~EF(CAR(S»)])E1F2] ["('(+ X (CAR :: [AS ['I'E 1 F2 (cl»[ 1 F2 ( CAR (S ) } ) ]] [" ( .) «!lEoF 0(" CAR) = AE. EVAL) = EXT('I'EF) (53-60) Unfortunately. (Xl.l X1. -) tIlE of o C)EoF o{" /) 4»E of o( . be proc~"'ura/ly dcclarativel~': this is correct - will be shown to intensional. c1JE of o( "CDR) ~EoFo(" PROF) cIlE oFa{"+) = AE. as TIlcse lead to the following characterisation: ~EoF o( .z) 111ere are several comments to be made about this list. if Xl. the natural reading of the designation of an application formed ill terms of EVAL is that it designates the procedural consequence of the referent of its 3igumcnt. the designation of a CONO "1 f. however. lbus we have: 4»E oFo{" EVAL) = AE. rather than From a declarative point of view.r"((X t .AF. however.AF. because it evaluates its arguments in Donnal. First. suppose in some cnvironnlcnt E1 the variable x is bound to 100 and Lhe variable y to a pair P5 and in field F2 that pair has CAR of 1. order.e might expect.AF. We then have: t ~EIF2("(EVAL :z [(<<flE 1 F2 ("EVAL»E 1 Fz] ["('(+ x (CAR V»~)] (AE.t then Xl . Semantic Rationalisation Procedural Reflection 186 extensional in the sense that they designate functions of the extensions of their arguments. since that nlullcful (+ 2 3).. = EXT(+) [Ft(~EF(X»] [F2(~EF(X»] [f3(~Ef(X» (53-69) 4»E oFo( .. = AE. Thus for example we expect (EVAl • (+ 2 3» to designate the nUlneral5..l = EXT(AX. is extensional.t X . than applicative.AS [~EF(~EF(CAR(S»)] (53-61) For example. the context arguments nlust be picked up explicitly..AF.. EVAL is the (local) proccdu:al consequence of the application well. this is ill-formed. note that COND COND is described as an extensional procedure.. EQ) ~Eof o( " NUMBfRP) ~EoFo( ~EoFo( <" ... but simply described. (+ x (CAR Y)))] '(+ X (CAR V»~)~ (53-62) V)))] ..AX . )1 Z «l>EoFo( "QUOTE) = INT(AS. l~wo II and the material conditional in the meta-language). As on. arc and APPLY.S E ATONS) eJse1f Xl. application is a fLlnction only of the referents of its arguments (as of course arc 8 J sa .. etc.3.AX . EVAL procedures that are important.2) .2 .) = EXT(-) :I EXT(-) = EXT(/) :I "ATOM) "COND) EXTC·) EXT(AS.

consisting of the lambda abstraction of for the time being that we have a Ineta-linguistic translator function over <body). Thus.Sa»] elself [51 = "IMPR] then [INT(TRANS(E. Then in be described as follows: 4»E oFo( "LAMBDA) a tClms of this function tile declarative import of LAMBDA can (53-63) AE. but the intent is clear.Sz. rather than writing out the full meta-syntactic translation functions that construct an appropriatc lambda calculus function designator from the arguments to the LAMBDA. we will have to give up on ever lIsing the cxtcnsionalisation Thus premature formalisation would be of no point. TRANS(Eo.3. the value of the 'I' function of these arguments). that designates the appropriate I. arguments: an environment and a field."(X). closed in the defining environment (this is 1.S2. LAMBDA forrns take a type argument to distinguish EXPRS from IMPRS.Fo. if we are to keep analysing l-L ISP. The correct context has been passed through.. As we would expect. Semantic Rationalisation Procedural Reflection 187 = [i'E 1 Fz«()E 1 F2 {CAR("('(+ X = ['ltE 1Fz(cIlE 1 F2 (" '(+ X (CAR :I (CAR V»~»~»~] V)~~)] 'l'E 1 F2 (" (+ X (CAR Y))) Since we have not yet spelled out '1'. that is also evaluates to this result will emerge only when we consider 'I'E F(EVAl) in the next section. the second two syntactic objects of LISP). The reason that we are beginning to case up on mathem. and a variable list and a body (the first two metalanguage objects. and."(+ x 1» would designate the incrctncnt function function.7-LISP). the declarative significance of expressions of the <vars> fonn (LAMBDA EXPR <vars> <body» is that they designate functions. LAMBDA we will show how.Sa»]] . Such function designators arc extensional . As described in the last chapter.AS [ If (SI = "EXPR] then [EXT(fRANS(E. (providing the atoln + was bound as usual in Eo to a designator of the cxtcnsionalisation of the addition function).F.e.AF. The only otllcr primitive we will consider is LAMBDA. we will assume TRANS that takes fOUf ". we are not yet in a position to continue this derivation. we will instead simply describe in plain English what its declarative import comes to.this is the crucial point.F. Note that the original expression (EVAL '( + x (CAR Y») designates this result (namely. and what remains is merely to inquire as to the procedural consequence of the original argument in the context of usc.tical rigour is that we already have plenty of ammunition to show how our present approach is doolnccl: after looking at function.

j!g definitions: (DEFINE F1 {LAMBDA EXPR (A) (CAR A») (DEFINE Fz (LAMBDA IMPR (A) (CAR A») (53-64) and two examples of their use: ( F1 (CONS 3 4» ( F2 (CONS 3 4» 3 CONS {Sa-56) In order to avoid making use of avoid the CAR DEFINE."(A). procedures: ~EOFO("(LAMBDA First we look at the designation of the t\YQ EXPR (A) A) (53-67) («l>EoFo{"LAMBDA»Eofol ["(EXPR (A) A)] [(AE. ]] [" (EXPR (A) A) J [ i f "EXPR = "EXPR then EXf(TRANS(Eo. 53)1 Procedural Reflection 188 lne crucial fact to notice about this characterisation is that the designation of all userdefined procedures are expressed in teons of EXT or INT. examples like those we used show that a predicate EXT? was not definable."(A). and LAMBDA have all had their own characterisations.Af . What we have demonstrated."A») elseif 51 = "IMPR then INT(TRANS{E o.AS [ i f 51 = "EXPR . In particular. We have ourselves violated our original claim that we would always use one of these two."A» EXT(AX . however. 4) (53-66) (CONS 3 4) TIle sernantical analysis is as follows. we will instead consider lhe following two expressions: «LAMBDA EXPR (A) A) (CONS 3 4» «LAMBDA IMPR (A) A) (CONS 3 4» (3 . we will look at [0 In that circumstance we had the follow. and in order to function. which needs explicit access to the field.S Z'S 3 »] EXT(TRANS(Eo. because of this definition of LAMBDA. lbat this characterisatiun is plausibly correct is manifested by two examples. CAR.fo. which we have not yet analysed.F o.3. because they needed explicit access to some aspect of the context of usc above and beyond that provided by the extensionalisation and intensionalisation functions. ])EoFol ["(EXPR (A) AJ] [AS [if 51 = "EXPR . X) .Fo. is that the exceptions to our convention are small in 11umber and constrained: no others can be generated.. 52.. Semantic Rationalisation where S • r"(Sl... CDR. Oile using the extensional and one using the intensional version.

X»Eofol ["((CONS 3 4))] :I :I :I X) [cltEoFo("(CONS 3 4»] X) ["(3 • 4)] "(3 • 4) (AX (AX Analogously: ~EoFO("((LAMBDA IMPR (A) A) (CONS 3 4)) IMPR (A) A)))EoFol ["(CONS 3 4)] (53-70) = [(flJEofo("(LAMBDA = ( AX [(INT(AX • X»EoFol ["((CONS 3 4»)] • x) [" (CONS 3 4)] :: "(CONS 3 4) This is as much cf an account. albeit briefly. we have not or DEFINE. Howe'ycr we have anlplc evi·lcnc~ to be able to show much CONS. since the same point holds for the environment. One issue clearly has to do wit. will turn. of the declarative semantics of IISP as we wilt exarnine for the present. although the substantive question here has already been decided: we use environments a~ theoretical posits in the mLta-lallguage. to the procedural import of . Semantic Rationalisation By an entirely similar proof we have as well: ~EoFo("(LAHBDA :I Procedural Reflection 189 IMPR (A) Al) INT(AX . but not because we have exhibited no mechanism by which Ule field can be affected. for example.lcturcs. X) (S3-68) Thus we can look at the two fuller applications: ~EoFo("((LAMBDA EXPR (A) A) (CONS 3 4))) (53-69) = [(cI»EoFo("(LAHBDA EXPR (A) A))EoFol ("((CONS 3 4))] = [(EXT(AX . for exarnple. at least formulated in these simple tCflns. '" 1 for FUNCTIONS X S I-LISP and CC 1 -+ 0 1 for 1. I\nd we could look at lambdaoobinding of fannal parameters. Therefore we I-LISP st~1. We could go on: it would be possible to provide an fuller analysis of TRANS.7-lISP). more serious problems wittl this approach than such incompleteness.h side effects: we have modelled examined SETQ CAR and COil.3. and we have not yet looked at APPLY (which would be the extcnsionatisation of a function of type [( S x s 1 -. shnilarly. and arrange for binding to ama~sed preserve designation.

First. where will we find any functions to apply? Some of these s· expressions will de:signate functions. we can almost use tllis code directly to generate a reathematical account of '1'. An immediate and natural question is this: if both domain and range of 'If are s-cxpressions. We could start to layout'" mathematically. we are supposedly going to speak in terms of function application and so forth. nonetheless. presented below (once again we eoncentrate on our SCtfEME. in those dialects' tenninology. since we are stili talking semantically.AF . at !east approximately. ['I'EF(tltEF(Fl(S»)]]) could in fact almost Y. "1. We as much as Of EVAl.' Local Procedural Semantics ('1') We tUfn next to the local procedural semantics (i') of I-LISP and 1. numerals return themselves: 'IN € NUMERALS. Thus. [eJlEF("MC-EVAL) . F. r€~~cctivc dialect). In the prescnt insta. however.e. because we have to characterise it independent of the designation function fIl.7-lISP: a characterisation of what. Semantic Rationalisation Procedural Reflection 190 3. albeit with reference to = EXT{'JlEF) we EVAL rather than wer~ defining the semantics of rather than defining '1'.. for the following reason: It is the ptocedura/ consequence junctioll that the 11Ieta-circu/ar processor designates. but that is of course of no help. Fonnulating a coher~nt reply to this concern will be the main emphasis in this brief sketch.3. however. we will instead look at a meta-circular interpreter. 11lis code for MC-EVAL is of interest for a variety of reasons. E E ENV.. each type of s-expression evaluates to. be used as a definition of .7-lISP" version of since it is tnore general than I-LISP). because we have defined in terms of primitive procedures other than E)cT('I'EF)] EVAL. suggested this in the last section.di.. F E FIELDS ['ltEF(N) = N] (53-71) Before proceding in this fashion. beginning witll the obvious fact that in all contexts E.As.cc. ifEF (i. MC-EVAL the expression [qlEF( "MC-EVAL) = (strictly. if rclativised to context) is a fbnction of type [S -+ S1.: AE. we can almost assume that fact will be crucial when we tUfn to the design of a course in specifying that ~EF( "EVAL) 4»EF("MC-EVAL) = EXT('I'EF) (this ~o MC-EVAl.

(P-EXPR (MC-APPLY-PE (2ND (1ST ARGS» (2ND AHGS) ENV» (EXPR (MC-EVAL (4TU (1ST ARGS» (DINO (3RO (1ST ARGS}) (2ND ARGS) (53-74) (2ND (1ST ARGS»»»»» . (* (1ST ARGS) (2ND ARGS») (I (/ (1ST ARGS) (2ND AR5S») {EVAl (MC-EVAL (1ST ARGS) ENV» (APPLY (CASEQ (1ST (1ST ARGS» (P-IMPR (ERROR 'YOU-CAN-ONlY-APPLY-EXPRS» (IMPR (ERROR 'YOU-CAN-ONlY-APPlY-EXPRS» .1 ARGS»» (53-73) (DEFINE (SET-81f\' I (1ST ARGS) (~~C-EVAl i2NO ARGS) ENV) ENV»») (DEFINE MC-APPLY-PE (LAMBDA EXPR (FUN ARGS ENV) (CASEQ FUN (CAR (CAR (1ST ARGS») (CDR (CDR (1ST ARGS») (CONS (CONS (1ST ARGS) (2ND ARGS») (EQ (EQ (1ST ARGS) (2NO ARGS») (NUMBERP (NUMBERP (1ST ARGS») (ATOM (ATOM (1ST ARGS») (READ (READ» (PRINT (PRINT (1ST A~GS») (SET (SET-BIND (1ST AR~S) (2ND ARGS) ENV» (+ (+ (1ST AnGS) (2ND ARGS») ((. {BIND (3RO PROC) (MC-EVlIS (REST EXP) 'C) ENV) (2ND PRDC»»)))) (DEfINE Me-APPLY-PI . Semantic Rationalisation Procedural Reflection 191 A Meta-Circular 1.(1ST ARGS) (2ND ARGS») (. (LAMBDA EXPR (FUN ARGS ENV) (CASEQ PROC (QUOTE (1ST ARGS» (IF (IF (NULL (MC-EVAl (1ST ARGS) fNV» (MC-EVAL (SRD ARGS) ENV) (MC-EVAl (2ND ARGS) ENV») (LAMBDA (CONS (1ST ARGS) (CONS EtJV (RE:.3. 7-LISP Processor: (DEFINE MC-EVAL (LAMBDA EXPR (EXP ENV) (COND {(MEMQ EXP '(T NIL» EXP) «~UMBERP EXP) EXP) «ATOM EXP) (LOOKUP EXP ENV» (T (LET «PROC (MC-EVAL (1ST EXP) ENV)}) (CASEQ (1ST PROC) (P-IMPR (Me-APPLY-PI (2ND PROC) (REST EXP) ENV» (P-EXPR (MC-APPlY-PE (2ND PROe) (MC-EVLIS (REST EXP) '() ENV) ENV) ) (S3-72) (IMPR (MC-EVAL (4TH PROe) (BIND (3RO PROC) (REST EXP) (2ND PROC»» (EXPR (MC-EVAl (4TH PROC) .

3 designates the quoted expression '3. On the other hand. since the numeral designates a nUlnber. We know that . since numerals arc part of the structural fic. the following: (MC-EVAL "3) -+ 3 (53-78) Similarly. the evaluation theorcnl tens us that the local procedural consequence of · 3 will bc irs referent: the numeral (MC-EVAL "3) Thus is supposed to designate that numeral. We would correctly predict. which we arc of course at pains to show they cannot.. Semantic Rationalisation (DEfINE MC-EVLIS (lAMDDA EXPR (ARGS ARGS· ENV) (IF (NULL ARGS) (REVERSE ARGS·) (MC-EVlIS (REST ARGS) (CONS (MC-EVAL {1ST ARGS) ENV) ARGS·) ENV»» Procedural Reflection 192 (53-76) (MAPCAR (LAMBDA EXPR (FUN) (SET-FUNCTION FUN (LIST 'P-IMPR FUN») '(QUOTE IF LAMBDA DEFINE» (53-16) (53-77) I»~ (MAPCAR (LAMBDA EXPR (FUN) (SET-FUNCTION FUN (LIST 'P-EXPR FUN») '(CAR CDR CONS EO NUMBERP ATOM READ P~INT SET [VAL APPLY + . . In some cases our analysis is correct: for example. The first is relatively minor: it has to do with the fact thrt. we have: (MC-EVAL '3) 3 I (53-'79) 3.11. a nunlcral. on our account. a variety of reasons why we cannot adopt this suggestion literally. the prescnt characterisation of cit is wrong . again. F the expression (MC-EVAl "3) would designate the local procedural numeral Because' 3 designates 3. consequence of the designation of · '3.it presumes that evaluation and interpretation can be identified.3. I-fence. and because a numeral is within the structural field. lois is predicted because conscq1lcncc is itself: and 3 designates the numeral and that numeral's proccdur~l (MC-EVAl '3) should return that numeral. however. (MC-EVAL "3) should evaluate to that numeral. it would predict that in some context E. as will be explained at the beginning of section 3. should generate an error. we also have: (MC-EVAl 3) 3 3 (S3-S0) This. in other words. not being expressions.f. and nlunbers do not have procedural consequences at :di. and we know that the expression '3 dcsigi~ates the 3.• There arc.

line by line. '\8 usual.of an environment and a field MC-EVAL takes only a single context argument: the environment. therefore. accessible to examination and Inodification without further ado. Finally. however. In spite of being constructed in terms of procedures bearing the makes explicit the Jonnal cut on procedural consequence: rather a behaviour than ac/ua!:y applying the procedure (in an (lpplication) to tIle arguments. because the meta-circular processor is inlernal to the process as a whole. which {s that YJhereas on our mcta-linguistic account is a function of a two-parI context . but also in defining the There is anuther rather more serious reason why name "APPLY". rather than as a function or list of pairs. MC-EVAL still computes the field-relative procedural hnport.EVAL 3-lISP prxcssof in chapter 5. however.f:iii. it obtains the field aspect of the context directly. It does not. MC-EVAl is of type [c s x s 1 -+ s 11. so to speak. In our mathematics we have defined as of type C[ ENVS x FIELDS 1 --to C S -+ s 11. in our review in section 3. 'onmcllt as a structure. For all of these rea~OTiS. it performs the standard computational forlnal expression analogue of function application we will ultimately call reduction. rather than in tcrnlS of structural context designators. therefore. we will Numerals evaluate to themselves in all environlnenrs: . We will make further comIllcnts on why it is reasonable to have 'I' defined in terms of abstract context. for the present we may simply observe that once again the use of an evaluative reduction scheme confuses use/mention issues alUlost irretrievably. we will begin to erect our own characterisation of MC-EVAl ~I'. without need of theoretically posited formal arguments. 193 There is another reason it MC-EVAl is not the extensionalisation of v. defined in tcnns of an env. The reason is clear: the COlli~11tational stnlctural field is simply there. Semantic Rationalisation This kind of confusion will of course be repaired in that - Procedural Reflection 2-lISP. MC. M\:-EVAL does not quite represent what we are calling '1'. by stepping through the definition of begin with the numerals.3. whereas our meta-linguistic characterisation is of course entirely external. the characterisation not only of the full procedural consequence l function r in the next section. clarify the question about closures and functions that we want to foc\Js on. 111is distinction between reified context arguments and directly accessible context fields will play a role . as a declarative analysis of the code would make 'I' apparent. MC-EVAL as just given is.

F E FIELDS ['I'EF(N) = N] Procedural Reflection 194 (53-81) Similarly. encoding procedure entirely parallel tu our trcaL'llent of cfl. F € FIELDS [ 1f [A E {"T. which brings to bring to light the fundamental problems that pcnn\..3.)] where S = r"(Sl 52 S3 . E € EIV. E E ENV. F E FIELDS [i'EF(S) = ["'EF(St) ]<irEF(S. E E ENV. . ''I'EF(Sk»] where S = rites! 52 S3 . SIr. ..). SIt)l Of... . (53-83) generalised to handle IMPRS as welt as EXPRS (and assulning a definition of EXPR and EXT IMPR as functions in the meta-language analogous to and INT in the declarative case): (53-84) 'IS € PAIRS.. 'l'EF(Sk»l where S = r"(Sl 52 ... to what those bindings designate or return . There is hOYt'cver a serious problem with this approach.. the atoms T and NIL are self-evaluative.. "NIL}] then ('ltEF(A) = A) else (i'EF(A) = E(A»)] (53-82) These two equations mimic the first three COND clauses in 53-72 reproduced above... Semantic Rationalisation 'IN € NUIIERALS.X) EXPR (53-85) 'nle definition of EXPR would be the following: [G<'I'EF(Sl}' 'l'EF(Sz).atc ~hcse LISP dialects and the vocabulary . E E ENV. so [XPRS should evaluate their arguments. immediately apparent how these should }1e treated: if we were to continue in a rn&nner then we might expect something of the following sort for extensional procedures: \IS E PAIRS.we see here how the one notion of envifonment is used across both procedural and declarative significance): VA E ATONS. AE :Af . other atoms evaluate to their (procedural) bindings (not. F E FIELDS ['I'EF(S) = [('I'EF(St) )EF] <52' 53..AS rfhc intuition behind these equations is this: just as extensional procedures dc-referenced their arguments.. app1ication~.~F o( "QUOTE) = EXPR(CAR) EXPR(+) IMPrt(AX. and then apply their own "v31ue" to those evaluated arguments. of course. It is not 'Ine only otller category are the pairs. 'l'EF(S3)' .. SIt)l and with such definitions of primitive procedures as this: EoFo("CAR) EoF o("+) f.. Sk)' (53-86) == AG.

"ructure in procedure poc. y (+ Y 1». There are other problems of the same variety in the equations we just wrote down: IlUlnera[s. it simply executes them in a non-inspectable fashion. of course. in other words. does remain with the structural domain. Thus they would take "+" onto the addition function. and the "addition" of tIle numeral effected \vithout explanation. posit an equation of the . since s-expressions are not functions. the meta- to the numeral 3 in an environment. but it does not deal with functions. but they - outset - deal with designation. and also have it take structures onto the functions that we attribute to them. on tile other hand. that is. to the numeral 1 would be Thus neither of t-l-tese two traditions affords any help. EXPR. and therefore cannot "be lIsed as such in the meta-linguistic characterisation.. Standard programming language semantics deals with functions. Thus cannot be correct It might seem that we could change 53-84 to return an s-expression. it would recursively decompose the structure encoding the definition. and recursively + At some point in this process the primitive procedure 3 would be encountered. structure mappings of tile program. have the following two incompatible things: have '1' take structures onto structures.3. 11le meta-circular interpreter. which is not open to us. a function that takes its arguments onto func~ionst which are not clements 53-86 of the structural field. "rhus for example if we were dealing with {F 3) where F had been defined in tCflTIS of (LAMBDA (Y) circular processor would bind process the expression (+ Y 1).iLion into a function - following sort (wI-jere the underlined part is changed from 53-84): . as we made clear at the not with structure-to- It is instructive to look at two places it might seem we could turn for help. even the functions that represent their procedural ilnport. Eo i~. but then equation would have to fail. We cannot. Note as well that there arc tr" reasons we cannot appeal ~I. In sum. and with context 111 odi[icat ion. For primitive procedures like addition. we will have to delineate a rational policy on use/mention issues before we can proceed with the definition of v. 53-86 in conjunction with 53-84 would attempt to apply tile real addition function (defined over numbers) to which represents a type-error in the meta-linguistic account. the declarative interpretation function in order to turn the cannot. Semantic Rationalisation Procedural Reflection J9S traditionally used to describe them. We said above that itEF was of type [S -to 51. for non-primitives.

given two numerals as argumcnts yields that numeral that designates the sum of the integers designated by the two arguments.and. M. It is exactly what the "arithmetic" component of a CPU does. the numeral addition function would not be described quite as simply as that given in of one sort and another.. Sit)' Procedural Reflection 196 (53-81) Not only is ell not available to us in defining function~ '1'. E E ENV. this is just the place where the idiosyncracies of representation would be taken care ot: For example. as mcntione J in the introduction to this chapter. hO'Never. F € FIELDS ['ltEF{S) = [(4)>EF(Sl) )EF] <S2. of course. C s -.3.. 9 intcrnaliser is a function that takes closurcs which are expressions. not a number.. We will define a function. do not have such limitations.B) .1 (+(M(A). LISP Furthennore. in other words. defined as follows: A(A.M{[» 9 (53-S8) Such a function. we will say that these functions arc ellgendered by the closures. That. in a particular version of LISPS with fixed length integers (the ar~ we have dcfined~ being abstract and infinite. contexts enter in. is exactly what one would expect the internal so-called "addition routines" to do. and therefore not quite physically realisable). but rather shown to have limitations We will call A the internaliser (to be 1~hc distinguished from the intensionalising function of the preceding section). our initial version (we will have more complex versions subsequently) will take stnIctures independent of context (since closures arc contextindependent) onto functions that arc context-relative: . into functions from structures to stluctures. In the case of + the function we want is clearly what we may call the nUlneral addition function. Sit>] wh ere S = r" (S1 52 53 . from structures (since 'l'EF( "+) must be a struct.. s 11 (53-90) In fact. Semantic Rationalisation "S E PAIRS.. the intcrnaliser would have the following type: 11 : CS -. designates the real addition and 'l'E(" 1) is The only tenable solution . which maps a certain class of structures onto what we will call internal /unctions. but this would not even be correct For + a numeral. in fact a reasor:able solution is to define yet another interpretation function. 53-88 above. to be spelled "A".. If we were to ignore its contextual rclativisativn.ure) onto a differellt function than its designation. 53' .

[A(A. parameters Al EXPR closures by Note that the bound environment Ak E is used to determine the f e• significance of the arguments. M. but is not passed to the body s.M('I'EF(B»»])E1f 1 ] <"2. . the fOlmal through are bound on top of the closure environraent This reflects the fact that 1. Ec E ENVS [~r" (EXPR Ec (At.. that atom function: CAR is bound to a closure that engenders the actual L\'I'Ef("CAR) CAR = 11"(fXPR Eo (A) (CAR A») (S3-96) == XE.1 (+(M('I'E 1 Ft (A» . M-t(+(M('I'Ef(A».[(4~Ef("+»EF] ("2. Fl('I'EF(A»] To illustrate. M.hF . Sk>] + As an example. consider 'l'E 1 Fo(" (CAR GOODBYE) : X) where x in E1 is bound to the pair (HELLO • . We can then set out the following equation for the local procedural consequence of pairs: VS E PAIRS..1 (+(M('l'EF(A». "3> [.. where S = r"(SI 52 53 .M(i'Ef(B»»] (S3-92) Similarly. (" "3>] EIF I 2.. (53-93) 'tiS E S. We will then enforce & to obey strict compositional rules for all non-primitive defining it as follows.\<A.3» = ~-1(+(M("2).7-LISP is statically scoped.B> ..B> . Sk)1 '1'E 1 F1 ("(+ 2 3) (53-94) ~ .M('1'E 1 F1 (B»»] <"2. [A<A> .1 (6) = "6 :: M.A<~S2' :: s~> = 'ltE 1 F(S) ] Ec except that for l~i~k E1 (A i )=i'EF(Si). E E ENV. instead.A2 .AF .. F E FIELDS ['ltEF(S) = [(L1'1'EF(SI»EF] <S2' 53.. Ak) 5)1 where E1 = hE ...Af. In 1-lISP'S initial environ'l1cnt. Semantic Rationalisation A : Procedural Reflection 197 CS -+ CC ENVS X FIELDS 1 -+ CS -+ s 111 (53-91) Then we have the following internal version of addition: A[EoF o{"+)] = A["(EXPR Eo (A B) == (+ A 8»)] hE. Ak E ATOMS. At . we will simply posit the value of A of all primiuvely recognised procedures. "3) = M-l{+(M('I'E 1 F 1 ( "2» .A 2 . consider binding in E1): ~EIFl("(+ (the atom is assumed to have its s~'1ndard 2 3) (53-96) = [(A'I'EF( "+) )EIF t ] = = [AE.3.M("J») As a second example we look a[ CAR..1 (+(2.B> .\f • [i\<A.M('I'E 1 F1 ("3»» = M.i\F . "3> [(AE..

In addition. We have to posit as well. Since QUOTE is primitive. Semantic Rationalisation YEtF o(" (CAR X) Procedural Reflection 198 (53-97) ("X) = [(AE. A] ("X) = .. we have to do two things: we have to specify how we are to illter:. [A<A> • A])E 1 Fol = [A<A> . F 1("(HELLO .lJret the [unctions.AF .E t Fo{" X» F01{E 1 ("X» <"X> This is course what it designates as well. x ("x> Like the CAR example. what we are saying is that what we take the primitive procedures to designate has to be posited froln the outside: this is what the lists of Eof o«pr1mitive-procedure» were for. for example.AF . In specifying an applicative architecture. we have sho'Nn that 'l'EF("(QUOTE x» = 4»EF("(QUOTE X). the functions that are computed by the primitive p. we have just demonstrated a way in which the functions engendered by composite expressions can be detennined from the functions engendered by tile primitives. since by definition the local procedural consequence of any symbol must be a symbol. + designating the addition function. GOODBYE) 0 [A<A> • Fl(VEF(A»])E 1 Fo] [A<A> • F0 1('ltE t Fo{A»] (" x> F01(. we have: AitEF("QUOTE) = 11"(IMPR Eo (A) A) == AE . how procedure applications fanned in terms of it are treated). when processed by the Given these two facts. they are not what we take those prilnitive function designators to designate. [A<A> • A] (S3-98) Consider. As a third and final example.rocessing of those procedures. = [(A'I'Ef{"CAR»E 1 Fo] = "HELLO .AF . we also have now said that that atom engenders what we have called numeral addition. It is well to ask what is going on. These functions - a class we arc calling internal functions . in other words. 'l'E 1 Fo("(QUOTE X) for the same E1 as in the previous example: (53-99) i'E 1 FO(" (QUOTE X) [(~'1'EF{ "QUOTE) )E1Fol (" x> [(AE. and independently.3. we can look at QUOTE. In brief.!. its intenlal function has to be posited explicitly. Thus where we had the atom primitive processor.arc not the local procedural consequence of the prjnlitive function designators. and we have to specify how the primitive functions are treated (strictly. because they cannot work .

coherent. is a device whose behaviour is semantically TIlUS a pocket calculator or an abacus is computationally potent under to In spite of this. Full Procedural Consequence (r) By the full procedural consequence we refer not only to what a given expression returns. however. the processor by a pair of an environment and a continuation. In spite of this claimed naturalness." is neither odd nor a\vkward. In order to handle nlore general circumstances. tells us what our :nterprctation is. the most natural explanation of which is formulated in terms of attributing semantics to its ingredients and operations. the behaviour is not itself the interpretation ~ say that \vould involve a category error. This is as much of an exploration of local procedural consequence as we will take up. For us in our role as language.. all predictions as to the consequence of structures can be mediated by L. in other words.c external attributed semantics. however. In fact it brings to tll(' fore a point about computation that underlies our entire account. since it is limited to those procedures willl no side effects. From this perspective. thus our function r is of type C[ S X ENVS X FIELDS X . and if composition and so forth can be shown to work correctly. rrhcse facts are exactly what our analysis makes plain: for primitive procedures. described by the oleta-linguistic function f. and they additionally (one hopes) cohere in well-defined ways with the attributed functions they stand in an internal/external relationship to.3. it is fortunate that in a rationalised dialect. designers. we will turn to the full consequence. We have assumed throughout that a conlputational device is a mechanism.. Rather. We are modelling the field with a single theoretical posit. 3. If each of the pritnitives can be proved to cohere with the designated external functions. A tells us the function computed by the behaving mechanism. A computer. inle1pTetation. Semantic Rationalisation Procedural Reflection 199 with abstract entities..d. once some global semantic properties can be proved. one rarely needs to traffic in these internal functions. the intemaliser u!J. these internal functions are for the meantime necessary. they occupy a middle ground: they are presumably computed by the underlying implementation. f\ut also to the full effect it has on both the stnlctural field and the processor.

using a higher-order dialect such as to model more explicitly the continuation structure involved in processing LISP. As the depth-first processing embodied in causes levels of interpretation no explicit continuation to nest. the field was not made an explicit argument. The meta-circular processor presented in the previous section (3. As we said in chapter 2. As \ve can by now expect. and the programs it processes. Semantic Rationalisation CONTS Procedural Reflection 200 1 -+ [ S X ENVS X FIELDS 11. . "rhus we were led to what we called a "continuation-passing" meta-circular processor of the sort sumnlarised below. t11is code is more similar to the characterisation of the full procedural consequence we are currently in search of. then that structure would be affected in a way in which the outside world would see. share the same field. as the discussion in chapter 2 explained. That a continuation need not be part of the range of r is due to the way in which continuations work in an appticative setting. MC-EVAL There is also a sense in which and its processor share the same continuation MC-EVAL structures. but was instead simply affected directly. as we commented there. itself.d.3. MC-EVAl. and if x designated a structure accessible from outside.ii) dealt explicitly with environments as well as with structures. 1. it is possible.EVAl MC-EVAL.7-lISP. the partial result and so forth are maintained on the stack (an implementation of simple continuation strucutre) of the processor nlnning structure is maintained by MC. Thus it was prcsunled that if (MC-EVAL '(RPlACA x 'A» was processed.

3. SCfllantic Rationalisation Procedural Reflection 201 A Tail-Recursive Continuation-Passing Meta-Circular tel-LISP Processor (DEFINE MC-EVAl (53-100) (LAMBDA EXPR (EXP ENV CONT) (CONO «MEMO EXP '(T NIL» (CONT EXP» «NUMBERP EXP) (CONT EXP» «ATOM EXP) (CONT (LOOKUP EXP ENV») (T (MC-EVAL (1ST EXP) ENV (LAMBDA EXPR (PROC) (CASEQ (1ST PROC) (P-IMPR {Me-APPLY-PI (2ND PROC) (REST EXP) ENV CONT) (P-EXPR (MC-EVLIS (REST EXP) '() ENV (LAMBDA EXPR (ARGS·) (MC-APPLY-PE (2ND PROC) ARGS· ENV CONT»» (IMPR (MC-EVAL (4TH PROC) (BIND (3RD PROe) (REST EXP) (2ND PROC» CONT) ) (EXPR (MC-EVLIS (REST EXP) '() ENV (LAMBDA EXPR (~RGS·) (MC-EVAL (4TH PROe) (BIND (3RD PROC) ARGS· (2ND PROC» CONT»»»»») {DEFINE MC-EVlIS (LAMBDA EXPR (ARGS ARGS· ENV CONT) (IF (NULL ARGS) (CONT (REVERSE ARGS*» (MC-EVAl (CAR ARGS) ENV (lAMBDA EXPR (ARG·) (MC-EVLIS (CDR ARGS) (CONS ARG· ARGS·) ENV CONT»») (DEFINE MC-APPLY-PI (LAMBDA EXPR (PROe ARGS ENV CONT) (CASEQ PROC (QUOTE (CONT (1ST ARGS») (IF (MC-EVAL (1ST ARGS) ENV (LAMBDA EXPR (RESULT) (IF (NUll RESULT) (MC-EVAl (3RD ARGS) ENV CONT) (MC-EVAl (2ND ARGS) ENV CONT»») (LAMBDA (CONT (CONS (1ST ARGS) (CONS ENV (REST ARGS»») (DEFINE (MC-EVAL (2ND ARGS) ENV (LAMBDA EXPR (PROC) (CONT (SET-BIND (1ST ARGS) PROC ENV»»»» (53-101) (53-102) (DEFINE MC-APPlY-PE (53-103) (LAMBDA EXPR (PROe ARGS ENV CONT) (CASEQ PROC (EVAL (MC-EVAL (1ST ARGS) ENV CONT» (APPLY (CASEQ (1ST (1ST ARGS» {P-IMPR (ERROR 'YOU-CAN-ONlY-APPlY-EXPRS» (IMPR (ERROR 'YOU-CAN-ONlY-APPlY-EXPRS» (P-EXPR (MC-APPlY-PE (2ND (1ST ARGS» {2ND ARGS) ENV CONT» (EXPR (MC-EVAL (4TH (1ST ARGS» (RIND (3RO (1ST ARGS» (2ND ARGS) (2ND (1ST ARGS») CONT»» .

d. thus we cannot define r by using cI» (althougll such a boot-strapping technique would be possible if a non-side-effcct version of r were inlplemcntcd.(1ST ARGS) (2ND ARGS») (* (1ST ARGS) (2ND ARGS») {I (1ST ARGS) (2ND ARGS») (SET-BIND (1ST ARGS) (2ND ARGS) ENV»»»» (53-104) (53-106) . for a number of reasons: the field is not explicitly mentioned.F.E..• I»~ As with the local case. E E ENVS. C E CONTS (53-108) [r(S. we would then be dealing \vith a full implementation of LISP in LISP. that c) cannot ultimately be defined except in terms of r.circular. However the general claim that the denotation of an implelllelltation of a computational process should be the full procedural consequence of the implenlented language remains true. the environment is encoded as a structure. F E FIELDS. \ve cannot simply take this to literally encode the full procedural consequence. <?f course. not as an abstract function. In 2-LISP 1-LISP'S evaluation it would be more possible to define the full consequence in terms of the full continuation-passing processor.3.F)] . It will turn out.C} = C(S. the code's claim to being meta. but it is instnlctivc to set out a 'IS E NUNNERALS. Semantic Rationalisation (T (CONT (CASEQ PROC {CAR (CDR (CONS (EQ (NUMBERP (ATOM (READ Procedural Reflection 202 (PRINT (+ ({* (I (SET (CAR (1ST ARGS») (CDR (1ST ARGS») (CONS (1ST ARGS) (2ND ARGS») (EQ (1ST ARGS) (2ND ARGS») (NUMBERP (1ST ARGS») (ATOM (1ST ARGS») (READ» (PRINT (1ST ARGS») (+ (1ST ARGS) (2ND ARGS») (. {MAPCAR (LAMBDA EXPR (NAME) (SET-BIND NAME (LIST 'P-IMPR NAME) GLOBAL» '(QUOTE IF lAMRDA DEFINE» (MAPCAR (LAMBDA EXPR (NAME) (SET-BIND NAME (LIST 'P-EXPR NAME) GLOBAL» '(CAR CDR CONS EQ NUMBERP ATOM READ PRINT SET EVAl APPLY + . however. The numerals are always straightforward: f. As mentioned in the introduction. and protocol wreaks its usual havoc. but we will not pursue such an approach). 110wever. we will not concentrate on few of it') simple constraining equations.E. A solution to this.i. but the field problem would remain. as the next section will make plain. by using the «Il of 3. is to pass the field as an explicit argument: this violates.

E. [r( Ft 1 ( F1 2 ( S) ) . C E CONTS [r{S.E.C) = 1f [5 € {"T. Semantic Rationalisation Procedural Reflection 203 Similarly the atoms: VS E ATOMS.F 1 ) • CAR is: (53-112) C([Fl(A)]. [A < 1 . C) ] ]] ] S (53-110) This version of 11 is a full context-passing version of the internaliser shown previously. F ..C) == [r( Ft ( S) . [ ~S 1 ( F12 ( S) .E 1 . for exanlple.F o ' [i\<V 1 . [A<A.E 1 . Ak) ~)1 = i\So·AEo·AFo·i\C [r(f 1 (5) . AC • [r(Fl(s). F E FIELDS.Ek.E 2 . A2. E1 • F1 > . AF.F t ) • r(S.Fc> • C(Sc..F 1 > .AE.F 1 )]] QUOTE: Finally.. E E ENV.i\F.Sk E*(A. C{Fl(S).A 2 .\S.F 2 )]]]] Similarly. C E CONTS [r(S. is: ~EoFo( & "+) (53-111) == AS..[i\<Sc. (AI.F. Ak € ATONS.E 1 . F2 > • fun intcrnatisation A of composite (53-114) [i\<Vk.E 1 . E € ENVS [Ar" (EXPR !. . E1 • Fl. we posit the intcrnalisation of &EoFo("QUOTf) == .)::V t • .AC . for addition. A1 .E. E E ENV.F)]) Of more interest is the characterisation of the full significance of pairs.E·.]]]] ] where E* is like E except that for lS1.AE.F. E2 .AF.E.3.f) (53-113) As we did in the previous section.E.E z . the full internalisation of AEoF 0(" CAR) = AS. we can define the (non-primitive) closures as fol1ows: "S E S.F 1 > • [r{F 1 1(F 1 2{S» .F.F)] (53-109) else [C(E(S). E. [A<A.Et. In order to allow for side-effects.M(B»)].k. so as to mirror the temporal flow of the processing: "S E PAIRS.Ec.1 (+(M(A). "NIL}] then [C(S.f c )])]·.F.. C([M.Eo.F I • [A<B.E. F1 .AC • [r(Fl(s).Fk. [A<V2 ..F. F E FIELDS.AE.E.f 2 > . the idea is to allow the environment and field to percolate throngh the establishing of the significance of the constituent parts. E1 .

the environment given it is not the one which has sustained the processing of the arguments. however. but rather the closure environment extended to include bindings of the fonnal parameters to the new bindings. Semantic Rationalisation Procedural Reflection 204 Each of the arguments. When the body is fi~al1y processed. in other words. however. which is passed through the arguments to the body and thence directly to tile continuation. is processed in the environment of the call. continuation is Ek Note on return. . that the environment passed to the ~s (which may have been modified in the course of processing the a result of processing the This arrangement is quite different from the case of the field.3. arguments). not the (possibly modified) version of E· returned body of the procedure. with side effects passed from one to the next.

There arc two sources of difficulty: one having to do with the semantical inelegance of evaluation. but more seriously that our approach cannot even be maintained. a tremendous amount of work before a complete semantics would be in place: the entire subject of functional composition. would require treatment Some of these subjects will arise in subsequent discussion of the dialects we build: the semantics of recursion. will come into tile foregoround when we discuss the 2-LISP implementation of recursive procedures in tenns of an explicit Y-opcrator. for a rather serious reason. On the face of it.e. TIlough \ve will show that tllis challenge can in fact be met - and our original intuitions preserved - to do so will lead us into sOlne complexities. . 3. and one with temporal considerations and side effects. we laid out a tentative declarative semantics for all of the I-lISP structural types. of procedural semantics. furthermore. The second. of course. and so forth. similarly for both tIle local There would remain. variable binding. our current approach is in trouble. recursion. this is what it is to be an extensional procedure. and for all of its primitive procedures. Semantic Rationalisation Procedural Reflection 205 3. and for the full procedural consequence. what TRANS comes to). However we have also assumed that all procedures defined as EXPRS are extellsional: that procedures tllat procedurally arc treated with EXPR can declaratively be treated \vith EXT. course. however.. It is important to separate them. lambda abstraction (i. would confront any possible dialect of IISP. for example. The Semantics of 1-LISP: a Second Attempt It is time to take a step back froln details for a spell. to reflect on what we have accomplisJled.i. However. It will be instructive to sho\v just how seriously what we have done so far is in error.e. we will not proceed with such considerations here. rIbere are a variety of problems that Inean not only that our current results cannot be adopted intact. this is not so. they would appear to challenge the coherence of our maintaining that (fJ and it are distinct.e. as suggested earlier. In t-LISP. The Pervasive Influence ofEvaluation The first concern is this: we have arranged it so that applications in terms of extensional procedures are defined with respect to the designation of the arguments - indeed. because the first set of problcIns are I-LISP specific: in a rationalised dialect they could be corrected.3.

these two subexpressions evaluate to the same entity (the numeral). "3)] = [«AG. we would have to re. of course.3. and evaluation. then. claim that For consider the following: (53-121) cIlEoFo{"(EQ 3 '3') = [(<I»EoF o{ "EQ) )EoF o ] {" (3 '3) = [{41EoFo{Eo("EQ»EoFo] ("(. To show an example. = False This in spite of the fact that (EQ 3 '3) unarguabty evaluates to 3. but evaluates to T - presumably an unwelcome result. the expression 3 ' 3) designates falsity. if we assume this correspondence. Thus (53-123) EQ is just an example: we would have to recast every extensional procedure. we cannot get away with what seemed only natural: our «I>EoFo("EQ) = EXT(=). To make a proper definition of the designation of EQ. is that the expression' 3 designates the numeral whereas 3 designates the nlllnber 3.3 '3) = [(EXT(=»EoFol ("(3 '3) G(~E(Sl)' ~E(Sz») )EoFol ("(3 '3) 4» EF( Sz) » Eo F0] (" ( 3 ' 3) ) = [AS =(<I>E oFo(Sl)' «JlEoFo(Sz»] ("(3 '3) [=(<<I»E oFo{"3). we only have to show how.AS = [( hE.AE. The problem is that EXPRS evaluate their arguments. however. The problem. There is of course no '1'E oFo{" fQ) doubt that from a procedural point of view it is an equality predicate: = Declaratively. making tile EXT function of no use whatsoever. (EQ as we have time and again said. Semantic Rationalisation Procedural Reflection 206 Alternatively. AF • AS =( <It EF( S1). We have known this all along. Because of the evaluation theorem. on the readings we have assumed. to put the same point another way. T.AF. bears a strange relationship to designation. We would have to give up tile intuition that any procedure was defined over the referents of its arguments..hasty assumption that the primitive procedure EXPR ( =).define it along roughly the following tines: (53-122) except of course this (like all attempts to use we are led to: INT when we want the meta-linguistic function f itself to do some de"rcfercncing or processing) is ill-formed - and F aren't bound. however.. 4>E oFo(" '3»] = [=(3. EQ designates an extensional equality predicate. and recast them all as defined . The source of this particular problem was our too. we will never be able to describe how 111e procedural consequence and the declarative import of a given expression relate.

It was our original aim to demonstrate the natural declarative attribution of significance to expressions formed in tenns of EQ. LISP so that the natural 3. the expression (EQ x Y) evaluates to T. because of side effects. the designation of an expression would never be used: although you could use the meta-theoretic machinery to ask of a given expression what its designation was.i. must squarely be faced. The Teluporal Context ofDesignation The second problem with the approach of the last section. the environment in which each of the clements of a procedure application are interpreted is the same. for some expressions x and v. not in tenns of the designation of anything! Looked at from the other side. Semantic Rationalisation Procedural Reflection 207 over the values of their args. which is undeniably that its arguments arc the same. we claim. we can see that from the fact that. however.3.all one can say is that they are co-evaluative. the answer would be formulated in tenns of the local procedural consequence of the ingredients. the story is not so simple. I-LISP. which is nonsensical. attempts to solve the problem by dismissing it It says that we have to abandon any notion of pre-theoretic attribution of semantics. This last maneouver is an attempt to correct the declarative semantics so that the equations work out: a better strategy. We could generalise tllis approach. is to correct intuitions are tnle of it. And this in order to establish the designation of the whole: we would claim that (EQ 3 '3) designates truth because 3 and '3 evaluate to the same numeral. that the context in which an expression is used is always passed down through the tree being interpreted: thus. The repair suggested in in other words. To follow such an approach is to get lost in fcnnalism and lose touch with our goals. So much the worse for 53-123. Consider for eXaInple: (LET «A '(2 3») {+ 1 {BLOCK (RPlACA A 6) (CAR A»» (53-124) . In actual I-LISP. throughout our analysis. and define a meta-theoretic function EXPR that cast the clesignation in terms of the values of the arguments. For one thing. in contrast. one cannot say whether x and Yare co-designative .e. in order to formulate an explicit account of that pre-theoretic attribution.. It is this: we have assurned. but this would be absurd.

First. therefore. is shallow.t should be evident that it will designate whatever is designated by the last fonn in its scope. would not reflect the (CAR A). explicit field and environment arguments. By our discu3sion in section 3. at first blush. and the rest. was temporally as well as structurally located. must designate six. as if it would violate our overall conception of procedural and declarative semantics as distinct. The answer :s tllis: what differentiates full procedural consequence from local procedural consequence is that the former makes explicit all of the potential causal interactions between the processing of one part of a composite expression and another. without losing grip on our claim that they describe different matters. Semantic Rationalisation It is clear that this will evaluate to the numeral 6 Procedural Reflection 208 (this would be reflected by looking at r). is equally vulnerable to stich causal effects. The present example would seem to suggest that we will have to do this as well for the declarative semantics. for declarative as well as for procedural purposes. changed field in establishing the designation of thus they would predict that the designation of the whole was the number three. should be.v. It is for reasons like tllis. In other words. Ilowever. The declarative semantics. 'fhis is not quite as limiting as it might seem. by our own ad.nlission.3. where we admitted that the context of use of an expression. but such a suggestion looks. It is of course our long-range goal to define 3-LISP: in that dialcc~ . like r. It is worth examining a variety of possible solutions to this problem of relating sideeffects and other non-local procedural consequences with the declarative reading.c. thus the whole The equations we have set down. of course. we are forced to admit that (CAR A) in the fonn given must designate the number five. but in the forlnal analysis that resulted we separated tl1cm too much. however. although we have not spelled out the declarative import of BLOCK. that standard programming langauge setnantics turned to continuation-passing style to encode the potential temporal interactions between the evaluation of one fragment of the code and another. what we must now do is let them come back closer together. We too took this approach. l11is concern. formulated with full continuations. it would be possible to define the dialect simply without side effects. for they illuminate several aspects of our approach. even of the declarative semantics. early in the chapter we argued that if and <Il must be separated. given our overall interest in reflection. . but only for procedural purposes. A full theory.

binding VAR and VAL to designators of x and 4. for exmnple. . ("[0 handle field side-effects would require passing the structural field as an explicit argument. environments are dealt with. Throughout our meta-theoretic analysis. because this is SETQ. It should be noted. as well. but the intent is this: a call to SETQ (say. this code assumes an environment protocol like that shown later in 53-137. operators can obviously be described perfectly adequately in a language without side effects.. but \vith an environment in which the binding of the variable to the normalised "value" tacked on the front. RPLACA and CONS and so forth could be sirnilarly constructed. explicitly articulated meta-theoretic accounts of the procedural semantics of the underlying machine. (SETQ x 4» \vould reflect upwards one level.3.a.• procedures behaviourally indistinguishable from those we say have side-effects in could be defined. From these two points we can see how a reflective dialect of the pure non-side" effect A-calculus would be sufficiently powerful so that procedures with "side-effects" (i.e. I-Iowcver to do this rather than made would be an empty victory. since in 3-LISP we in fact support environment side-effects primitively. SETQ tnight SETQ I-LISP) RPLACA and and so forth . After normalising the value (the variable doesn't need to be normalised.as reflective procedures that explicitly call the continuation with arguments For example a definition of look something like the following. as discussed in section 5. we have fonnulated side-effects explicit. The strategy would be to define such procedures designating the modified field and environment functions. differently. in the untyped A-calculus which makes which is certainly a side-effect-free fonnalism. and binding ENV and CONT to the environment and continuation in effect at the time of the caU. that side-effects and non. Also.) (DEFINE SETQ (LAMBDA RfFLECT [[VAR VAL] ENV CONT] (NORMALISE VAL ENV (LAMBDA SIMPLE [N-VAL] (CONT [N-VAL] (PREP [VAR N-VAL] ENV»»» (53-125) This is 3-LISP The syntax and meaning of this will of course be explained only in chapter 5.local control f. in virtue of the very architecture. which \\'e do not do in 3-lISP. Semantic Rationalisation Procedural Reflection 209 the ability to reflect is sufficiently powerful that one can obtain. the continuation is called with the nonnalised value not only as the result. for all that would have happened would be that the semantical account of side-effects would be buried inside the definition of SETQ. But the following code would work if that scheme were adopted.

From the fact tllat side-effect!. The only approacll still open. . into a much more difficult subject matter.. We would simply decline to specify the designation of 3).3. it should be noted. Semantic Rationalisation Procedural Reflection 210 explicit in the scmantical account of SETQ.and. an unnecessary defeat What it amounts to is a claim that the temporal aspects of the context of lise of an expression not only affect the dc. At the present time the author has no suggestions as to how the semantics of 3LISP can be finitely described (although there seems no doubt that they could be 2-LISP we merely lack te. we will be at pains to argue. But of course we call describe the temporal aspects of the context . as it happens. At first blush this would seem to connect the declarative and procedural notions so closely that we lose the ability to prove the evaluation theorem. is this: we should allow that procedural consequence can affect designation. rThis is one reason that merits development on its own. but that they affect it in ways which we cannot describe. If we adopted the approach just given we would have to say that the designation of any expression depends on the designation of any reflective procedures in its arguments. then. However \ve will not. l~hus this second option should also be ~ejected - particularly because it is not so much an option as a suggestion that we abandon tIle effort.·)ignation of that expression. our problem was how they were to interact with designation. that we have no principled way of saying what the designation of the whole form is. be in such deep water as all tha~ as the next pages should Dlake clear. A second possible approach to the problem of procedural dependencies would be to give up. (BLOCK (SETQ A 3) for example. can be described nothing of particular note fol1o'Ns. when faced with side-effects: to say.:hniques). the full significance of SETQ lvould be identical either l\'ay. which is merely a recasting of the same problem . for tile whole argument at the beginning of the chapter focused on how it was essential to have declarative and procedural readings specified independently "in order to prove anything about how they relate. This.. is an admission of defeat . where semantical characterisation is still tractable.a recasting. Therefore it seems unlikely that we cannot describe their declarative effect. however.the full procedural semantics function r was developed exactly in order to make them explicit. in a case where the arguments to a procedure involve side-effects. and try to layout tIle ways in which «I> will depend on the contextual modification made explicit bv r.

iiL Full Computational Significance (I) Procedural Reflection 211 The approach is simply to identify very carefully our assumptions - including the admission that the declarativ~ import of a symbol may be a function of its temporal as well as its structural context - and proceed once again to erect the mathematical machinery to honour them. is to show how manifested by c) depends on the contextual modifications that arc already adequately r. lviore precisely. we should never feel the need to give up the ground cases. Thus. What we want. we will have a new full computational siglli/icance function I (which we will call for alliterative reasons). whereas r mapped structures and contexts onto structures and contexts. although the declarative import of an expression is affected by procedural consequence. we will examine a function that maps structures and contexts onto structures. computational semantical function which is formulated not purely in aid of the loc31 procedural purposes. Docs this mean that that full computational account is the declarative import? Of course not Does it mean that the local procedural consequence and the declarative import merge'"' No. The approach we will follow is to adopt a new. but which instead makes clear how that procedural h~ve consequence affects tile full context of each expression. a kind of "grand interpreter" consequ~n:e. The examples in the last few paragraphs have indicated that only the jilll computational account of the processing of symbols will enable us to determine the declarative import of an expression. circumstances force our analysis to be.e.3. there is no need for that It is helpful to remember that the oliginal intuition in return themselves t8 ~e case of numerals - that numerals designate numbers but No matter how complex other simple and perfectly coherent. for both declarative and procedural l'he natural suggestion is to the new semantical interpretation function convey both the procedural and declarative import. and defining such a n would duplicate much of r. as well as the context information. Semantic Rationalisation 3. of type: . Thus the situation is not symmetric. instead.called lIt say . (Jesignatiolls. fully general. it does fiat itself affect context. One possibility would be to fonnulate a full declarative selnantical function . However this is wrong-headed: as we mentioned earlier. and contexts.that woe~d stand in the same relationship to ~ that r stands to it.

so the above equation we can characterise in its terms the corresponding new fonnulation of the evaluation theorem: \/Sl' 52 E S. we get the following restatements of our main theorems (evaluation and normalisation. 'will be roughly the foltowing (this is ill-defined. Scrr. since 52 is in nonnat-form.AF. we make them selectors on the sequence of entities returned by 'I' 4J 1:: (53-130) == == AE. C [l:(S. but is intended to convey the overall flavour): 'IS.E. we are by these definitions taken to IE F be asking about the first coordinate of the four-tuple designated by of Y.F. Et ·.. F. lbese not only make equations 53-128 and 53-129 meaningful. eJlEF(S). we would have a new statement of the normalisation theorem: \. What we will do is to define «I» and 'I' in tenns of the new ~. they enable us to sholten those fonnulations as well.F.else [«ItE t F1 (Sz) ::. ID) = <52' D..[X2])] Thus if we inquire as to 4lEF of a given expression Y.E. that we will define v and is for the moment strictly content-free. however.ID) = <52' D.3.AX.F . Fz E ENV. we still need to discharge this reference (although this use of c) is relativised to E1 F1 . in tenns of }:. Ez • Fz>] :> [ 1f [0 E S] then [52 = 0] . F2 € ENV.AX. E. E1 . respectively): 'IS E S. E.E 1 . E2 E ENV.AF . In order to convey a sense of this new ~.[X 1])] AE.antic Rationalisation Procedural Reflection 212 cc s X £. D € 0 [[ }:(Sl' El • Ft. E2Fz or any other context would serve as well). Ft. so that they can be used as they were before. given an essentially empty continuation. f € FIELDS [ if [tJlEF(S) E S] then [clJEF(S) = VEr(S)] (53-131) .AS[~(S. in a case where there are no side effects. Ft .~~'.C) = C('I'EF(S). C s X 0 X ENVS X FIELDS 11 (53-126) "lbus in a given context we will say that a computational expression signifies a four-tuple of a result. F)] c) (53-127) It is to be noted. 0] )] (53-128) Similarly. In particular. 0 € 0 IT I(5 t .~ X FIELDS X CONTS 1 .E. Ez E ENV. and a two-part resultant context The intent. In particular..F t .SI' 52 € S. E E ENVS.As [~(S. Ez • Fz>] ::l [[ IllE t F1 (5 z ) = D] (53-129) 1\ [NORMAl-FORM(Sz) ]]] Note that in both cases the rclationsh:p betwen 52 and 0 is expressed using «1'. a designation.

The use of the identity continuation in 53-130 is intentional. designated by AX. since (RETURN 10) is not a continuation structured in the way that would require. under this new protocol. ~Ibe easiest way to sec \vhat this rcfonl1ulation amounts to is to begin laying out the characterisation. Semantic Rationalisation else [[ 4»EF(S) Procedural Reflection 213 = tIlEF(i'EF{S»] A [NORMAL-FORM(~EF(S»]]l 'itS E S. sidc~effects I must be fonnulated in tenns of continuations. lbis is the point towards which we have been working this long white. and deserves some (RETURN comment. what would happen if we asked what designated.designation and result of the full significance. but can still compose those local aspects out of the full significance of the ingredients. on the other hand. This careful trading between full signficance and local designation is just what we want: it is too broad to say that the designation is the full significance (that is what standard programming language semantics approximately docs).F. n~mcrat 4). E E ENVS. In this new fannulation we retain the ability to talk about the local aspects . in order properly to handle of all kinds. we ask for the designation or local procedural consequence of: (PROG (I) (53-133) (SETQ I 0) A {5ETQ I (+ I 1» (IF (= I 4) (RETURN I» (GO A» Then the answer will be the number four (or the (RETURN I). of the semantics of the basic structural types and . however. Note. By 53-130. we would inquire as to Le. and this will have been determined in virtue of examining the full computational significance of the clnbedded term rather than examining only that term's local import. But this is perfectly I~ reasonable: (RETURN 10) does not really have a designation on its own. these equations closely resemble the initial versions we presented in the chapter's introduction.X the first or second element of the four-tuple signified by I("(RETURN 10).X).3.AX. or what (RETURN 10) (RETURN 10) resulted ill.E.. but it is too narro\v to say that the designation is formed only of the designation of the consitucnts (that was the error of the previous section). 'Thus the full procedural consequence of a form such as 10) is describable only in such tenns. (RETURN 10) - In allliklihood this would be ill-fanned. F E FIELDS [[ ~EF(S) = C)EF('I'EF(S»] A [NORMAl-FORM(l)EF(S» n (53-132) Except for the increased complexity for dealing with environments and fields.

F t > • [~S 1 ( F1 2 ( S) • E1 . rather than£(s. be <S. this could not be determined if continuation-passing (53-135) = i\E. of that binding. F) -+ if [S E {"T. f1. in the context of usc.AF. Xa . <Xl' x2 . might be some continuation mapping that result onto SOIne other unkno\vn entity. F. but they of course depend crucially on the environment.ed is the numeral or boolean. since continuations are applied to four-tuples). in an appropriate context. F>.F 2 >. [i\<St. thus both are context-independent and side-effect free.AE. 53-134 should be noted. Fk . ID). which is the sequence <S. E. In a more complex case. [A<S2. C(S2. we usc the identity function ID (ID is in this case ["<Xl' x2 • x3 • x. what is designated is the designation. In both cases what is retuin. else C(E(5).E 2 . T(S). and the provided continuation is All is straightforward.3. F) ~EF(E(S».> . after all. It would seem that the full N(S). ~ Procedural Reflection The first three structural types are straightfonvard: 214 =AS. the form semantics were not employed. what is designated is the integer or truth-value associated with the constant Neither environment nor field are affected.Et. More revealing than the three atomic types is the full significance of pairs: VS E PAIRS ~(S) (THROW 'TOP-LEVEL 3) might designate the number three.hat the computational significance of an expression is.i\F."C [}:(Ft(S). we have to do so in a context If we ask only with respect to a field and an environment. applied. The use of the continuation in E. N( S).Et. What is returned is the binding. we might ask for the designation of an expression that involves a control side-effect. x4 >]. F).DI(FI2(S). F1 . However to ask w. N(S).Ft).F2)])]]] . E. thus. (53-134) C(S. Atoms too are side-effect free. It is. F>. E.Dt. the full computational significance of the numeral 3 is ~("3. F)] First we consider the numerals and symbol. "NIL}] then bool(~ans. N(S). Semcultic Rationalisation the primitive procedures. E.E2.AC [case TVPE(S) ATOM NUMERAL -. in some Et and Fk . E. E. only the fact that bindings are context-independent that legitimises this ostensibly odd characterisation of their designation. however. as we have noted before. C. C( S. computational significance ofa numeral should.

if s was the 51 expression (+ 1 2). From a cOlnputatiollal point of view this meta-linguistic characterisation is 01 (F t 2 ( S) _Et • F1) inefficient. Under one. The first two are represented in this code by making the internalised function take as an explicit continuation a function that receives the full procedural consequence of the application of that internalised function. and will designate the +-closure (EXPR Eo (A B) (+ A B». in any pair the CAR - Fl(S) in the equation - will presumably designate a function.:s.this is what the metacirCtdar processor makes clear. calculating tile procedural and declarative import separately. [A<Sl. the internalised version of that function will be applied to the arguments: this is ~Sl (F 12 (S) . and the arguments). There are then. First we take CAR: . but is not something that we try to manifest in the scmanti. F1. Under the third (the Jorlna! account).E 1 • Fl. which essentially branches the nleta-linguistic characterisation of the significance of :. we will show the significance of several primitives. f 1) (since 0 1 is the extellsiolla!isation of the addition function. For example. to the full significance of that to which the CAR we can presume (assuming that the engenders no control side-effects) that D1 wilt designate that function. It should be evident that this technique. consider the various ingredients we have to deal with. ]) CAR. bears the bnlnt of the claim that the two arc to be independently specified. which is calculuatcd independently in the meta-language. 01 will designate (the extcnsionalisation ot) the addition function. although boUt dependent on the same computational contextualisation. three ways in which we expect to combine these various ingredients (those ingredients being the closure.Dl. Under tIle second. the cxtensionalised function will be applied to the arguments: this is . but it is exactly the difference between them that captures our foundational intuition that declarative and procedural import. E. this will apply the real addition function to the designations of the arguments.D 1 ( F12 (S) • E1 .. the addition function.El. Semantic Rationalisation Procedural Reflection 215 In order to understand this.. as we have pointed out before.3. as expected). Since will designate its fourth argu.C) recursively decompose in terms of 1: of their consituents. First. C). but then puts this together with the declarative import of the application.nent applied CAR the term l:(Fl(S).Fl> . the closure will be reduced with the arguments by a computational process .airs. and 51 will designate the expression evaluates (a closure of some sort. because both and ~SI (F 12 (S) _E1.. presumably). F. arc nonetheless distinct In order to illustrate the lise of this reconstituted I.

We give first its new general definition on non-primitive closures. Ak E ATOMS. again).Dz. Semantic Rationalisation I(EoFo{"CAR» = Procedural Reflection 216 AE.F o• [A<V t . . not four (an example of such a appeared in 53- 'is € S. it in that context (E l Ftl(A). that the CAR-closure X) designates the second argument would have to be proved - this presumably can be done. Note that 136): is not a full continuation. The full intemaliscr A has to be mildly redefined so as to deal witll a C· :E that yields s~nsc four-tuples. Then CAR which is of course the CAR of S2 in field Fz• Thus designate tile first element of the pair designated by their This is entirely to be expected. l1te normal-form CAR is the closure of the procedure. First. this is unchanged from before). Ak) ~)' (53-137) = ASo·AEo·AFo·AC* [~(Fl(S) . [A<A. Second.Eo.AF.Ez. as usual: its nonnal-form.. below. characterisation of CAR will pick those up explicitly.D z .A z . so there is no Itarm in ignoring them here. which is described separately. its designation. F) I(Fl1(A). The function that it designates is the crucial thing to look al It is a function of three things (all designated functions arc called with three arguments: an argument to the application and a two-part context first obtains the significance of its single argument the crucial part comes: applications in terms of arguments. and F1).El. First.F 1 • [A(V2 .F 2 > • ..Ft. .AC . F2 is ignored. Thus right away we see that in this environment (the s-expression "(EXPR EO (X) (CAR X))) CAR is side-effect free.F2> • FZI(Dz)]])] This can be described in English as follows.D t .E 1 . (EXPR EO (X) (CAR There are various things to be noted. in the C· that it is a function of three arguments..3.F 1> · [I(F l t(F 12(S».El. E € ENVS [L\r" (EXPR ~ (AI. CAR is a procedure whose signficance is that. Otherwise the context returned by as Ez.F t > • E.althougll it consistently ignores the denotations.Et.[A<Sz. it is only the designation O2 of the full significance of At that is given to the CAR function (F 21). . f 2 1 (D 2 ). A1 . in a context (E and F).E 2 .Az. it straightforwardly signifies (calls c) with a tuple of four things. and the context unchanged (E and F.. (53-136) [C("(EXPR EO (XJ (CAR X)). The full ~.

F) (53-139) AEOF O{"+) == AS.Dz.03)])])] E.M(B»)]. C{Fl(S).F c ) • C*CSc.F.E. [A<A.Et.F 1 > • F1 1(A)] E.E t .F t • [A<Az.F) (53-142) . AC • [~(Fl{S). we have to provide the intemalisation of all primitives. [A<A. of + and QUOTE: 1:{E oFoC"+» .D2 .D t ..Dc.AC .fl. F. C([F t l{A)]. [A<A.F3 > • +(02. AE •AF .E 1 .F t .a AE.AE.AF.E 1 .E 2 .E 1 .F z> • :E{ F2 1( F1 2(A».AF.F t ) .E*.[A<Sc.F t > .D 1 . Ez • Fz • [A<A3 . [~(Fl1(F2{S» ["<A. F) AEoFo{"QUOTE) == i\S. [C("(EXPR EO (8 C) (+ DC). for illustration we first present it for CAR: AEoFoC "CAR) (53-138) == AS.Ec.·]]]]] where E* is like E except that for 1:S1~k E*CAt)=V t • As before.E.Ez.Da.F 1 ) ] ] We also give the full significance.Ez.Ek. [A<B.E 1 .E.F l )]]]] (53-141) = AE • AF • AC • [C("(IMPR EO (X) X).Fk. and the internalisation.Fc)])].AC .F t ) • ~(Fll(A) .F 2 ) ~(EoFo("QUOTE» • C([M-t(+(M(A).AC . [~(Fl(S) (53-140) • .E a .AF. Semantic Rationalisation Procedural Reflection 217 l:CS.3.AE.

Ft. I(Ftl(A). An Example To step through a particular example will be instructive (if a little tedious). [A<A. l [AS 1 ( F1 2 ( " (CAR ' (A B C))). [A<S2' Ez • F2 ) • (ID)<Sz.Et.e. 51 will bind to the closure that the inlerllaliser will subsequently also take onto the CAR function. [A<SI. ["<S2' E2 • F2) (ID)(5 2 • • ([A<A.F z>])]]] Now equation 53-136 applies.Et.El.02.Ft) . [&SI(F 12("(CAR '(A B C)).F 1 ). Et • Fl. E2 t F2) • (ID)<S2. F2 1(D 2 ) ] ) ] . Fa.E 1 . '(A B C)). Eo. E1 • Fl' ["-<S2. Semantic Rationalisation Procedural Reflection 218 3.Fl). Fl> . E2 • F2 > • ( I D) (S 2 • D1( F12 ( " (CA R '( ABC) ) ) • E1 • f 1) • E2 • F2) ] ) ]] ] This is merely equation 53-135 with our particular arguments filled in - this is legitimate Fa: because (CAR t (A B C» is a pair.El. since EoF o( "CAR) is primitive: (53-145) ([A<Sl.E2.Dz.F2 • F2 1(Dz )])] Eo.Dl.[ASz.Fz <F 02(" (CAR '(A B C»).F t ) • l:(Ftl(A). D . allowing the significance of CAR to bind in a context and an argument structure. Fo» We perform the first reduction. Eo. Fo• [A<Sl. Fo• 10) Eo.[ASz. 01 will bind to the extensionalisation of the CAR function.Fl. as we will see (tllus preparing the way for the declarative and procedural consequence being the same).E z . ([d("(EXPR EO (X) (CAR X))] <F 02("(CAR '(A 8 C)). Eo. E2 • Fz>]» . Eo. Fa». We will look at the full significance of (CAR '(A B C» ~("(CAR in I-LISP under this new approach: (53-143) = [l: ( F0 1 ( " (CAR ' (A B C))).Et.F t > .3.D 1 (F 12("(CAR '(A B C))).iv.El.E t .Ez~Fz>])]] ("(EXPR EO (X) (CAR X)). • First we perfonn the CAR operations out of = [~("CAR. Et. Ft) [ AS 1 ( F1 2 ( (S3-144) " (CAR ' (A Be»).Dl(Ft2("(CAR '(A 8 C»).F 1 • [A<S2. (53-146) Fa. Dl.E2. Et.

[~(F01("(QUOTE (A B C»)).Eo.D2.Fo.F2 • FZ1(Dz)])] Then we can proceed to calculate the deciarative import. rather than "2". Nonetheless it affords a good example of the full significance of the paradigmatic First we apply I in the general case for pairs (the internal continuation from above has been renamed. Eo.3.Eo. • {[A<A.F 2 )]» <"('(A B C»). • ~(Fll(A).F o• [A<5 2 . side effects.[ASz.D2.F z>]» [~(Fl1("('(A B C»)). to avoid confusion): = ([4("(EXPR EO (X) (CAR X)))] <"('(A B C)). in an a-conversion.F 1 > Ez. what the whole We will turn to the calculation of what it returns presently. [A(Sl. F2 1(D 2 ) ] ) ] .Et.Et.Eo. Ez .Dt.E2. (53-148) ([A("(EXPR EO (X) (CAR X»)] <"l'(A B C).Eo. \\'e are instead in the midst of calculating. [A<Sz.Eo. expanded the term representing the internalisation of the expression designates. (A 8 C) to its fun representation (53-149) = ([A("(EXPR EO (X) (CAR X)))] <"('(A B CIT. CAR Note that we have not yet closure. from the semantical characterisation of the ingredients. which our example will not illustrate. Ez • Fz) · <SZ.Fz . and perform the two on Fo: = ([~{"(EXPR Fa. E2 • F2 ) <S2. to use "3" subscripts.E2. F2 > • <sz.E t . [A<Sz.Eo.F o».[AS2. Eo. • Ez. Once again performing a as "(QUOTE (A B C»)): CAR ofT F1 (and expanding the " .Fl.Fo. This subsidiary call to ~ by the declarative significance of CAR is necessary in case tllcre are IMPR.F o . E2 • F2 ) <52. Semantic Rationalisation Procedural Reflection CORS 219 We can remove the identity function.F o• [A<Sz. . EO (X) (CAR X»)] (53-147) <"('(A B C».F 2 >]» [~("(QUOTf (A B C»).F t > (S3-160) Fo• • [AS I ( F12 (" (QUOTE (A B C»).D2.F2> • F2 1(Dz )])].E2. E2 . of course.[A<Si.

.E t .Eo.F z»])]] We can bind the context and arguments into this full significance: = ([A("(EXPR EO (X) (CAR X)))] <"('(A B C)).f z>]» Ez. Doing the CAR on Fo extracts the QUOTE function explicitly: (Sa-161) = ([A("(EXPR EO (X) (CAR X)))] <"('(A B C)).Eo. F3 t(D 3 )] <52.E t . E2 .F t > .Et. F3> • F3 1(D3 )] <52' [D t (F 12("(OUOTE (A B C»)).Ea.F z>]» [z.F3> .[A(A. Now equation 53-141 defining the procedural consequence of QUOTE applies: (S3-162) ([A("(EXPR EO (X) (CAR X))] <"('(A B C»). .Eo. Semantic Rationalisation Et . El. <Sz. F3> • f 31 (D3 )] <52.F o».3. E3.F o• [A<Sz.F o• [A<Sz.F 1 )].F z»]».F t > Ez.Et.F o». D3. [0 1 ( F1 2 { . D3. [D t (F t 2("(QUOTE (A B C»). <F 02("(QUOTE (A B C))). F1t(A)] . Procedural Reflection 220 Fl' [A<5 2 • EZ ' F2 > . E1 • Ft. Fl> t.F 2 >]» <"(IMPR EO (X) X). ([A<A.Fo.F 1 )]. Ez • Fz> • <52. • [AS t ( F1 2 ( " (QUOTE (A B C»)).F 1 • [A<Sz. ["<52' E2 • f 2 ) • ([A<Sa. E2 • Fz> • ([A(Sa. Ez • Fz> <sz.F o• [A<Sz. F3) • F3 t(Da )] 3. .F z»])]])]. • ([A<SI. (QUO TE (A Be) . Fl> • [~Sl(F12("(QUOTE (A B C»)).Eo. E2 • Fz»])]j)].Et. Ez • F2 > • ([A<Sa. [A<St. Ez.Eo. E1 J F1 ) ] • E2 . D El. D Ea.Da. Dt. [~("QUOTE. Ea.E o. F1 l(A)].) ) .Eo. (53-163) ([A("(IMPR [0 (X) X)] <F 02("(OUOTE (A B CJ).F o• [A<5 z • E2 • F2 > • <52. ([A<Sa.

Da .Eo.F O• [A<5 2 • Ez• F2 ) • <52' ([!("(IMPR EO (X) X)] <"((A 8 C)).F t > .\(5 2 . (53-167) • ([A<S3. ~2' F2 ) • <52. Fa> • F3 1(D3 )] ° It is now straightforward to take the Fo CAR: thus indicating that QUOTE returns its first argument. this fact is ignored.E3. Ft l(A)]<"((A B C)). Ez.E.3. Ez. EJ. .F o• C(fl(S).Eo. f 3 .F O' [. D3. Ez.F 2 > .AF. E2 • FZ > • ([A<Sa.F 3 > • F3 1(D3 )] Ez.Eo.F t > . What proves of interest is the designation of QUOTE. Semantic Rationalisation And perform the two ofT Procedural Reflection 221 CORS F0 to pick up the arguments to QUOTE: (53-164) = ([~("(EXPR EO (X) (CAR X)))] <"('(A B C)).F 2 >]» ([A<Sz.Eo. ([A<S3' 3 .EO.Ez.E 1 . Ft l(A)]<"((A B C)).Eo.F o• [.F3> .F z»]».Fo».EO.E 2 . Ez . Fz> <52. However.Ez.AE.F z> • <52' <Sz.i\C • 8 C).F z))] <F 0 1("((A B C))).([A<A.Eo. ([A5. QUOTE Next we need the internalised version of ([~("(EXPR from equation 53-142: EO (X) (CAR X)))] (53-166) <"('(A [i\(5 z .\<5 2 .F o• [A<Sz.Et.F z»]»' Which we can then reduce: ([~("(EXPR EO (X) (CAR X)))] (53-156) <"('(A B CIT.F z)]» <52.f a) • F3 1(D3 )] <"(A B C).F o».F o)). Ez. which is no\v applied to Ule original arguments: = ([A("(EXPR EO (X) (CAR X)))] <"('(A B C)).D3.F a».E 3 . F31(D3 )] <52.Fo~ [i\<Sz.F)] <"((A B C)). since we arc aiming for the designation of (QUOTE (A B C». ([A<A.Eo. Ftl(A)]<"((A B C)).Et.F 2 >]» ([A<A. Ez • F2 ) • ([A<S3.Eo.F 1 > .

E o .E 1 .Ez.F 1 ) • C([F t 1 CA)].Eo. Semantic Rationalisation Procedural Reflection 222 Eo.Et.F t > . This half of the derivation.F o»]. will be quite brief: because some of the intennediate results arc the same as ones we have already calculated. however.F 2 >]» ([A<A.E 1 . are at this point dropped.E 7 . that we' can do now: (53-161) ([~("(EXPR EO (X) (CAR X))] <"l'(A B C))). and the details can now be spelled out. it designates the We have not yet spelled out hOYt the intemaliser in this reformulation works. we have proved that.F.F 2 >]» .Eo.F z> <S2' (X) (CAR X))] (S3-168) <"('(A B C)).E 1 .E 2 ."A.Eo. Fz> .F o.[F ol(F ol("((A 8 C»»]. Ez . [i\<S2. <Sz.F o' [A<Sz.F o .i\C .AF. Ft l(A)]<"((A B C»).F o• · [F 01([A<A.E. Note that S3 and E3.F z)]» '( ABC» Finally.Eo.3.F z)]» Thus we have shown that {QUOTE (A 8 C» designates (A B C). [I(Fl(S) . EZtF z>]» F1 t(A)]<"((A B C)).F t ) ] ) ] ] <"('(A B C»). EZ.Eo.AE.E 2 . Ez • F2 > • B <Sz.Eo.F 2 >]» CARS Now we perform the inner of the two indicated = ([&{"(EXPR EO (X) (CAR X»)] off Fo: (S3-160) <"('(A C». returns. which have been brought along to establish the correct context. E2 • Fz> • <S2. The outer CAR (off Fa) is the explicit CAR from {CAR {QUOTE (A 8 C» ."A. (53-162) [i\(A. but its intent is clear.[A<Sz.[F ol{"(A 8 C»].F t > .F 2 ) • (S2. independent of what C CAR atom A (indicated in the meta-language by "A). Fo».F O>)' We can now apply the designation of QUOTE as indicated.E z . F3 is used to do the CAR (in case an intervening RPLACA had actually modified the fann under processing): = ([A("(fXPR EO [A<Sz.D 1 .Ez. Another reduction: ([A{"(EXPR EO (X) (CAR X»)] <"('(A B C».F o• (S3-159) [A<Sz. The intemalisation of the primitive CAR closure we obtain from equation 53-138: ([AS.

\Vc have proved that the expression returns the atom A.F 1 »])] And: = [~("(QUOTE (A 8 C)). F11(A)]<"((A 8 e»)."A.AC .F 1 > .E z . (CAR t(A B e» both designates and without side effects. <Sz.EO. ([A<5 z . continuation this time.vas returned: = ([A<Sz. Semantic Rationalisation Proceding with the reduction: Procedural Reflection 223 = [}. E2 • F2> S <SZ' " A. [A(A. all that remains to reconstruct our previous machinery in this new fonnuiation is to define new versions of EXT and they would be used.F 2 >. Admittedly we have a different But of course we have already gone through the detennination of the full significance of (QUOTE (A 8 e» in 53-151 through 53-169.D 1 . and show how of the primitive addition procedure was as follows: l:(EoF o("+» :I (53-169) AE.F 2 >] <[F 11(A)].E 1 . .E 1 .D1.Eo. ([A<A.F o» ([A<A. In particular.Ez.F z>] <[F 1 1(A)]."A. This time when we substitute we ignore the designation.F t »] (53-165) <"(A Eo.F t > B C).F z>] There is one final CAR <[F 0 1("{A 8 C»].AF. we noted that ~ INT. Thus we can step immediately to the result: .Fo• • (53-164) [A<A. [A<A. [C("(EXPR EO (8 C) (+ B C). E2 • F2>] <[ F11 ( A) ] • E1 . but the computation is tile same.:(F 0 1("('(A B CJ).F a».F t ) • ( [A < 2 .E 1 .Eo.E z .E 2 .F o» Fo: (53-166) to be perfonned in (53-167) And finally we can apply the final continuation: (53-168) We are done.Fo .E z .E 1 .F 1 ) • (53-163) ([A<Sz.E 1 .3.F z).Eo. F1 ) ) ] ) ] above.Et.F 2 > . "A. <Sz. As expected.F 1 > • .D 1 .E 1 .Ez. <52 . We will not trouble with more examples. and concentrate on what .

>· • [1':( FIt ... )])])] G(D 1 .EIt. It differs from the previous one in just the way we would expect: rather than simply referring to the designation of the arguments in the context of use of the whole.AF.Ez. but in the end applies the original function to the s~t of designation~ returned (S3-171) EXT == i\G. closer to the head than) the current argument position do not affect tile processor's access to subsequent arguments. ) ) >] A.F It >... ( F2 ( A) ).D 1 . as each argument is extracted. of course. Ez • Fl . (S3-173) [C("(INPR EO (X) X).D2 Note the usc of different fields itl each of the CORS...E t . in such a way that side-effects to that list before (Le.Dz. INT(AX. it iteratively steps tllrough the full significance of each argument... because the arguments are not processed: I NT == i\G. F)] Th~se considerations suggest the following definition of EXT.\<8 2 . ».E.F t ) • 1:(F 11(FZ{A» ..AC .F> • ~(FI(A).EI.X). [A < E• F> . ( F1 2 ( F2(A» ) [A<Bk. G<F1( A) .F I • [A<Az. EXT(+) E.t l( FIt .E a.Da . reflecting the fact that the processor steps down the argument list.D2 • E2 • F2 I( F2 1( F1 Z( FZ(A») .F 2 • Proc-edural Reflection 224 E. (53-172) Thus for example we have the following full significance of ~(EoFo("QUOTE» QUOTE: = AE.F t [.22{ .AF.3. E2 • f z. Semantic Rationalisation I(F 11(A) . (53-170) [C{"(EXPR EO (B C) (+ B C}).AC .F z> • :E(F Z1(F I 2(A» . F • [A<8 1 ..Da)])])] It is the second argument to the continuation that is in question: it would be easier if we could have said: ~(EoFo("+» = AE. The corresponding definition of INT is far simpler.E l . F)] . F1( F2 ( A) ) . Dk )'])] . F) [A<Aa . F1 ( F2 ( .. E.F 3 > · +(Dz..E z .[A<A.Dk. E.. so as to deal effectively with side effects.

ng-range goal of reflection (and v:e have probably a~~cd as much patience of the reader as can reasonably be expected). we have spent as much time on semantic characterisation as we can afford. F"irst. however. that we have. and in some cases does not. but not when one first LISP is dc-referencing just ill case the referent is in the structural field: we now should prove. Sufficient distinction between them remains so that we can examine. we arc far from done. and simjJ/ijies otherwise.e. dereferences if it can. The Evaluation Theorem In spite of the extent of the explorations of section 3.obvious given our long exposition. whicll by rights If we were to set out on that project. we would adopt the following strategy.' Nonetheless. because we will have a notion of normal-fonn available in which to cast the answer. and we have shown how the significance of composite structures derives from the significance of tile parts. we would define as standard any 1-LISP procedure with the following property: all . however.ii.3. Semantic Rationalisation Procedural Reflection EXPR 225 It would be convenient if we could similarly define an theoretic ~Jnctions and IMPR as meta- that would generate the internalisations automatically. we would have to define the intemalisations individually. It is EVAL natural to ask) when one first encounters this fact. This is the observation we have called the evaluation theorem. accomplished our main task: we have provided a mechanism whereby the full significance of the prhnitives can be defined. in outline at least. whether there is "method to madness": whether there is any lurking fact that determines when considers the situation is a clear "yes": evaluation in LISP'S ~valuator derefercnccs and when it does not. The answer . 3. fashion. given our :(. the relationship between its resuit and its referent 'tf we were to proceed in this fashion. In 2-LISP we will be able to do this. For tile present. in a partially related. but not identifiable.e. lacking such apparatus. We have indicated as well how both declarative and procedural import are carried by this full significance. sea.ting out the primitive significance (and internalisation) of all the primitive procedures types)f we would of course see that EVAL (h~~ have already done this for the structure LISP'S ~ the projection of ooto its first EVAL'S coordinate - in some cases derefercnces its argument. v. It should be clear. for any given expression.

returns an object within the field. W'e would have. are (bound jn the initial environment to) standard procedures for the first reason. but it is not so immediately clear that it will always be the same objcct. would also be standard. In other words we would have to show the compatibility of the following two . since that is implicated in dctcnnining the local procedural consequence of CAR applications. cI-EF(P)]]]] (53-176) AS € S • [VP E PAIRS. for example. The proof would proceed first by showing that the atolnic structure types obey the evaluation theorem immediate that CAR. returns the result of one of its second or third arguments. that designated a function whose range was outside the structural field. Thus the range of IF includes all of 0. In addition. depending on the first: (I F T 1 'A) designates the number one and returns a co-designative numeral. This is not quite as simple as it might seem. Falsity} 1 5] :J [1' [fltEF(P) E S] then ['1'EF(P) • 4'EF(P)] else [tIlEF(i'EF(P» :. Then we would show that all the primitive procedures are standard. and designates an object within the field. thi~ we have essentially shown already. E E ENVS. The conditional 1F t + is similarly standard. would be called standard. for example. complement (IF F 1 'A) designates the atom A and returns that atom. )1] if [CZ-EF(5 1 ) E $] then ['i'EF (51) • -tEF (51)] e7S8 [fltEF('lrEF(St» • fltEF(SI)] (53-174) This can more properly be put as: STANDARD EI : CS -+ {Truth. any procedure that designated a function whose range was entirely witllin the any procedure structural field. CAR and QUOTE.. to examine the primitively provided intcrnalisation of CAR.. F E FIELDS [[Ft(P) II For example. for example. IF is standard in the sense just defined. for the if its designated range cannot be for example. second reason. However a procedure can be standard even classified as either in or outside of s. The intent is carried by the following infonnal characterisation: STANDARD(S) a for (51 :I r"l! . it is for example. whose significance was correspondingly such that any application in ternts of it would return a designator of its referent.3. not just S or its Nonetheless. Semantic Rationalisation P!-ocedural Reflection 226 applications in tenns of it satisfy the theorem. and whose computational significance was such that any application in terms of it would return its referent.

D 1 .. because a proof that pairs satisfied it would follow directly from the fact that the tenn in procedure position must be standard. that the approach is not specific to this particular theorem.AC • [1:(Ft(S) .ElIFl) (53-176) • I(Fll(A).3. that designation is always preserved - given a different 2-LISP notion of what counts as being standard. Once the primitives had been proved standard.E 1 . designation. Note. [~<A.AE.E2. ). the same technique could be used to show that 2-lISP satisfies the normalisation theorem - i.AF. F) and: AEoFo("CAR) :s AS. we leave it . Though involved.Fl. this could presumably be done. not do this here.AF. It would then be immediate that the dialect as a whole satisfied the theorem. we would then demonstrate (using recursion induction) that all compositions and all abstractions definable in terms of the primitives were also standard (by looking at the full significance of arbitrary closures. It is not immediate that these imply that 'ltEF("(CAR One strategy that might be of help would be to define a function STANDARD-PRIMITIVE that would simply assert the above two ch~racterisationst given two inputs: it could then be used to defille the primitive import of various of the provided procedures. however.El. .AC • [C("(EXPR EO (X) (CAR X)). and intcmalisation all worked in step so as to preserve "evaluation" properties). however. It is with this strategy in mind that will be presented in the next chapter.E.F I (S3-177) [A<A.FI) • FZI(D1 )]])] E. We will. Semantic Rationalisation equations defining l:(EoFoC"CAR» CAR: Procedural Reflection 227 • AE. .Dz..E t .to employ the standard dodge as an excercise for the reader.f 1 )]] ••• ) • «bEF("(CAR .[A<Sz.e.F t > • C([F 11(A)]. and showing that procedural import..

the concepts of simplification and reference we have used here are borrowed without apology from logic. that a revised dialect should be based on a computable function 'I' that is designation-preserving. and rather partial notions.3. But so far the analysis has been symmetric: one could equally well conclude. that simplification and de-referenCing were two somewhat related. is to say that we have shown only how the theoretical categories of two disciplines relate. that our stand against evaluation would long since have been taken. lbc notion of evaluation is by all accounts a natural notion of computer science. explicit or implicit. in other words. by this point in the analysis. Indeed. From this suggestion emerged the suggestion that v take expressions into nonnal form. before moving to the design of 2-lISP. therefore. To\vards a Rationalised DesIgn What then have we learned from this analysis of categories of semantic consequence is bothersome. as summarised in the theorem bearing its name. and philosophy. It might seem. in an attempt to Jay to rest an}· . We have suggested as well that the de-referencing behaviour implied in the received notion of evaluation is problematic. therefore. I-LISP? First. provided sufficient ammunition to enable us to choose one as better. the inelegance that resulted did not simply make programs more complex: it mandated certain uses of metastructural machinery that were not strictly necessary (that is why a matter of aesthetics is of such concern to us). Semantic Rationalisation Procedural Reflection 228 3. We have not. 11lere are two questions that still deserve attention. we have seen that the lack of category alignment between the typology of the structural field and the Furthermore. to the mechanism used to compute '1'. this is our position. The first has more to do with the relationship between evaluation and reference. eae}l ineffectually covering a piece of the far more natural concept of evaluation. This can readily be repaired in a new design. mathematics.t:i. we will focus on the concept of evaluation in its own right. Another way to make the point of the last paragraph. in a particular instance.r. that evaluation conflates issues of expression simplification and term de"referencing. We seem to have shown. if we did not examine the issue further. but we have not yet de/ended it: all that we have demonstrated is that there is a particular correlation between evaluation and reference (providing you accept our account of the referential import of LISP expressions). In section 3. and that that declarative interpretation function should be defined without recourse.

Indeed. we have not yet said very much about what the concept of Donnal fonn should come to. It will thus be appropriate to examine this notion further in section 3. That third characterisation will t-LISP meta-circular processor. except to remark that the definition of this notion used in the A-calculus - based. LISP 2-LISP. since once we have an appropriate definition in hand we will be sufficiently equipped to set out on the design of In chapter 2 we embedded a simple theory of meta-circular processor. on the concept of not being further p-reducible - fails to meet our that of being standard of category identifiability. In chapter 5 we will erect our third meta-theoretic characterisation of LISP. without regard to the structures in terms of which they arc implemented. that theory was of the procedural import of current chapter we constructed another theory of LISP. In section 3.t:iii we will review a variety of the features of our meta-theoretic account that. we will therefore make plain our final position. In the this time encoded in a A-calculus meta-language. Secondly. the chapter will end in section 3. s-expressions. LISP. Finally. although they did not merit mention while we were in the midst of describing the reflective goals. the tension between our declarative stance and the behavioural (instrumental) cast of the procedural tradition is strong. will tum out to be important when we take up on data abstraction.t:iv with a short discussion .3. We mentioned at the outset that there were various properties that should be associated with any nonnal-fonn designator - context independent.but we have said nothing about how a computable notion of nonnal fonn is to be defined. within by constructing a As became much clearer in the more detailed analysis of the LISP prescnt chapter. Procedural Reflection 229 It is one goal of this dissertation to convince the reader that the very concept should be struck from our theoretical vocabulary. of both the declarative and procedural import of the clements of the structural field. side-effect free. this time within the code of the in some ways be like the 3-lISP reflective processor.included by way of a footnote I-LISP. Semantic Rationalisation lingering feelings that we are treating it unfairly. It win have occurred to the reader that our considerable emphasis on the . and deserves at least SOUle comment Although we . essentially.t:ii.declarative import of atomic and composite structures would seem to fly in the face of the received wisdom that one should define data structures behaviourally. and in some ways like the meta- linguistic accounts presented here in chapter 3. and stable .

the apparent conflict between them will have to be explicitly defused. evaluation In particular. self-evidently tractable. then we could perhaps prove that this mechanism indeed embodied the independently formulable notion of evaluation. we expended considerable effort in the previous sections to characterise it precisely. is that we have no such independent notion of evaluation. The critique of evaluation requires further argument.lne. and therefore evaluation cannot be something that any fonnal processor can itself effect. and cannot. Alternatively. LISP. because of this. Rather. if a fonnal mechanism were proposed that was claimed to effect an evaluation mechanism. Semantic Rationalisation Procedural Reflection 230 will argue that the two positions are not fundamentally opposed. The problem. then the received understanding of it fails to be evaluation. itself bear normative weight. Given this structure. We wilt look at these two options in tum. it fails to cohere with the prior attribution of significance. Third is an aesthetic claim that.in fact it is addition. they are not fonnal notions. or a concept playing such a cornerstone role in some theoretical structure that its utility could not lightly be challenged . 3. if it is claimed independent II 10 be all °tion. At least we have no lonnal notion: to the extent that there seem to be pieces of a natural concept.j:L Evaluation Considered Harmful The evaluation theorem simply states a tonnal relationship: it docs not. it is important to establish that attribution independently of the procedural treatment of formal structures.then we might be able to argue from first principles for what the value of any given expression should be. . the procedural treatment should emerge as semantically coherent. we will reason as follows: if we had an independently definable notion of a pre-theoretic or lay intuition that this formal concept was intended to capture. in terms of the prior account. however. First is the recognition that computation is based foundationally on semantical attribution. Subsequently. once this attribution is set forth. the claim is that if evaluation is taken as a procedural reg. The stnlctttre of the argument should be clear.3. Second is the claim that. We are not claiming that it is incoherent as a procedural regime . has survived unchallenged for two decades: in manner. we challenge evaluation in a double after all.

and x is 16. a third notion of value. do we refer to abstract mathematical entities.common both to evaluation and to applica'. is the number 5. since it is not quite clear whether it is the function that has an argument-relative value. enough. Thus we may ask x Y) is. what (+ with caution - A second. The usage is a little strange. Similarly. 3X would be said to have a value of Similarly in first order logic. stemming from mathematical and logical traditions. and one that engenders far If any particular variety of object has an unchallengeable claim to having a value. and we will continue to use the tenn more confusion. and is involved with the use of the tenn application: a paradigmatic use of the term "value" is with regards to a function: the value of a function applied to an argument is the clement of the range of the function at that argument position. Finally.o~ which we will subject to the same scrutiny - is one of distinguishing use from mention: in employing these tenns. that possesses the value. it would seem to be a variable. Y is 10. Thus the value of the addition function. the value of the square-root function applied to the number 169 is the number 13. One has to do with functions. 62. perhaps an extension of the foregoing usage. a sentence like might be said in a particular world to have a value. This expression. In mathematics. applied to the numbers 2 and 3. has to do not with particular variables but with whole expressions. and if the value 0/ Y is four. Semantic Rationalisation Procedural Reflection 231 The basic problem . In fact the very use of the term "truth-value" betrays this assumption. refers to what the term deflotes. for example.3. in other words. has to do with variables. do we want to say that we apply the mathematical addition function to two numbers. such tenninology is clear in such a circumstance. Historically. or to structures that signify those entities? For example. only partly related use of the term "value". if x is 2. From an informal standpoin~ however. or do we want to say that we apply an expression that designates that function to two expressions that designate numbers? Both ways of speaking are coherent. like x + [MORTAL(X) /\ SAD(X)] (Y • Z/3). it seems uncontroversial to evaluate an expression. In the mathematical examples. In both of these last two cases it is clear that the value of the variable or expression is the referent or designation: the value. but we cannot use the same term to refer to such crucially distinct circumstances. or whether there is an abstract application consisting of a function and arguments. the value of the variable x was assumed to be the real . if the value of x is three. there seem to be three standard uses of the terms "value" and "evaluation".

to reply that the answer depends on whether one is using Arabic or Roman numerals. This referential or designational sense of "value" is reflected in the use of the phrase "valuation functions" for what we are calling interpretation functions: the main semantical functions that map signs onto significants. on the standard reading. Some readers may object to this claim. A possibly reply to it that might be offered to counter our objections one we might expect to hear in computational circles 2 3) It is that I-LISP. This is incontestable: if the value were the numeral.fUnction it would seem that it should return the value of its argument. it would make sense. not the numeral 2. It is of course possible that the value of a sign may itself be a sign (since signs can be part of a scmantical domain). there is no problem having a computer evaluate "( + if we take numerals to be self- referential in just the sense that we saw numerals to be "self-evaluating" in Certainly this is mathematically tractable: no special problems are raised in the matltcmatical model theory by having certain objects be their own referents. . This can be put more strongly: to evaluate is to dereference. Similarly. but it nonetlleless follo\vs that no expression in a fonnal system can properly be said to be evaluated that designates an abstract entity such as a number or function. not a designator or name. then the value of the existential variable is the philosopher himself. implying that evaluation must dereference its argument. This is crazy: the value is 5 independent of symbology precisely because the value is the number. In sum. and that y is the object desigllated by that term.3. if we said that the open sentence [MORTAL (X) A SAD( X)] was satisfied by Socrates. No COlnputer. or an external object like a person or table. The same referential sense is reflected in Quine's dictum that "to be is to be the value of a bound variable. but if evaluation is a . Semantic Rationalisation Procedural Reflection 232 (platonic.16 (a maxim that accords well with our definition of an object as the referent of a noun phrase). This conclusion immediately raises trouble about the proper use of the term "evaluation" in a computational context It seems established that evaluation must be a process defined over signs. can evaluate the expression "(+ 2 3) If. to say that y is the value of x is to imply not only that x is a sign but that it is a teml. The problem is much simpler: as we have said before.. as any number of semantical accounts have shown. not a sign designating that number. on being asked what the value of x + Y is when x is 2 and Y is 3. whatever) number two. in other lvords.

is . we are not simply attempting to erect some mathematically coherent structure: we are attempting to make sense of our attribution of reference to formal symbols. in other words. such questions do not need to be answered in this context. it should be clear. What we arc left with.the extensional. multiplication. We will not have to change its behaviour: what is under attack.on would then have to claim that he or she is using the word "addition''. not over numerals. 2. since addition is defined over numbers. The only possible result of suell an approach is the kind of confusion we are trying· to rectify: a dissonance between our natural understanding of computation and our fonnal analysis of computational systems. in other than their normal sense. In sum. referential ones . note that nothing is being said about whether people can evaluate an expression such as (+ 2 3): it is by no means clear what it is to say of a person that he or she evaluates an expression. as well as "reference". is forced gradually to sever any connection between what we claim the machine is doing and how we understand what the machine was doing. Fortunately. There is simply no possible doubt that every computationalist takes the numerals numbers I. In passing. or whether there is any salient notion of output or result of such a process. One would have in addition to reject all the claims of the standard denotational semantics accounts saying that LISP procedures naturally designate functions. Such a pen. Nor is there solace to be found itl a position that says that computers can access actual Platonic numbers (whatever they might be) as well as numerals. however.3. Such a person. etc. Anyone who attempts to hold the view that numerals are their own referents must suffer the embarassment of admitting that the expression (+ 2 3) has nothing to do with addition. since that violates the fundamental notion of computation. 3.not the computational ones. As we have held all the while. Semantic Rationalisation to say that Procedural Reflection 233 numerals refer to themselves is false. is the conclusion that we must be more careful in describing what 1-LISP does. This is made self-evident by the fact that the operations we define over them we call addition. there is simply no tenable retreat to be found in this direction. since the notions of value and evaluation in the llleta-languages employed ill those seman/ieal endeavours are the notions we have just endorsed . since it is not clear whether to do this is to compute a ftlnction in any sense. and so forth to designate it is almost impossible to overcome the natural tendency to do so.

(PLUS "PLUS" The question we need to resolve is whether the expression It is applied to the expression (3 4)". we are saying that in doing that 1-LISP cannot be said to be returning the value of the input expression. rather than two.cal levels. The trouble arises over whether application is a function defined over abstract functions. yielding the expression "7". The situation will be made clear by considering the following diagram: (53-178) Reduction FD: Func. the idea is that a function is applied to its arguments to determine a value: from this application would seem to be a relationship between functions. because it relates three. yielding the 1l1ln. The situation regarding function application is only slightly more complex than evaluation. objects of some variety. Infonnally.a term to take the place of the APPLY of I-LISP. The consequence. is using terms that cross selnanl. however. we are asking whether one applies one applies FD F to A to yield v. is that application is not what APPLY in I-LISP does. of course. such as . however. problem in typing "(+ 2 3)" Procedural Reflection 234 We are not saying. since that function is defined over expressions. This is the usage we just agreed to maintain regarding values. arguments. Semantic Rationalisation our account of that behaviour. Dasi Application In the terms of the figure. not over abstract functions. in an effort to maintain at least a modicum of clarity on this subject. so it is nanlral to use application in the same way. Consider an expression such as .3. implying that \VC need a term for the fonner . What we will strictly want to avoid. or over exp~essions. or whether the addition fUllction is applied to the two nUl1lbers 3 and 4. or whether 3 4)". that there is any I-LISP to the interpreter and having it type "6" in response: rather.ber 7.. to AD to yield VD. are coherent: we have agreed to lise application for the latter. in other words. Both concepts. and values.

reduction in this new sense is in point of fact reductive of complexity in the general case. except that it should designate the value of the function at that argument position. It should be clear that in I-LISP the function relationship among relationship among fD t AD. In the remainder of this dissertation we will adopt the following definitions. The other relationship - among FO. Thus we will say that the function designator "+" and the argument designator "(2 3)" . because names are looked up. altllough it should be straight away admitted that we have so far not uniquely defined reduction. AD. It is not always the case that reduction in the LISPS we will examine reduce complexity.3. In other words. by the characterisation just given + and (2 3) might reduce to (+ 2 3). the value of the addition function applied to the numbers two and three. the same name is used to designate a F. will play a considerable rotc in our considerations of . rather than between arbitrary objects in the world (even its use in philosophy of science as between one theory and another is compatible in spirit). which will in 2. Semantic Rationalisation Procedural Reflection APPLY 235 among F. we will say that the addition function applied to the numbers 2 and 3 will yield the number 5. we will call reductio!!. and YD. one takes the complexity of an expression to include the complexity of the bindings of all the variables occuring within it. tautologically. since the latter term designates. which can increase the apparent complexity. and VD. it is p-reduction that 110t actually "reduces" the complexity of a lambda term. among F" At and v.and 3-lISP be designated in the initial environment by the term REDUCE. reduce in I-lISP to the nUlneral "5". in and v. and what is called the value of that function at that argument For example. designates a and v. AD.f. an argument (or arguments). The reduction function. SCHEME. in other words. It: however. Application will be taken to be a three-place relationship among an abstract function. an argument designator. a-reduction is particularly a "reduction" in any natural sense of that term. and also because the term connotes a relationship among expressions or linguistic objects. By "application". we refer to the relationship in the lower part of 53-178. AD. and a nomlal"'!oI11l designator of the value of that function applied to tllOSC arguments. However we will of course use the term "reduction" to relate a function designator. Of the two "reductions" in the A-calculus. in part because of its relationship to the p-reduction of Church. since we have said notlling about what expression a composite expression should reduce to.

would simplify to the numeral designator of the following sort: Similarly. 2-lISP brackets are like 1-LISP parentheses): (53-181) (DEFINE APPLY (LAMBDA EXPR [FUN ARGS] (FUN .thus l-LISP'S (Prloe A [B el) is syntactically not unlike I-LISP'S (PROC A (LIST B C) »: ARGS) FUN ARGS) APPLY [FUN ARGS]) APPLY [APPLY [FUN ARGS]]) (53-182) (FUN . We will not. Semantic Rationalisation Procedural Reflection APPLY 236 reflection. (+ 2 3) would simplify to the nUlneral (REDUCE '+ '[2 3]) 6. in a<!qition. would all be declaratively and procedurally equivalent (here the brackets should be treated as enumerators -.. for the on the readings we have just given to those terms. however.. (APPLY (APPLY (APPLY (APPLY APPLY [APPLY [APPLY [ .. anv exp. (REDUCE 'REDUCE '['REDUCE '[2 3]J) (53-185) would simplify to the double designator ' '5. since it is a meta-structural function. since application is a higher-order function. is neither trivial to define. that any number of applications of APPLY would ~l be empty.3. whereas (53-183) nor recursively empty. Furthennore. tha~ or EVALUATE.. make use of functions called simple reason unnecessary. on the other hand. ARGS») It would follow. ]]]) REDUCE. they are entirely (thi~ i~ in particular. in particular. In particular. The following. in the following type of expression: (F • A) (53-180) APPLY Thus we could define in 2-lISP as follows (for lists of fonnal parameters. the expression (53-184) '6. [APPLY [FUN ARGS]] . a double application of reduction. such meta-structural designation is necessary in order to avoid semantical type errors: the following expressioD would .-ession of the fonn '-I JSP syn~~x): (APPLY F A) (S3-179) is entirely equivalent to a simple use of the tenns.

so they are highly I-LISP. since that would require that we be able to inter-convert all expressions designating the same mathematical function. which is evidently non-computable. . and are what 'J. we cannot hope to achieve a notion of canonical Donnal form.we will call them handles we can simply establish by fiat that all handles that designate the same s-cxpression are themselves the same handle. There is a minor problem here. recommended. Nonnal Fonn Designators Our aesthetic mandate required that the category of a normal-fonn designator 2-LISP is introduced depend solely on 4'(5) - this was what we called the semantical type theorem. Thus if we make s"'expression designators a unique structural type . a given s-expression can have distinct quotations: (53-187) However we have a solution to this already mandated by the category alignment aesthetic.. providing we make the two boolean constants distinct from regular atoms. Semantic Rationalisation Procedural Reflection 237 generate an error: (REDUCE '+ [2 3]) (S3-186) since reduction is defined over expressions. Our approach to defining a generally adequate notion of nOImal form will be to look at the various kinds of clement in our domain are canonical. whatever notion of normal form we adopt. We noted at the outset that. regarding uniqueness: in as we noted earlier.I for I-LISP D. Hence we must expect that. if functions are to be first class objects in the semantical domain. There is no hann in this way - it does not weaken the LISP that results in any it is merely worth admitting straight away. For s-expressions we also have an obvious suggestion: their quoted fonn. For the number and truth-values the an~ obvious normal form designators are the numerals the two boolean constants. functions on the standard interpretation will possibly l1ave multiple normal fonn designators. Thus two problems are solved with one solution. These took designators into.. and the second argument in this case designates an abstract sequence of numbers.3.t. The requirement that the structural types correspond to semantic types in as clear a fashion as possible has been satisfied for the lJulnbers and truth-values. All of these issues will become clearer once 3.

E. except what is laid out in the following section on data abstraction. the compositional aspects of such a proof can be handled by straightforward techniques. satisfy the three constraints we mentioned earlier regarding such normal fonns: they arc environment-independent.F. Semantic Rationalisation ProcedurwReflection 238 There are two other segments of the semantica1 domain to be treated: the users world of objects and relationships. F E FIELDS (S3-193) /\ [NORMAl-fORM(S)]] As mentioned earlier.C) = C('1'EF(S). Ft. it is an environment-independent object (if applied in any environment it will yield the same function). E € ENVS [1:(S. the present question is how we deal with functions. E E ENVS. in other words. in terms of the i' of the preceding sections. if we define the notion of nonnal-Jorm in terms of these three properties: CONTEXT-IND == A5 [VEt. E2 E ENVS. and the set of continuous functions. of course. Formally. It is at tllis point where the notion of a closure suggests itself as the reasonable candidate for a normal-form function designator. sideeffect free. F2 € FIELDS [[ 4lE 1 F1 (S) = cIlE l F2 (S)] 1\ ['I'E 1 F1 (S) = '1'E 2 F2 (S)]]] (53-188) Sf-FREE == AS ['IF E FIELDS. About the first to be designated only by base-level structures and not (tautologically) by any terms in programs .4»EF(S).and.3. is to prove the normalisation theorem in the general case: 'liS E IT tflEF{S) = 4lEF(VEF(S»] S. this can be stated as follows. We commented that one reason it may not be considered to be a valid expression is that it doesn't have any obvious value. since it embeds its defining environment with in it. E E ENVS [s = i'EF(S) ]] (53-190) NORMAL-FORM == AS [CONTEXT-lND(S) A SE-FREE(S) A STABLE(S)] (53-191) The result we have already is this: VS E S [[ S E NUMERALS U BOOLEANS U HANDLES] :J NORMAL-FORM(S)] (53-192) What will remain. note that all suggestions for nonnal-form designators made so far.not. but of course . Before considering them.E. The other seman tical entities are the functions. a real function in the sense we are using that term . We cOlnmented in chapter 2 that it was unclear whether a closure was an s-expression or not: it was clearly a finite object .we have little to say here. C E CONTS. and stable.F) [vF n (53-189) STABLE == AS E FIELDS.

However there is something odd about this: since all closures contain environment designators within them. it would seem that environment designators would be circularly 1ermed. in part to make it easier for environment designators to be modified in a reflective dialect. since we are using them in the function position of a procedure application. as we remarked in chapter 2. and what functions the terms EXPR and IMPR designate. Functions.. that environments do not need access to an enclosing environment designator. a and IMPR - in "function position". Thus for example: (53-194) \If E ENVS. We can thus posit the following: a combination fonned of the atom EXPR or IMPR followed by nonnat form designators of an variabl~ list. in other words. on the other hand.e. From this ste~nd it follows that the nonnal-form environment designator is recursively defined by the above equation. It is also true. are distinguished combinations having EXPR special atoms environment. the second clement of an environment closure would be the closure itselt). Note that the 2-lISP enumerating structure (called a rail) designates a sequence. we have treated environments as functions in our mathematics: there is no immediate reason to do so differently within the calculus. Regarding the first question. are very close in stnlcture. F E FIELDS fi[ 'l'EF(" (LAMBDA EXPR (X) (+ X 1)))] = [r"(EXPR '(X) ENC(E) '(+ x 1))lD A [NORMAL-FORM(ENC(E» ]] Two questions are raised by this example: what it is to be a normal-form designator of an environment (and whether environments will constitute an addition to the semantical domain). In fact. we will adopt a different strategy. notation used to notate a new data type designating sets - . thus we could for example posit that environment designators contain themselv~s as l'teir own enclosing environment (i.3. I-lISP Procedural Reflection 239 closures. however. Semantic Rationalisation this is a criticism that has by this point evaporated. and a "body" expression will be defined to be normat-fonn designators of functions. The referents of tllis particular kind of rail. Since procedure application is defined as extensional ill first position thus if braces were legal 2-LISP that of the function designator - we are committed to allowing tht: function to be designated by any type of syntactic expression. however. it follows that a rail of two· element rails will designate an ordered set of two-element tuples. and of closures. arc unordered sets of two-clement tuples.

We can ex/end the definition of the behaviour of sequences of a certain structure so t1tat they can be applied. with the additional constraint that if more than one tuple has the argument as its ~f first element. then the tuple closer to the front value of the application. Finally. say. althoug. we can define an environment to be an ordered sequence of OUf tuples of atoms and bindings. because we do 110t have such a structural type. facilitating the requirements of reflection. thus violating the semantical type theorem. in the environment designated by In addition. then. expression the sequence is used to determine the Sequences. not over sacks (assuming 'He posit sacks as llormaI-fonn designators of sets). "Thus a variety of concerns can be dispensed with . since tllese can still be applied. the ([[2 20] [(* 2 2) 60] [4 'HELLO]] (+ 1 3» (53-196) would designate fifty. For example. This is mandated because. Semantic Rationalisation Procedural Reflection 240 a data type called.3. and return the numeral 60. can be applied directly to obtain a kind of "association-list" behaviour that is often primitively provided in LISPS. In other words. We do not have to solve this problem. suppose that the expression {I 2 T} designated the three53-136 element set consisting of two numbers and a truth value. rails are eminently suitable ground for side-effccts. we are given an answer as to what fonn a nomlal-form designator of an environment will take. and return Given SUC!1 60. On the other hand. Then equation seem to require that ({[2 20] [4 50]} (+ 1 3» would (53-195) designate fifty. and since rails are the nannal-fonn designator of sequences. a protocol. because the iiltemaliser is currently defined only over closures. but it does le:ld to the following suggestion. the circularity probltm just adduced does not arise. since environments will not be normally designated with closures. as if they were fun~tions. In the reflective code we call usc such applications as the atom designated by VAR (ENV VAR) to designate the binding of ENV. to deal witlt this case. we would 11ave other problems as well: sacks and closures would come into conflict as normal-form designators for sets of a certain structure. meta-theoretic characterisation still holds. extensionally they are equivalent Vie would have a ~ proLtem in our meta-theory. a sack .they too could be used in function position in a procedure application.1t S<!cks and closures are intensionally distinct.

but rather a EXPR closure should be structure. procedure is named by the atom its name can be normal-form. ot: for example. which would be vicious. Closures must be" stable.. position of the closure. Eo variablcs.d. trickier. onto the function designated. would (53-197) BINDING1] [VAR2 BINDING2] . then. which has a simple answer: the its own CAR. thus no atom Hence we must reject The obvious suggestion is that the nonnal-. EXPR . in other words. This would seem to be a circular CAR requirement. on the other hand we must support such code as: (LET [[EXPR +]] (EXPR 2 3» (53-199) 6. [VARIt 8INDINGk]] '[X] '(~ XI» There is however one final problem with this solution. This clearly must designate five and return the numeral . the designator have the following form: (EXPR [[~ (LAMBDA EXPR (X) (+ x 1». that is straightforward: it can signify an extensional procedure (even though designates the TRANS LAMBDA is intensional) that takes environments. by standard assumption it must designate the value of the function designated by the arguments designed by the CDR. we need to ask what function it designates. however. since the question re-appears in asking what appears in the requirement for a circular structure. is I-LISP notated as follows (in fact this is 1-LISP graphical notation for eventually adopt a analogue of this structure): . though it is not lexically printable. No atoms arc in normal fonn. and how As to what function it designates. sequences of EXPR. we will Thus the structure of the 2-lISP EXPR closure. Thus we simply cannot have 53-197. and a body expression. The closure. I. should appear as the EXPR CAR of each extensional closure.fonll of tIle procedure signified by can appear in the procedure position of a closure.e.. we have (in the initial context = EXT(TRANS) EXPR'S and Fo): ~EoFo("EXPR) (53-198) The question about name appearing in the procedure position of closures is.3. function of section 3. EXPR appear as an atom in function position. This closure is a pair. Semantic Rationalisation Procedural Reflection 241 rather easily.. However it is not a circular account. but the EXPR.. CAR applied to the The arguments are all Donnal fonn designators.

This much of a discussion should indicate that a semantically rationalised LISP is a possible fonnalism. this raises no particular problems. .3. Semantic Rationalisation Procedural Reflection 242 (S3-200) EXPR closure ENY VARS BODY Since EXPR is primitive. The design of such a calculus will be taken up in the next chapter.

or designated by symbols in the field. CDR. CDR. No reference is ever made by a meta-theoretic variable to a This is very different from the environment and continuations: continuations often embed other continuations within them. PROP. Lessons and Observations Before leaving the subject of these semantica1 fonnulations. that constitute it are not objectifiablc within Therefore there is no way in which past states of that field can be retained in structures. there are two additional comments to be made that will tum out to be important when we design 3-LISP. RPLACA. The first three use the argument to determine CAR. This fact is of course predictable. and property-list relationships. as mentioned in the introduction to this section. by applications formed in terms of seven primitive pr~edures: CAR. This field argument is referenced.j:iii. as sketched in what we called a process reduction model of computation in chapter 1. that then hold for the indefinite future. if one thinks just a moment about what the structural field is. the teons in the D"leta-linguistic characterisations of the semantics of 1-LISP procedures always pass the field to their arguments that they receive RPLACA) from their caller. The field is the world in which the processor lives. Though the field itself has structure. The meta-theoretic mathematical entity is merely designed to "'odel an actual structural field. the last four modify the field in ways that subsequent computations can see. which is a single graph of symbolic structures examined and manipulated during the course of a computation. and after processing a procedural reduction (our new term for a procedure application) the environment in force before the reduction is again used. to the illteractions amollg calls to these functions. beyond simple sequencing. of course. We can make a very strong claim about the use of the field as an argument: there is no structure. Semantic Rationalisation Procedural Reflection 243 3. whereas during the reduction a different environment (the one itl force when the closure was created) is used to process the procedural body. The structural field is not itself part of the semantic domain D r~lationships this was what we meant in chapter 2 when we said that the primitive LISP. with the exception of modifications (for example by field other than the one currently passed around. and PUT-PROP•. CONS.3. RPlACD. The first has to do with passing the structural field as an explicit argunlent among the meta-fleoretic interpretation functions. a world from which that .

they were not encoded as stnlctural field and r deal with internal procedural consequence. However there is a deeper way of making the same point The field of structures is the world over which the programs run: they can ajJeet it.that the blackboard itselfneeds to be encoded on the blackboard. It is for this reason that throughout our analysis we have maintained these two parts of the context in different theoretical objects. although 'I' it was crucially a function from s to S - from Its context arguments. It is this realisation !hat led us to a characterisation of computation as the interaction between a processor with slate and a field with slate. One role of particular relevance to us was that they are the functions designated by the meta-circular processor. The mathematical consequence of this fact is this: a single so-called global variable could be used. they are . however. rather than an explicit argument passed around between functions. We commented in this regard that structures onto structures. Nonetheless we were able to formalise them. we cannot make fonnal use of this fact. continuations fragments.the semantical functions explicating procedural consequence - are in some sense odd. lIowever when we embed the meta-theoretic characterisation of LISP into the 3-lISP reflective processor. we will not need to have a structural field argument for any of the meta-theoretic procedures: the field is simply there. which the processor reads and writes: there is no need - no sense in the suggestion . 11lus. So long as we are using the A-calculus as our meta-language. however - Cl1vironments and were abstract functions. and a world it cannot in one glance see. 11lose functions . and yet at tile same time they do not tell the fannal story of how the computation is effected. will be designated by a particular structure. since they do not deal with what symbols designate. because each reflective level will operate in a distinct environment. The second comment about our approach has to do with the context arguments to and 'I' r. and passed around as an argument.l.3. the two are independent exactly because there is no sense in which the state of the field is part of the state of the processor. Semantic Rationalisation Procedural Reflection 244 processor cannot escape. since we have no such mechanism as global variables. but they cannot create or store whole fields. accessible to and modifiable by any program that wants to touch it It is the blackboard on. and show how they made sense of a variety of phenomena in need of explanation. The environlne..

They exist only in the semantical donlailJ of the meta-language used to characterise 1-LISP. This is both correct and important It is correct because. environment and continuation designating terms. It is for this reason that.lnu!laneous[y 1noves what . in a S.3. The question we will have to face is this: wIlen a process reflects. environments and continuations arc tacit part of the background in which those s-cxprcssions are used. and mention the functions and numbers that they designate. as we have maintained all along. F € FIELDS [G(S. not in tenns of structurally encoded representations of computational state. they are reified in service of constructing an adequate and finite theory of the wide potential behaviour that forms the subject matter of the theory./ s.E. the context is borne by these entities only as functional theoretical posits: they do not have a reality in the phenomenal world being explained prior to the articulation of the theory explaining it Rather. although the notion of an environment plays a crucial role in explaining how LISP works. For example. More fo nn ally. One level of reflection moves the s-expressions that were used into a position whereby they arc now mentioned. however. and binds formal parameters (ENV and CONT. It takes another intensional act to access The point is perhaps best stated as follows. This issue is important because it arises in the design of 3-LISP. no ENVIRONMENT-P predicate can be defined within IISP: Ellvironments and continuations are not pari of 1-LISP'S semalltical domain D. and the term designates a~ environment No s- expression designating or encoding an environment is needed. tenns in the theory of LISP mention LISP s-expressions. s-expressions are explicitly used. Semantic Rationalisation Procedural Reflection 245 formulated in terms of abstract theoretical posits. say) to the environment and continuation in force at the point in the computation prior to reflection. nor is any mentioned. are used in formulating tllese explanations. .F)] E (53-201) the tenn s designates an s-expressioD. At the object level. when we reify abstract descriptions of processors with structural field expressions. meta-theoretic expression like VS € Tenns signifying continuations and environments. or should they The foregoing argument designate structures encoding environments and continuations. shows how the only correct answer is the fanner. should ENV and CONT designate environments and continuations. E E ENVS.

Thus we are focusing on the structural field of all abstract or virtual machine. in sketching the process reduction model of computation in the first chapter. universally used to implement the LISP For example. and all programming languages. ilt field we did not mention the notion of a pointer. Semantic Rationalisation Procedural Reflection 246 was tacit into tenns that are used Thus at the first reflective level we use vocabulary to refer to what was tacit at the object level.j:iv. Implelnelltation. where only the resultant behaviour is what counts. So the question reduces to one. there is no limit to how abstract a structural field one could examine in this way. even if the programs engender behaviour of . point is how some of those properties have already been embodied in decisions we have made in our mathematical characterisation of our simple initial dialect 3. in particular. it was our claim. and it will receive much more treatment in chapter 5. The reader will have noticed that we place great emphasis on the apparently static structure of the entities in the structural field what might seem an odd emphasis in light of the current interest in data abstraction. that the notion of a field of structure in fact pcnneatcs a great tnany calculi. become available themselves to be mentioned. not of ilnplemenlatioll. but of the legitimacy of focusing on a structural field at all. we include (in LISP'S case) all programs in the structural field. Furthermore. With respect to this question. There are several replies to be made to this apparent criticism. Declarative Ilnport. because of the fact that lve a/tribute declarative inlport to cOlnputational structures. and not to let our characterisation of it be influenced by matters of implementation defining the LISP by considerations. and Data Abstraction One postscript remains. it may seem as if we are putting theoretical weight on what is normally considered part of the implementation.3. a type of objcct almost field in the memory of a Von Neuman underlying architecture. In particular. First. introduced at the first level to refer to the tacit structure of the object level. What is notable at this. we mention the terms that were used at the object level. of how it might be encoded in the structural field of an implementing process. This identification of the reflective hierarchy with an increasingly reifled account of the tacit structure of non-reflective behaviour is one of the most striking aspects of our design of 3-LISP. Only at the second level do the tenns. we have taken some pains to define the structural field abstractly.

as theoretically substantive ingredients in a process.3. Thus. makes a strong claim about the fonn and organisation of the elements of the structural field It is exactly the substance of this hypothesis that the most compelling functional decomposition of an intelligent process will posit. any notion of language. not return . the knowledge representation hypothesis. the other makes calculations simpler. and concentrates purely on behaviour. and (CADR el ) would designate the imaginary component (notice we say designate. (CAR way of preparation for 2-lISP). Semantic Rationalisation one Procedural Reflection qua programs.this by is a complex number. standard example is the notion of a complex number. a set of structures on which declarative import can be laid. (There is no doubt. an extremely important issue remains.ons completely any notion of "static" symbols. In order to obtain the radius. and it is in order to facilitate very abstract machines that we have defined the notion of a structural field. for others. which can be easily represented either in terms of its rectangular or polar coordinates. that viewing computational processes purely behaviourally - and ignoring any semantical claims on their ingredients - is a more general approach. under whose influence the present project is pursued. the real and imaginary coordinates being the first and second elements. It is probable as well that one would have to give up any notion of symbol. are nonetheless static structural objects In addition. however. 247 sort or another. Suppose for example we choose the first option. The problem is that it is far too general to be of any interest: it may even be too general to count as· computational. representing a complex number as a iist of its real and imaginary rectangular components. and distinguished it completely from issues of notation. One of the most compelling aspects of computational systems is the ease with which they allow programmers to define abstract data types out of more primitive ones. and probably any recognisable notion of processing. it is indeed possible to deny the utility of the notion of a structural field. one would usc the expression: . if C1 el ) would designate tllC real component. The price will be that one would have to deny any representational claims in addition. For some purposes one representation is more convenient.) In spite of these rejoinders. if one abanet. No mention is made of how abstractly defined these structures will have to be. Thus we might define a complex number as a list. in other words. In other words. A "'. in a manner analogous to the way in which procedures are defined in terms of more priinitive ones.

rather than deciding once and for all between these two options. w construct . to define what is called an abstracl data type of "complex number". on which a number of opera~ions are defined. and would define the procedures appropriately. to the two rectangular components. we could have the dual implementation. appropriately constrained. would use copies of such implementation-dependent code scattered throughout a body of code. we will assume two additional functions: POLAR COMPLEX-FROM-RECTANGULAR and COMPLEX-FRON- that.3. (IMAGINARY e). It is widely considered more modular. implementing complex numbers in terms of their rectangular coordinates: (DEFINE REAL (LAMBDA EXPR (e) (CAR e» (53-204) (DEFINE IMAGINARY (LAMBDA EXPR (C) (CADR e» (DEFINE RADIUS (LAMBDA EXPR (e) (SQRT (+ (. and to the two polar components. would construct one instance of the abstract data type. Suppose for example we require that for any complex number c we be able to use the fonns (REAL e). in terms of polar coordinates: . imaginary numbers. respectively. of course. We would define some way of storing the information within this· module. given two coordinates in the respective system. Of course to make the example realistic we have to provide a way . and (ANGLE C) to refer. the following module yields this behaviour. RAD (COSINE ANG» (* RAD (SINE ANG»») Analogously. For example. Semantic Rationalisation {SORT (+ (* (CAR C) (CAR e» (0 (CADR C) (CADR e»» Procedural Reflection 248 (53-202) Similarly the angle could be computed by taking the appropriate arctangent: (ARCTANGENT (CAR C) (CADR e» (53-203) No one. (RADIUS e). (CAR C) (CAR e» (* (CADR C) (CAOR e»») (DEFINE ANGLE (LAMBDA EXPR (e) (ARCTANGENT (I (CADR C) (CAR e»») (DEFINE COMPLEX-fROM-RECTANGULAR (LAMBDA EXPR (REAL IMAG) (LIST REAL IMAG») (DEFINE COMPLEX-fROM-POLAR (LAMBDA EXPR (RAD ANG) (LIST (.

abstract types. external programs need not know which implementation strategy has been used. and from a consideration of the tenninology that is typically used to describe such abstractions. How do we say. But what is much less clear is how to make the declarative import of such a computational module explicit.to make their borders. display-oriented input/output devices. since the behaviour (modulo efficiency considerations) of the two is the same. although it requires some effort to make these abstractions clear in the scmantical treaUnent . with respect to the example we gave above. are the notions of declarative import and data abstraction related? There arc a variety of hints that may be taken from a close examination both of what we actually did in the example above. Semantic Rationalisation (DEFINE REAL (LAMBDA EXPR (e) {. IMAG IMAG») (ARCTANGENT (I IMAG REAL»») (DEFINE COMPLEX-fROM-POLAR (LAMBDA EXPR (RAD ANG) (LIST RAD ANG») Outside of these modules only the six procedures names would be used. has to do with how to characterise such From a procedural point of view the standard techniques will suffice. (CAR C) (COSINE (CADR C»») (DEFINE IMAGINARY (LAMBDA EXPR (C) (. but it is not uncommon to define. (CAR C) (SINE (CADR C»») Procedural Reflection 249 (S3-Z06) (DEFINE RADIUS (LAMBDA EXPR (e) (CAR e» (DEFINE ANGLE (LAMBDA EXPR (e) (CADR C» (DEfINE COMPLEX-FROM-RECTANGULAR (LAMBDA EXPR (REAL IMAG) (LIST (SQRT (+ (. come to the fore in the mathematical characterisations 'mat emerge. for instance. in this same style. that it represents a complex IlUl1zber? How would we say of a far more complex artifact that it (or instances of it) designate graphical terminals? To what extent. and so OD. It is clear that arbitrary types of object in the user's world can be handled in a like manner: our example is extraordinarily simple.3.to represent objects as complex as files. First. The question for us - the reason that these considerations matter in our investigation computational structures semantically. in spite of the received maxim . REAL REAL) (. in other words. in other words.

and two particular real numbers that represent the given complex number. That structural field fragment will itself have declarative import. any given instance of the abstract data type will necessarily have some implementation in terms of elements of the structural field of the implementing machine. and the semantical account. Theo. based on whatever interpretation function was in effect prior to the definition of complex numbers. are precisely not a sequence of two real Dlllnbcrs. .there is no likelihood whatsoever that () of the structures given above wilt have anything to do with instances of comr10X numbers . that the code we used itself must succumb to a declarative treatment. as described by the standard semantics.but it is not too much to ask that we establish semautic~ some sort of relationship between the explicate. OUf new data type is not really that of a complex /lumber. as well as this code having detenninable semantical import. the infolmation about a particular complex number can be deduced from the following two things: a general claim about a bijection between complex numbers and two reat l1umbers. since really what we have done is implement an abstract fonnal object to which we intend to attribute the following semantical import: a complex numeral will designate a complex number. we will call the data type a conJp/ex numeral. since all expressions of the form (LIST x Y) designate the two-clement sequence of the referents of x and Y. however. in writing down the code in and 53-205 - code that is intended to generate that behaviour . of course. as we always do. It is entirely likely that this characterisation will be at odds with the one we are headed for . that we wish to Furthermore. it is clear that on either implementation. a complex numeral c will be taken by our semantics onto a sequence of two numbers.VvC did not in some magic fashion build it out of behaviour. Actual complex numbers. the processing of which is intended to yield the behaviour we had in m~nd to implement It follows.3. We can in fact readily dctennine the declarative import of such instances in our simple example. and this is what we know when we accept the implenlcntatioD. account that emerges from the code we have written. therefore. we need to clarify our terminology. rather. in tenns of complex numbers. Semantic Rationalisation Procedural Reflection 53-204 250 the that behaviour is what is crucial. Rather. f"irst. we wrote down static symbols.

er the data type. Semantic Rationalisation Suppose we define a relationship IT Procedural Reflection 251 that encodes the appropriate mapping between sequences of real numbers and complex numbers (we will focus on the rectangular implementation. which is intuitively just like is extended to include t c) except it n. be «) otherwise = 4»( X) (this would of course be contextually relativised as 2-lISP usual).a two-element list of real numerals . then such equations as 53-207 could be written as follows: . we REAL-OF and would want to prove that the function designated by REAL was (the extensionatisation at) a function from complex numbers to their real coordinates. in the standard semantical treatment. In other words if 4» of a term is in the domain of II.3.instead of 4». (or whatever rationalised dialect one llses) would '-preserving as well as fJ)-preserl1ing. First. then 4-' (X) cf»' (X) = n( 4»( X) ). of the implementation of complex numerals. For example. In other words. if c1 is a complex numeral . For if the primitive language processor preserves and if the ilnplelnelllation relationship is defined over referents. REAl-OF(IT(X») (53-207) Similarly for all of the various other functions comprising the behaviour defined over complex numbers.3) = 2 + 3i. The crucial fact about II is that it be fOffilulatcd in terms of the designation. although the form of the argument is identical in either case). some remarkable properties emerge. nee) = REAl-OF(C) + [IMAGINARV-OF(C)]1 Then what we would want to prove would be something like the following: ~EF("RfAL) = EXl(AI . not over structures. Furthennore. we would have to specify the consequences. Now if this is done. in its tenns. suppose we define an extended semantical interpretation function 4". then II(ct-EF(C 1 » is the complex number that c designates in what we are beginning to think of as an extended calculus. then it is obvious that a regime that maps one tcnn into another with the same referent will not change any properties that depend only on reference. Once we had defined fi. if function application is redefined to use -r. IMAGINARY-OF Suppose that are two functions in out meta-language that project complex numbers onto In other words· we are assuming that: (53-206) their real and imaginary coordinates.returned by COMPLEX-FROM-POLAR. of the" significance of the abstract operators defined ov. fInen what is true is that ~-designation. Thus for example TI( 2.

then its underlying semantical cleanliness will perfuse' the abstract structures implemented on top of it .'EF("RfAL) Procedural Reflection .simply asserts. REAL-OF(X» 252 = EXT(AX (53-208) In other words a systematic way emerges in which the interpretation functions can be extended along with the introduction of new abstract data types.and. In other words. The moral.vays. in other words. that REAL designates the real coordinate of a complex number. in tenns of the designations of the implementing programs.3. then the resultant ex/ended dialect will be semantically rationalised as well. for it means if we define 2-LISP correctly. without proving it or relating it to the semantics of the implementing language - then nothing about the semantical properties of the processing of this instances of this data type can be said. This is quite considerable a result. if a user simply posits the designation of code implementing abstract data . it: however. such abstract data type extensions can be proved as sound and consistent.i' from the implementing language ooto the language extended with the abstract data type. for example. nonetheless we (or any other user) will be able to build it up in standard powerful . then the sernantical soundness . for example. Semantic Rationalisation . so that ti!e fundamental semantical characteristics of the underlying system are preserved. and not surprisingly. even if it is a simple kernel calculus. If that extension is done with care. the semantical flatness of the underlying processor carry OV\. is that if the abstract data type is soundly defined and implemented in temlS of the semantical imporl ofa selnantical/y rationalised dialect.

2-LISP: A Rationalised Dialect We tum next to the design of 2-LISP~ a dialect semantically and categorically rationalised in terms of the analysis set fortll in the previous chapter. that a clear separation between the simplification and reference of expressions can workably underwrite the design of a complete and practicable system (something that no amount of abstrf~t argument can demonstrate). and independently of" procedural consequence. It does not fol1ow that tll0roughly examined. We will show in that both facilities -. arc necessary for neither capability.4. however. The most striking property of 2-lISP that differentiates it from I-LISP is of course the fact that its procedural regimen is based on a concept of normalisation rather than of evaluation - with the concomitavt commitment to a declarative semantics defined prior to. Meta-structural primitives. 2. provides no soiution. We will attempt to show. in other words.higher-order functionality and the ability to objectify multiple arguments can be cOilveniently and compatibly provided in a semantically-rationalised base language. 2-LISP will have no Incta-stnlctural primitives: on the 2-lISP'S contrary. To partially compensate for the lack of higher-order functionality in a firstorder system. we . we observed in chapter 2 thac the I-LISP meta-structural facilities were employed for the following reasons (among others): 1. In addition. To deal with certain fonns of objectification and compositionality of program structure in the structural· field. We saw as well 2-LlSP that the objectification issue \vas not treated in the "-calculus. simple naming and de-referencing primitives will be introduced and rather In addition. in keeping with this approach. 2-LISP is intended to demonstrate) emerging from our drive to free the meta-structural powers of a computational calculus for reflective In particular. language has shown us that a LISP The Sf:HEME need not use meta-structural capabilities to EVAL deal with higher-order functionality. 2-lISP: A Rationalised Dialect Procedural Reflection 253 Chapter 4. the standard way in which multiple 3rgumcnts are handled. there are two further points that purpc~es. but even in that dialect certain types of objectifications required meta-structural trcatmcr:t (the explicit use cf and APPLY). we will initially provide primitive access to NORMALISE main processor functions (under the names and REDUCE). Strikingly. currying.

proved in section 4. we are also committed to two aesthetic principles: 1. programmer into odd behaviours and curiolls problcrns. the appropriate context of usc has been lost by the time the body of the intensional . there should be no distinguished individuals that receive special treatment). and procedural consequence. we will show thaI they need not be primitiv~ but could be defined in tenns of other functions (this is a claim called the up-down theorem. 2-LISP: A Rationalised Dialect Procedural Reflection Of.:!ffice. J There are several properties of 2-LISP that should be made clear at the outset. however.4. various facilities of solutioIl. The point is that and REDUCE will be required only when the processor state (in terms of an environment and continuation) must be objectitied: in other cases. It is our claim that these facilities can all be provided in a clean manner. and it provides primitive access to the main processor function. and used in defining programs that are simply not possible in (those that objectify the state of the processor in the midst of NORMALISE a computation). In the course of our pursuit of these goals. 2-lISP is an extremely powerful calculus in various fOlmal senses: it will handle functions (LAMBDA) of arbitrary order.d. First. we will show how IMPRS (intensional procedures that do not nOffilalisc their argul11cnts) have no Ylay of nOflnalising those argunlcnts after the fact. it contains powerful meta-structural facilities. 2-LISP In spite of this power. less powerful primitives will always s. where these functions will be re- introduce<L as part of the reflective capability.iv). and so forth.. I-LISP or and it is just the right preparation for 2-LISP 3-lISP. 254 to put will be able to prove thai there is no reason one would ever need 10 use them ~ the SaIne point another way. structural field. since i. there is an odd sense in which well self-contained - is not very lead the it does not provide a very natural closure of capabilities over the 2-lISP concepts in tenns of which it is defined. it contains primitive intensional operators. both functional and hyper-intensional (QUOTE and primitive support for arbitrary IMPRS). declarative import. To the maximum extent possible there should be category alignment across the entire system: among lexical notation. In all aspects of the design the category (as opposed to individual) identity of a form should dctenninc its significance (i. but there are of course consequences to this power. Tnis is a much stronger result than we were able to reach in SC:JEME. such as that it will in general be undecidable what function a given 2-lISP program computes.e. In particular. some of which have no obvious For exanlple. 2.

in a word. 2-LISP: A Rationalised Dialect Procedural Reflection 2SS procedure is processed. but also fully infonnative designators of arbitrary contexts. That pristine goal. nor ev~n any hint that solutions are possible. to avoid the introduction of structural encodings of theory-relative meta-theoretic posits. and if TEST signified an intens\onal procedure. The general character of these problems. the problem step. because (as we will show) we still lack an appropriate theory of (finitely representable) functions-in-intension. there WQuld be no way within the 3 body of TEST to ascertain that x was bound to at the point of call. however. however. the questions do not arise in its case. Many other examples could be cited. ~ with IMPRS and closures and all the rest IMPRS) is that they inevitably force us to take part of a step towards full reflection. SC ••EME Nor do other systems provide any clues: since the A-calculus has no meta-structural facilities. natur~ of IMPRS and the static seoping protocols the govern variable Similarly. Thus for example if we were to write (54-1) (LET [[X 3]] (TEST X» in 2-LISP. and it is striking that provide EVAl does not and APPLY as primitive procedures. The problem . however. In 3-LISP. in setting out the structure of constituents. is that we will find no solutions. Environments were to be entities in the selnalltic domain 0/ the meta-theory that facilitated our explanation of how 2-lISP worked.d - meta-structural binding. The present moral is that the full complement of natural be developed without such a capability: that. without taking the whole reflective prOCedUTf! (a category that will subsume will enable us at will to bind not only designators of arbitrary argument expressions. will elude us. we intended to postpone introducing enviro~ments illlo LISP itself until we took up reflection as an explicit concern.4. but they will arise in due course: this is not the place to pursue details. . we will be forced to accept encodings of environments as structural It was part of our stated goal in designing 2-lISP. 2-LISP closures (normal fonn function desjgnators). ]be ability to objectify the environment in this way doesn't so much require reflection it would be Inorc accurate to say that it is 2-LISP reflection. perhaps for some of these very reasons. As a consequence we will be forced to use environment encodings as a stop-gap measure to cover for this lack. 2-lISP facilities cannot is inherently incomplete. \yorth noting at ttle outset.which arises from the interaction between the 2-LISP we will explore in greater detail in section 4. At heart.

4. it a1rr:t9st dictates. Rather. to make evident the fact that a procedurally reflective dialect is not an esoteric dream. is a stepping stone. are two: first. since this author. in other words. which does provide a natural closure of meta-structural powers. we could perhaps avoid mentioning structures that were actual parts of 2-lISP programs. This makes a little sense. . does not believe any such suitable limits can be found. But the closure question (the encoding of environments in closures) arose simply in providing an adequate treatmcnt of higher-order functionality. intents of this chapter. at least. to demonstrate the power and effectiveness of our double semantics viewpoint. will be the final product. not only pushes us irretrievably towards 3-lISP. 2-LISP: A Rationalised Dialect Procedural Reflection 2-LISP 256 One could of course argue that these results suggest that is already too powerful - that we should restrict it so as not provide any meta-structural powers.where such powers are essential. in fact. LISP reasons for wanting meta-structural programs that write On the other hand. since the fact that 2-LISP can handle objectification and higher-order functionality at the base level means that many of the standard powers are obviated. but we will not attempt to find a natural boundary for them. One could argue instead that although meta-structural powers over e~~e:itial1y uninterprctcd expres~ions may be useful. but merely the natural reconstruction of current practice. we consider 2-LISP a step on the way towards the yet more llle powerful 3-LISP. there remain cases - programs are an obvious example . the structure of that further dialect 2-LISP. A good hard look at 2-LISP. We will leave meta-structural facilities in 2-LISP. and second. 3-lISP in sum.

as can atoms (names). M in 54-7 is the standard field clements): s is the set of structural .4. no otllcr elements of the field are accessible from tile numerals (other than their handles: see section 4." formula ")" ".and. however. each numeral will designate its corresponding integer in all contexts. and so forth. and functions) are mathematical and abstract. a..vL). Numerals and Numbers As in I-LISP. Each numeral is atomic. differing only 2-LISP in having a processor with extended power. 2-LISP: A Rationalised Dialect Procedural Reflection 257 4. We will work primarily with six categories. and values ofapplications S-expressions ~ ofbindings and user's world t Notatioll (eL) [ "+" I . in part because pairs . <notation of referent> ~on-digit [character]- The first four semantic types (numbers. sequences. field. the fifth is the structural field itself: and the Sixtll is whatever extension is required in a particular use of a 2-LISP program. the 2-LISP field contains an infinite nUDlber of distinct numerals corresponding one-ta·one with the integers.encodings of functiol~ applications .we will be able to set these two taxonomies into approximate correspondence: as discussed in the previous chapter. FurthcftnOre. as explained in chapter 2. in addition. 4. i. truth-values. will be approximately constituted as follows (the notational BNF is a little informal: a more accurate version would introduce breaks between identifiers.can of course designate any element in the semantical domain.a. as it happens. The pairing cannot be exact. but the intent should be clear): SF Category Numerals Booleans Rails Pairs Handles Atoms Designation (fIl) Numbers Truth-values Sequences (of <)'8 of elements) Functions. 1'hey are notated in the standard fashion. It is not coincidental that lllcre are six primary structural catc~orics and six primary semantical categories . since the latter dialect is structurally identical to the fonner.~]" (54-2) [digit]- I "(" formula ".a. we cnn summarise these points (the function interpretation function from numerals to numbers. in both syntactic and semantic domains.. in the sense that no first-order relationships are defined as functions over them. and as is suggested in the table just presented. The 2-LISP Structural Field In this first section we will present the the 3-lISP 2-LISP structural field . Using the machinery of the last chapter._" ]0 digit [ "$1" "SF" ] "[It [formula].

Thus we have our first constraint on 2-LISP'S it (it should be clenr that so far this behaviour is no different from that of I-LISP): VE E ENVS. Rather. we will start simply. M( N). F € FIELDS [( ~E F( N) = I ] A ['1M E NUMERALS [[ tI-EF(M) = I] :J [M ::: N Dlll Numerals will be taken as canonical nannal-form designators of numbers: thus any 2-LISP structure s that designates a number (and that normalises at all) must normalise to the numeral that designates that number. F. F € FIELDS. 'IE € ENVS. N E NUMERALS. that this designation is one· 54-6 to-one is implicit in and 54-6.4. as is indicated by the following characterisation in tcnns of total procedural consequence. E. F E FIELDS. from 54 -11 54-10 it [0110\'18 as well tilat they are stahle. since it does not yield an algorithmic method by which it may be rendered true. 51' 52 € S [[[ (I»EF(Sl) E INTEGERS] A [Sz = 'l'EF(Sl) [S2 :a M. 2-LISP: A Rationalised Dialect INTEGERS a NUNERALS a Procedural Reflection 258 (54-3) (84-4) {I {N II is an integer} SAN is a numeral} I N E. F E FIELDS. C E COlTS [ >:( N. with the fact that numerals nonnalise to themselves: VE € ENVS. the normalisation of numerals involves no side effects. F E FIELDS. (54-6) 9 l (l Il is an l-numeral) E NUMERALS in the standard fashion [C)EF(N) :I (S4-6) (54-7) \iE € EHVS. C) = C(N. however. N € NUNERALS ['1'EF(N) ~ (N)] (54-10) Finally. thus the following is provable: (54-8) VI € INTEGERS 3N E NUMERALS ['IE € ENVS.1 (c)Ef(Sl» n :J (54-9) ]] It should be clear. E. N E NUMERALS M(N)] Equation 54-7 implies that each numeral designates an integer. Thus we straight away have shown the tnlth of the following: . F)] (54-11) From S4-7 and 54-10 it follows that numerals arc context-independent. tllat 54-9 is a desideratum that we will want to prove: we cannot simple postulate it. and from it fotlows that they are side-effect free.

e. and designating respectively Truth and Falsity. a. 2-lISP: A Rationalised Dialect [NORMAL-FORM(N) Procedural Reflection 259 VN E NUIIERALS J "~" (54-12) littJ~. " to indicate the lexicalisation of evaluation): (54-13) 4 -26 -26 00000111 -0 111 0 4. We will not use the name NIL to notate the boolean that designates Falsity.l. but a distinguished elClnent used for no other purpose. as well as structurally and semantically ("$" is otherwise a reserved letter in notation). we will instead notate them not simply as "T" and "F". no other structures (besides their handles) are accessible from them. to use a definition from logic) and nonnalise at a. normalise to . and they are tile canonical normal-form designators of their referents. in order to distinguish the boolcans lexically (from the 2-lISP atoms). "SF} Falsity} (54-14) == (54-15) (54-t6) (54-17) :: = ("Sf" f "SF" ] 9 L("$f") = "SF 8 L("$T") = "$f 'tiE E ENVS.. First we have the equations defining the form and designation of the booleans: TRUTH-VALUES BOOLEANS L-boolean = {Truth. where the second notates the result of normalising that structure notated by the first 4 just as we used => => => => II .Values There are two 2-LISP boolean constants. but as "STu and "SF". the relationship between two lexical notations. {"$T. since we have introduced so least the following follows from what has been said (we use the symbol lexicalisation of the nonnalisation relationship - but at to indicate the i. We cannot yet show very many examples. B E BOOLEANS [~EF(R) = TRUTH-VAlUE(B)] (54-18) The constraint we will ultimately want to prove is that all expressions that designate truth or falsity (all sentences. F E FIELDS. iL Booleans and Truth. compnslng their own structural field category. They are like the numerals in several ways: they arc atomic. The inconvenience in requiring an extra letter is more than compensated for by the maintenance of the category alignment The equations constraining th\' booleans are similar to those describing the nUlnerals.. As hinted in 54-2.4.

Semantically. C € CONTS [~(B.Ilave shown that the boolcans satisfy the normal-form constraint (S4-18. ATONS == {A ::= I A is an atom} (54-24) L-atom 9 L(l [character_]* non-digit [_character]- (54-26) (54-26) Il is an L-atom) = the corresponding atom E ATONS For the time being we will not define a property list relation as a functiol1 over atoms - although such an extension would need to be explored for a practical version of tile dialect. and can also assert that these two constants are side-effect free: VE € ENVS. and S4-21): '10 E BOOLEANS [NORMAL-FORM(D)] (S4-22) Again.4. with distinct lexical types (except with respect to the case of the constituent characters) notating distinct individual atoms.F. Each is notated with a lexical type in the usual way. in the field only their handles are accessible: we will discuss environments presently. F € FIEL?S. all atoms will be viewed as context-dependent flames. 2-lISP: A Rationalised Dialect Procedural Reflection 260 the appropriate boolean constant: VE E ENVS. Again. and there are assumed to be an infinite number of them in the field. we . 54-20. we can posit this as true of the booleans tllemselves. 51' 52 E S ctlEF(Sl) :I Truth A [52 II i'EF(Sl) :J [Sz = "$f A fIlEF{Sl) = Falsity] A [52 II '1'EF(Sl)]] :J [52 = "$F]D ml m 1 D n (54-19) Again. They are 2-LISP atoms are structurally similar to those of 1- atomic and indivisible.E. B E BOOLEANS ['1'EF(B) :I B] (54-20) (S4-21) 'IE E ENVS. B € BOOI. a.C) C(B. F € FIELDS.EANS. LISP.TRUTH-VAlUE{B). and . Atoms Like the numerals and booleans.E. iii. F € FIELDS. in the sense that aJl atoms will designate the referents of their bindings in the appropriate environment.F)] = Thl1~ as was the case with the numerals. only the most simplistic of illustrations are possible: ST $F ST SF (54-23) 4.

when we wish to emphasise their use rather than their stnlcturc. Pairs and Reductions Although 2-LISP pairs are identical to I-LISP pairs from a purely structural point of view. will be viewed as constants. The rust of these points is easily stated: 'IE E ENVS.iv. In particular. E. A € ATONS . A € ArONS 'IE E ENVS. in other words. atoms playa role as context relative names. but t11at will have to be proved. It should be noted as well that we will use the tenn "atom" when we refer to these objects from a primarily structural. since we have yet to identify ho. The nonnalisation of atoms is also side effect free: 'IE E ENVS. non-semantic point of view. C) = C{E(A). E.w environments can be affected. A € ATOMS [4»EF(A) ["'EF(A) ~ filEF(E(A» ] (S4-27) E(A)] (54-28) These two equations. and follows from the way in which reductions are treated. we will variously call them variahles or parameters. enclosed within parentheses and separated by a . we assume an infinite number of distinct pairs. It follows that no atoms. correspondingly. No atoms. but rather in terms of primitively recognised closures.a. will nonnalise to themselves: rather. procedural treatment.· as shown below. F € FIELDS. F E FIELDS. lbc pritnitivc notation for pairs is like that of I-lISP (with al1 its problems): a pair is notated in notations of its CAR and COR. some substantial differences between 2-LISP and I-LISP will begin to enlcrge between the dialects as we look at their semantics. 4. over which tile standard two first-order asymctric relationships are defined. however. Finally. 4»EF(E(A». do not imply that no atoms are in normal-form. no atoms are in nonnal-Jorm. C E CONTS [~(A. including the names of the primitive procedures. atoms must normalise to normal-form designators of the referents of their bindings. and notation. 2-lISP: A Rationalised Dialect Procedural Reflection 261 they will also nOlDlalise to those bindings. F)] (S4-29) Examples of the nOffilalisation of atoms will be given once we have some machinery for building environments. Functionally. mapping each pair onto some arbitrary element of the terms of ~hc field. as will be discussed in section 4. the primitive procedures are not dermed in tenns of atoms. and. 1l1cse relationships are total 2-LISP functions. It will tum out to be a thcoreln about 2-lISP that all bindings are in normal"fonn. F.4. F E FIELDS.b. called CAR and CDR.

. First. to the object designated by the CDR). we will stay with tradition. Our characterisation of declarative semantics for 2-LISP pairs.4. Sk)l in F (S4-33) It was this characterisation that made reference to the notion of a list.. S] (S4-3~) (54-31) 9 L(L I L is an L-pair) = a pair € PAIRS whose CAR is 1st fonnula and whose CDR is at of the 2nd aL 01 the (S4-32) It would be possible to define a radically different kind of lexical notation for pairs. partly because it provides the correct ingredients for our successful treatment of argument ohjectification within the base language. although we do not endorse the properties mis notation brings with it. in the way that we have curried the meta-language... less incompleteness. however. in contrast. and every reading of a lexical combination notates a previously inaccessible pair: PAIRS CARS == {P a cons == I P is a pair} [PAIRS -. Sit>] where P = r" (51 52 S3 . Two facts make this different from I-lISP. Note. furthennorc. one may note. in I-lISP we defined the declarative import of a pair as follows (ignoring side-effects for a moment): 'IE E ENVS. define the usual notational abbreviation for lists (since we are not defining lists at all in 2LISP).EF(P) = [ (4)>EF(Sl) )EF ] <S2 Sa . but such a move is major change. f!)1 In F According to the meta-language. with fewer ambiguities.. . all functions designated by 2-LISP expressions are functions of a single argument. S] [PAIRS. We will not. P E PAIRS [. is the following: VE € ENVS. F € FIELDS. F E FIELDS.. that this is not a case of currying the IISP. and therefore preserving LISP'S notational style is part.. This will prove simpler in a number of ways. pairs will be taken to designate the value (note our use of the term "value") of the function designated by the CAR applied to the CDR (not. of our claun to still be defining a dialect "tithin the IISP family. and so forth. especially since it is only through notation that we llumans access the LISP field. in other words. 2-LISP: A Rationalised Dialect Procedural Reflection 262 dot. if not all. P E PAIRS (5(-34) [ eJlEF( P) = [ (~EF( PI) )EF ] P2] where P = r"(Pl . as shown below. Semantically. For these reasons. but will instead reserve that notational style for a combination of pairs and rails.

54-34 and 54-35 can mor~ accurately (in the sense of using explicitly) be written as follows: 'IE E ENVS. Pz)l in F (54-36) Again. by a rcdcx. this should be compared with 53-136. as we will ultimately demonstrate. in other words. and from the procedures: (54-37) definitions (including the internalisations) of all the primitive VE E ENVS. P E PAIRS [[ cl>EF(P) = [ (eIlEF(F 1(P»)EF ] f2(p)] A ['I'EF(P) = [(~[+EF(fl(p»])EF] f2(p) l] (54-36) It is to be noted that procedural consequence is defined cOlnpositionally. There is no way. Procedurally (again temporarily ignoring side-effects for pedagogical simplicity). F E FIELDS.4. we will refer to the entire structure involved in a given procedure application - thus the identity conditions arc . it should also be true (if 2-lISP is correct) that the following equation holds. all pairs have 2-lISP CARS and CORS. 2-LISP: A Rationalised Dialect Procedural Reflection 263 Furthermore. and. P E PAIRS ['ltEF(P) = [(£1[i'EF(P 1 )])EF] P2 l where P = r"(f! . as we have just mentioned. as we will show in a moment). however. F E FIELDS. from the defining equations such as 54-34 and 54-36. Finally. we have a corresponding characterisation: the normal-fonn of the CAR of a pair is reduced with CAR'S the CDR according to the function engendered by the intemalisation of the fonnal form: VE E ENVS. for pairs to be structurally ill-formed from a declarative point of view (or from a procedural point of view. in a certain sense. but this is a statcnlcnt we will have to prove. even from the point of view of implementation. in that it makes reference only to the CAR and CDR of a pair. F € FIELDS. (There is actually a slight distinction even in reference between the two terms: a pair has only two "parts": a CAR and a CDR. it apparently has no adverse consequences. but will usc the tcrm redex (shaft for "reducible expression") when more functional or semantic stance is indicated. the 2-lISP characterisation is total. Regarding pairs we have a similar distinction: we will usc the simple term "pair" again primarily structurally. Since no induction is required to identify the F arguments. P E PAIRS [[ cflEF('I'EF(P» = ~EF(P)] A NORMAL-FORM('I'EF{P»] 2-lISP In discussing atoms we distinguished between the purely structural term "atom" and tile functional terms "variable" and "parameter".

A number of preparations are still required before we can give examples of the normalisation of pairs.E. that [~EoFo("+) = EXT(+)].Fl)]. for example. which allowed as to posit. therefore. This is given in below. Fz> · C(S2. to look at the structural type rail. designates the atom At {CAR (CONS tAt 8» as one would expect. of course.F2)])]]) Ft. ~(P. Simple examples like this will be given in section 4.E2. for example. J:inally. D 1 . . note its similarity E ENVS. and the role it will play in establishing Qur main theorems. [A<Sl. we have to give the full }:54-38 characterisation of the semantics of pairs.a.b. F. since it is rails that are usually used to encode the arguments to primitive 2-LISP 2-lISP procedures.F t > · l. which will work correctly with this semantic charactersation of pairs. will emerge later in the chapter. We need.F. C E CONTS.) Two things should be noted about how we are proceeding. We also need to show how to designate clenlents of the field. they do not handle side effects. we need to define what the procedures arc. to 53-135: VE More properly.4. The importance of this equation. the equations we have given of course illustrate the default case only. F E FIELDS. We will then be in a position to show that.ix. 2-lISP: A Rationalised Dialect Procedural Reflection 264 somewhat different The details will be spelled out in section 4.E [ (~St) ( F1 2 ( P) • Et • [A<S2' Ez . we are simply assuming that we no longer have the kind of troubles with evaluation that prevented us from giving a I-LISP characterisation of tile sort illustrated in 54-34 and 54-36. for example.[Dl(Ft2(P). P E PAIRS (54-38) E. We will in fact posit just such a declarative import for the symbol "+" in the initial environment.C) = ~(Fl(P).El. Secondly. First.

First is a structural lack: as posited above. it might seem. are by no means the same problem. one gave it a' single list of two arguments. A LIsp. indeed. as we should by now expect. of course. that a possible solution would be to wrap all the arguments to a procedure up into one object before calling it. and secondly against the use of one stru~ture type for two semantic purposes. These. We lodged two complaints against this practice: first against the fact that this data structure was not primitive (that fact alone broke the category correspondence between structures and semantics).. l'his is of This course possible. The foregoing discussion of pairs shows how in 2. a sequence of any entities 'Nhatsoevcr. procedure. like version might encode the addition of 3 and 4 as « + 3) 4). LISP we have defined applications. directly in tenns or. Another suggestion would be to employ currying. there is no way in which a procedure can be called with more than a single structural argument. the A-calculus loses no power in virtue of being defined with single arguments. of pairs. v. Rails and Sequences In standard LISPS the derived notion of a list. Unless. . the problem is rather that. 2-LISP: a Rationalised Dialect Procedural Reflection 265 4. at least theoretically. then any function could be called in that way. is used both to encode function applications and enumerations (including enumerations of multiple arguments for procedures). even if such a procedure existed. For example. there would be no way to call it with more than one argument And if a Inethod were devised by which liST could be called with multiple argunlents. one could imagine a variant on example in (+ (L 1ST 3 4». both declaratively and procedurally. rather than lists. 1-LISP in which.4. and LIST Ylould not be needed. a. We still lack. as for But this fails. instead of calling the addition function + vlith two arguments. since the problem recurses: we have no way to This is not for lack of an appropriate primitive LIST define such a LIST function. calls to LIST were structurally distinguished but that is too inelegant to contemplate. as we remarked.. in need of clarification. however. we will look at them separately.typically adopted in the A-calculus that we have employed througllout in our meta-language. a structure with which to enumerate a sequence of arguments - There are two related problems coalesced here. The second is a semantical ina<i~quacy: we have as yet no accepted way to designate a sequence of referents. in the style . With regards to the fIrSt..

»" (S. X» .. would designate 54-46 would designate. X) .. we would allow the following: (lAMBDA (VI Vz . in the new notation.. rrtther... X A) (* Y V»~»~) (54-46) We would have the following expected result: (HYPOTENEUSE 3 4) 6 54-46 (54-47) 54-47 This would work because and would be notational abbreviations for: (54-48) (DEfINE HYPOTENEUSE (LAMBOA (X) (LAMBDA (Y) (SQRT .(." _ _ ••• _ "( . For example. _ ". in the standard notation. «(+ . This can be arranged with a suitable definition of LAMBDA. Vt ) <BODY» (54-44) to be an abbreviation for (LAMBDA VI (LAMBDA Vl ( . what we mean is tllat 54-44. that would contradict 54-42. a fiJnction of the sort that. in order to make function definition more straightforward. 2-LISP: a Rationalised Dialect Fr~dural Reflection 266 currying approach has a variety of advantages.. _ formulal_ ". «(* • Y) . given the following procedure definition in the new notation: (DEFINE UYPOTENEUSE (LAMBDA (X Y) (SQRT (+ (. _ formulat ")" (54-41) could be taken as an abbreviation for .. V»~»~»~ and .." _ fonnulat_ ..4." _ "(It _ formulaz _ "..)" (54-42) rattler than as an abbreviation for the standard W(" _ tormu181_ ".. «* .( . -43) SiDhiarly..." _ "NIL" _ ") ... (lAMBDA Vt <BODY»») ~~nce (S4-45) (Of course 54-44 can't be made to be structLirally identical to S4-46.) "fhe structures that resulted would by and large look superficially - which is to say notationally - familiar. _ formul at _ "." _ fonnulaz _ ")" _ . and could be made notQliona/ly eq'uivalent to the old by defining the following as a notational abbreviation: "(" _ formu18t_ forrnula2 .

Iffi. In addition. In particular. . the change would be even nlore complex. In Sl. wives us fUT/her away from any ability to handle oujectified arguments. 54-48 would be much more complex: we have expanded only the body of the DEFINE procedure being defined. and some term x designates them as a unit before to engender their addicofi. tenninology. rather than closer. of course. currying would of course not work in t-LISP). A) • B) Therefore tile modifications would have to be: (BLOCK (RPlACD Y '0) (RPLACO {CAR Y) 'e» (54-62) And if the list (C 0) were the value of a single variable. a special procedure would have to be th~ devised that element by element applied the function to the sequence. rath~r Under the current proposal it is less easy than than . the calls to and LAMBDA would similarly have to be arg~lments in order to show the ft~11 expansion. since we are working in a d high~r"order language (the intermediate constituents of currled application are functions. suppose that y was (+ A B). suppose we wish to add two numbers.nore. For example.) This proposal. Rather than existing as a single list. this protocol makes it particularly difficult. rather than being explicitly decomposed in this £:1shion.4. however. but we needn't bother with that !lere. the fOlm Y would hl fact be: (54-61) «+ . I!l I-LISP (actually modify) this to be to use I-LISP this could be effected by (we assume that Y. while this currying proposal is eminently feasible. aJld we wished to change (+ CO). evaluates to (+ A B»: (RPlACD Y t(C 0» (54-60) However in the ~·roposal we are currently considering. 2-LISP: a RationaUsed Dialect ~ Procedural Reflection 6 267 {(HYPOTENEUSE • 3) • 4) (S4~49) (Actually uncurri~d. if Y new were a composite term encoding <: function application. which is straightforward in a higher order formalism. they have been spread out one by one in a series of explicit redcxes. passing derived function along at each step. and we wished to rcpiace its multiple argumentS with a new set (a task of the sort that ie liable to arise in reflection). the currying approach does nothing to answer our original goal. Note such as (RANDOM) as well that under the new proposal forms with no are notationally ill-formed: schemes which curry as a method of treating different numbers of arguments will not pennit functions to be cal!ed with no arguments at alt.

such as (+ '( t' • or Y». including abstract sequences in our matllcmatical domain . the first inaccessible number. how to designate an abstract sequence. From the point of view of declarative senlantics. each rail has a knglll that is the number of elements in it..'rom an infonnal point of view. 2) or (CONS • (1 • (2 • NIL»} or whatever) is semantically ill-fanned. It follows from our semantics. r. however. and a red-breasted finch). each of which is in turn an s-expression. 1) . as we will illustrate in the to embody what we take to be the essence of the concept of a list. then its seventh clement is its last. for example. but we will distinguish them in a moment. although tIle the reverse accessibility relationship does not hold. the currying suggestion doesn't even address the second of our original concerns. which we will call a rail) to serve as a structural enumerator and normal-fonn designator of abstract sequences. mathematical abstractions. r"fhus we have. 2-LISP: a Rationalised Dialect Procedural Reflection 268 Furthennore. For all of these reasons. From just these facts the MOL'S 2- rail looks similar to lists and NIL'S vector. Rails are notated (in a manner derived for lists) by enclosing sequence of notations for their elements w:thin square brackets. Thus if a rail R1 is of length 7. Rails will in many ways be like the derived lists of next few pages. What is true about the suggestions just considered is that they are purely structural suggestions: they do not deal with the related but distinct question of what it is to designate an abstract sequence of objects. nothing incoherent or problematic about a nu. Nor can we use qunted pairs. a raii designates the abstract sequence of objects designated by each of the clements of the rail.sequences that might consist of arbitrary entities: s-expressions.4. a rail consists of a number of elements. N·o amount of currying or adler structural suggestions deal with the question of (+ '( 3 4». of Thomas Wolsey. Procedurally. some iails arc normal-form sequence designators. rails will be original LISP defin~d 1-LISP. rattler than being implemented in tetms of pairs. and we are mandated by our aesthetics to avoid category dissonance between structure and semantics.tnber as its or CDR. we will define a special structural type. from the old 1-LISP not~tion I~'rom a ran each of its elements arc accessible. since pairs are reserved for applications. rrhe elements are numbered starting with the index 1. or objects from the user's world (a triple. for example. alt110ugh they are prhnitive. as a first approximation to a characterisation (tllis is rather . In particular. since no pair can contain There is. respectively. thus rails will normalise to rails LISP (thi~ will be explained further in a moment). that in 2-LISP the expression CAR (CONS 1 2) (independent of whether that is «CONS.

2-LISP: a Rationalised Dialect Procedural Reflection 269 imprecise but we will improve it presently): t SEOUENCES RAILS a {Q lOis a sequence of elements ot 0 } (54-63) == {R IR is a rail} (54-54) (S4-66) 9 l (L IL = "[It _ formulal_ formulaz _ .. and the fifth tail of R is the empty rail []. _ formulak _ "]") = R E RAILS [Vi 1:S1~k the 1'th element of R is I (84-60) el (farmula. R) ) ]]]] This equation is tacking. however. where by tlle Nth tail of a rail we refe:· to the (sub)rail beginning after the Nth element. . we will posit that any elelncnt of a rail may be changed (corresponding. [[ Q E SiQUENCES ] A = Q] [lENGTH(Q) = lENGTH(R)] A [ \f i 1~ i ~ LENG TH( Q) [Q i = cI» EF( NTU( 1. to the use of 1-LISP RPLACA on lists). rfhus if rail R is notated as I-LISP [2 4 6 3. "[1 2 3 4]" designates the abstract sequence of We will assume tVJO functions in our NTH m~ta-language: one called LENGTH.)] For example. C INTEGERS LJ {OO} [[INTEGERS X C RAILS U SEQUENCES 11 -+ 0 1 11 0·(54-61) We can then begin to characterise the declarative semantics of rails as follows: VE E E~VS. and a selector function called that position. which in turn hinges on modifiability. and also that the tail of a rail may be changed. 10]t l'!lUS then the second tail of R is [6 8 10]. In the spirit of pairs. we are saying that rails arc piece-wise composite. in a sense. Since identity hinges on discriminable difference. because it does not take up the crucial questions of identity of rnils. LENGTI~ that takes an index and a rail and yields the element at The types of these new functions are as follows: : NTH CC RAILS U SEQUENCES J -. which is a function from rails and sequences onto their lengths (which may be either finite or infinite). a rail is formed (as a LISP list was) of an clement and a tail. It is this structural technique that will allow us to lists (and will also distinguish our notion from the preserve the character of standard more common programming language construct of a vector or one-dimensional array). the rail notated with the string the first four positive integers.4.. R E RAILS (54-62) [[ ~E F( R) :J . F E FIELDS. we need first to ask in what ways rails can be altered.

as we will sec in a moment. for example.blatantly reveals the identity of 2-lISP rails. K clements and the Kth tail. not with the third. which change. therefore. However this would be too simple. It is the behaviour of these primitive procedures. but it turns out to be the happiest of the available choices. arbitrary elements and arbitrary tails of rails. since that would be too coarse-grained a 1l1cthod of individuation. they cannot be canonical normal-form designators. effect. similarly.fard lISPS by the derived notion of a list. respectively. This may initially seem odd. the consituent tails are the zeroth (the rail itself) through the (the empty rail). as mentioned. It has the consequence. and the consequences of the side effects they. These identity considerations will require somewhat complex mathematical modelling. It imnlcdiate1y follows that rai~s even if rails are determined to be nannal-form designators of sequences (which tlley will be). TIle logical suggestion would be to posit a special class of rails (RAILS).. thus the third tail of a rail starts with the fourlh element. of the previous paragraph is (It should be observed that the convention we have adopted specifies that the Nth tail begins with the "Nth plus 1" element. in RPlACN. that a rail consists of and so forth. and then to define a function from rails and clement positions (indices) onto arbitrary s-expressions. provide a function called so that the normalisation of expressions of the form . The intuition we will attempt to honour throughout is rationally reconstruct to the abilities provided in SW I1 . f'irst. since distinguishable can designate the sarne abstract mathematical sequence. In I-LISP one can lise combinations of 2-lISP RfllACA and an arbtirary number of COilS to change any clement in a list. And so on Further examples will appear in the next pages. we will. rather than with the Nth. but will rather introduce them informally and by exalnple. Secondly.) We will presently define two primitive side-effecting procedures RPLACH and RPLACT (analogous to I-lISP'S RPLACA and RPLACD for lists).4. rails will be allowed to have the same elemcnts. for a rail of length Nth N. 2-LISP: a Rationalised Dialect Procedural Reflection 270 In the R addition~ we will say that the zeroelh tail of a rail is itself: thus the zerocth tail of [2 4 6 8 10]. it is clear that distinct distinct 2-lISP I-LISP lists can have identical clements. it follows that we cannot in the mathematical characterisation of the field identify rails as sequences of their clements. in particular. that most . to make tllem plain. we will not at first present the equations they must satisfy.

This. it means that the length of a given rail may not be constant over the course of a computation. This difference is indicated in the following two "sessions" with I-lISP and 2-lISP. that one can change an arbitrary tail of (most) lists by using In particular. however. italicised): > (SETQ X t(A BCD)) > (A BCD) > (SETO Z '(L M NO)) > (L M N 0) > (RPLACD (CDR X) Z) > (8 L M N 0) . but its not EQI Again. regardless of what (N) it was before. Corresponding to this facility in 2-LISP we will say that one can change an arbitrary tail of a rail R by using a primitive procedure called RPLACT. It is also the case in RPlACD. there are considerable consequences to fact that the in 54-64 which means that two rails that were different (non"EQ. is I-lISP (54-66) Make 2nd tail of X into Z > (A B l M N 0) > (PROGN (RPLACA Z 'HELLO) > (THERE N 0) >x > (A 8 HEllO THERE N 0) ) (SETQ Z '(T U V W») )x Change the 1st and 2nd elements of Z (RPLACA (CDR Z) 'THERE)) X sees both changes Make O'th tail of X into Z in the only way 1-lISP allows > (PROGN (RPLACA X (CAR Z)) >x > (T U V W) > (PROGN (RPLACA Z 'HELLO) > (THERE V ) (T U V W) (RPLACD X (CDR Z)) > (T U V W) (RPLACA (CDR Z) 'THERE) W) X now looks like Z. normalising expressions of the fonn (RPlACT <N> <RAIL> <~EW-TAIL» (54-64) wilt" change the field so that the Nth tail of <RAIL> will henceforth be <NEW-TAIL>. tile 54-64. This facility has a number of consequences. in which replacing an arbitrary tail starting with any element other than the first had different consequences than changing the first. change the 1st and 2nd elements of Z . after processing the expression in for example. the new length of <RAIL> will be can be 0 <N> + lENGTH«NEW-TAIL». Second. in I-LISP terminology) (EQ) in virtue of executing a primitive LISP'S can be rendered the same procedure.4. however. This facility. 2-LISP: a Rationalised Dialect Procedural Reflection 211 (RPLACN <N) <RAIL> <NEW-ELEMENT» (54-63) witt change the field so that the Nth element of <RAIL> will be <NEW-ELEMENT>. I-LISP. respectively (user input is. as always. cleans up an inelegance in lists. First.

to change a the definition we have posited for 2-lISP list to be identical to another. however. ) x ) '[T U V W] > (BLOCK (RPLACN 1 Z 'HELLO) (RPLACN 2 Z 'THERE)) > 'THERE >X > '[HEllO THERE V W] 2-lISP RPLACT is also defined to be able to add elements. 2-LISP: a Rationalised Dialect Procedural Reflection : X sees the 2nd chango. :. in other words. but not . Set the 2nd tail to be (C D) (54-67) A length 2 list can be extended.Make 2nd tail of X into Z (54-66) > (RPLACT 2 X > '[l M N 0] >x > (BLOCK (RPLACN 1 Z 'HELLO) > 'THERE ) X > '[A B HELLO THERE N 0] > (SET Z '[T U V W]) > '[T U V W] > (RPLACT 0 X Z) > '[1 U V W] (RPLACN 2 Z 'THERE)) > '[A B L M N 0] Change the 1st and 2nd elements of Z X sees both changes Make O'th tail of X into Z X and Z are now the same rail. as shown in the following parallel sessions: > NIL > (SETQ X '(A B)) > (A B) > (SETQ Y 'C)) > NIL > (RPLACD (CDR X) '(C DJ) > (B C D) >X > (A BCD) > (RPLACD Y '(C D)) > <ERROR> >y This is I-lISP Make X a 2-element list Make Y a O-olement list () is NIL. change the 1st and 2nd elements of Z X sees both changes again. Y is still '() . in the following fOtmal sense: the must be between 0 and the length of the rail.4. I-LISP 272 ) x > (T THERE V W) There is no way. In distinction. Again. A length 0 list. cannot be extended. of course. in such (2-lISP a \l/ay that any subsequent changes on the latter will be seen in the former. would engender the following I-LISP. quote marks have approximately the same meaning as in but ignore for now the fact that the replies made by the system are quoted as well): ) (SET X 'eA B C DJ) > '[A B C 0] ) (SET Z teL N N 01) > '[l M N 0] l) This is Z-lISP SET is like 1-lISP's SETQ. 1'his again clears up an index to RPlACT oddity about I-LISP'S RPLACD. the 1st.

In of any whereas there can be arbitrary numbers of distinct 2-LISP. however. 2-LISP: a Rationalised Dialect I-lISP Procedural Reflection 273 In other words lists of length 0 are quite different from lists of other lengths (they NIL.4. are all. in particular. (54-68) > (SET X 'eA B1) > '[A 0] )' (SET Y '[J) ) '[] ) (RPLACT 2 X 'CC DJ) > '[C 0] 0 Y >x > '[A 8 C D] >y ) (RPLACT > '[C D] '[C D1) A length 0 rail can be extended also > '[C DJ . we have the following symmetry over rails length: This is 2-lISP Make X a 2-element rail Make Y a O-element rail Set the 2nd tail to be [C D] A length 2 rail can be extended. the same atom lists of any other length).

In particular. If the first element is not the trigger. and a new rail to splice into the old one at the first position where the bigger element occurs. SPLICE checks to sec whether the first element is the trigger. of three arguments: a rail (list) to work on. Though not of great importance in and of itself: the increased clarity is a noticeable convenience. an clement to trigger on. down the rail until it either finds a copy of the trigger. to illustrate this. this behaviour simplifies a number of otherwise rather tricky coding situations. if there is one.e. on whether an occurrence of the trigger element was found). Thus if x designates the rail (54-71) [DO YOU MEAN • WHEN YOU SAY 0] then we would expect (SPLICE '[YOU ARE HAPPY] . . if this were not intended. In addition. below): (54-74) TRIGGER) (LET [[OLO-TAIl (TAIL 1 OLD)]] (BLOCK (RPlACT 0 OLD NEW) (RPlACT (lENGTH NEW) NEW OLD-TAIL) ST»] [$T (SPLICE NEW TRIGGER (TAIL 1 OLD»]») After checking for the appropriate temlinating condition..!» is defined in 54-333. we will require that SPLICE retuCJl Sf or $F depending on whether the splice was actually performed (i.~ X) (S4-72) to return $T with x now designating the rail (54-73) [DO YOU MEAN YOU ARE HAPPY WHEN YOU SAY *] The 2-LISP definition is as follows {this definition modifies the inserted fragment. the line [[NEW ·:COPY NEW)]] could be inserted as a second binding in COpy the LET on the fifth line. after processing (RPLACT 0 OLD NEW). and if so splices in a copy of tl1C new rail.4. it iterates OLD. or exhausts The techniques are of course standard. there would he no way to refer to the tail of the original OLD. As a final example. we witl define a procedure called SPLICE. we show a so-called destructive splicing procedure that inserts a new list or rail fragment into a pre-existing list or rail. such' a (DEFINE SPLICE (LAMBDA [NEW TRIGGER OLD] (COND [(EMPTY OLD) SF] [(= (NTB 1 Ol. The binding of OLDTAl L is necessary since otherwise. 2-lISP: a Rationalised Dialect Procedural Reflection 274 As we 'will see many times in the examplesihroughout the remainder of the dissertation.

For contrast. which operates we have to break it into two parts.(LENGTH NEW) 1) NEW) (COOR OLD» T) ) (S4-76) «NULL (CDOR OLD» NIL) (T (SPLICE-HELPER! NEW TRIGGER (CDR OLD»»» 1-LISP However in spite of its increased complexity.(LENGTH NEW) 1) NEW) (CDR OLD» T) ) (54-76) (CDR OLD» NIL) (T (SPLICE-HELPER! NEW TRIGGER OLD»») «NULL (DEFINE SPLICE-HELPER! (LAMBDA-(HEW TRIGGER OLD) . SPLICE in I-LISP.(LENGTH tJEW) 1) NEW) . we can construct an analogous definition of on CORS. Thus (SPLICE '[] 'NOT DID NOT ANSWER • [I DID NOT NOT ANSWER YOU]) would change the third argument to be · [I YOU]. First. ).. 2-lISP: a Rationalised Dialect (RPLACT 0 . A natural first attempt would be as follows.COND {(EQ (CADR OLD). SPLICE 1 will fail if NEW is empty (Le. one to use for the modifications when l1}e other indicates an appropriate element has been found. is NIL or (».. Because we need to use RPLACD. one to tcst for the first element of OLD being the trigger. Note as well that no special care needs to be taken for an empty NEW. This case could be checked explicitly as follows: (DEfINE SPLICE 2 (LAMODA (NEW TRIGGER OLD) (COND «NULL OLD) NIL) «EQ (CAR OLD) TRIGGER) (IF (NULL NEW) T (Bl~CK (54-71) (RPlACD (NTUCDR (. and so fortIl). and anuther part that allows us to use two trailing pointers: (DEFINE SPLICE 1 (LAMBDA (NEW TRIGGER OLD) (COND «NULL OLD) NIL) {(EQ (CAR OLD) TRIGGER) (BLOCK (RPLACD (NTHCDR (. TRIGGER) (BLOCK (RPLACO OLD NEW) (RPLACD (NTHCDR (. Procedural Reflection 215 Because of the we do not need to retain two "trailing pointers". since (NTJlCDR -1 NIL) will cause an error (we assume NTUCDR returns its whole second argument if its first argument is 0. (SPLICE '[] <A> <B» would remove the first instance of element <A> from <8>. the CDR of its second argument if its first argument is 1.4. there arc two ways in which this version of SPLICE is not as general as the 2-LISP version in 54-74.

In order to compensate for thi£ inability. 2-lISP: a Rationalised Dialect (CDR OLD» T») Procedural Reflection 276 «NULL (CDR OLD» NIL) (1 (SPLICE-HELPER z NEW TRIGGER OLD»») {DEFINE SPLICE-HELPERz (54-78) (LAMBDA (NEW TRIGGER OLD) (COND «EQ (CADR OLD) TRIGGER) (BLOCK (IF (NULL NEW) (RPlACD OLD (CODR OLD») (BLOCK (RPLACD OLO NEW) (RPLACD (NTHCDR (. Thus a typical call to SPLICE might be: (SETQ SAYING (SPLICE SAYING '. so that a user can reset variables explicitly.(LENGTH ~EW) 1) NEW) (CDR OLD» NEW») «NULL (CDR OLD» OLD) (T (BLOCK (SPLICE-HElPER 3 NEW TRIGGER OLD) OLD»») SPLICE 3 (54-80) (DEFINE SPlICE-HElPER 3 (LAMBDA (HEW TRIGGER OLD) (COND «EQ (CADR OLD) TRIGGER) (IF (NULL NEW) (RPLACD OLD (CDOR OLD» (BLOCK (RPLACO OLD NEW) (RPlACD (~THCDR (.4. INSERT» (54-19) We could modify SPLICE to return the appropriate list: {DEFIr~E (LAMBDA (NEW TRIGGER OLD) (COND «NULL OLD) OLD) {(EQ (CAR OLD) TRIGGER) (IF (NULL NEW) (CDR OLD) (BLOCK (RPLACD (NTHCOR (.(LENGTH NEW) 1) NEW) (CDDR OLD»» T) ) «NULL (CDDR OLD» NIL) (T (SPLICE-HELPER z NEW TRIGGER (CDR OLD»»» But even still there is a problem: if the first element of the original OLD is the trigger. the practice is typically to have procedures like SPl ICE return the modified list.(LENGTH NEW) 1) NEW) «NUll (coon OLD» (54-81) (coon OLD»») NIL) . but it is ~ problem in any casc. This IS particularly obvious where NEW is NIL. then the explicit check for that in SPLICE 2 fails to make the change visible to others who have pointers to OLD. where we return T but do nothing (that alone ought to make us suspicious).

the lessons are presumably clear.4. the I-LISP version was ail order of magnitude more difficult than the 2-lISP version of 54-74. Thus one might use SPLICE 4 as follows: (LET «PAIR (SPLICE SAYING '... in possibility of error.i). 2-LISP: a Rationalised Dialect Procedural Reflection 277 (T (SPlICE-HElPERa NEW TRIGGER (CDR OLD»»» However now we have lost the bit of information that was originally returned saying whether or not the trigger was found.(LENGTH NEW) 1) NEW) (con OLD» NEW»» «NULL (CDR OLD» (LIST NIL OLD») (T (LIST (8LOCK (SPLICE-HELPER 4 NEW TRIGGER OLD) OLD»») (DEFINE 5PLICE-HElPER 4 (54-84) (LAMBDA (NEW TRIGGER OLD) (COND «EQ (CADR OLD) TRIGGER) (BLOCK (IF (NULL NEW) (RPLACD OLD (COoR OLD» . Note that whereas SPLICE 4 returns a two"'element list as just agreed.. INSERT») (SETQ SAYING (CADR PAIR» . a "multiple-value return" mechanism might be used here. in difficulty of design. OLD is always the appropriate list to return. (i~stead OUf final version returns a list of two clements. if SPLICE-HELPER 4 gets called at all. and so . (DEFINE SPLICE 4 (LAMBDA (NEW TRIGGER OLD) (COND «NULL OLD) (LIST NIL OLD» «EQ (CAR OLD) TRIGGER) (LIST T (IF (NUll NEW) (COR OLD) (54-83) (BLOCK (RPlACD (NTHCDR (. First. some use of (CAR PAIR) as flag. the first is the flag (T or NIL) saying whether the trigger was found. both in resultant comp:cxity.. SPlICE-HElPER 4 returns only the flag T or NIL depending on whether or not the insertion was effected. the second element is the possibly modified list of a two-element list.d. of the sort explored below in section 5..BLOCK (RPLACO OLD NEW) (RPLACO (NTHCOR (. ) (54-82) The full definition is as follows.(LENGTH NEW) 1) NEW) (COOR OLD»» T) ) «NULL (CnOR OLD» NIL) (T (SPLICE-HELPER 4 NEW TRIGGER (CDR OLD»»» Though we won't consider this example further.

user . was analytic and paid no attention to design. a formalism that we . it is ctifficult to generate this behaviour in TIle problem is that if except is used. We will not explore.vill use heavily in the chapters ahead (chapter 3. Nonetheless. and we Inust avail ourselves of all tlle aesthetic help we can muster along the . that the complexity was due to a particular kind of circumstance: boundary conditions and the avoid&nce of fence-post errors (the general case was handled in much the same way in both dialects). While they were adequately treated by the general code in 2- they had to be handled specially. It might seem possible to use then the stack cannot be allowed to become empty. for reflective code is rather subtle. in contrast. we do 'Yell to appreciate their potential impact. We may observe. for a ~~~~~~. particularly in consort. in t·"lISP. but that is not our view. furthennore. the RPlACA. IISP. then the motiH1ed stack or queue has to be returned and. the consequences of the many small design issues that have been faced in specifying 2-lISP (the requirement that each s"cxpression have a single handle. It is worth pausing. We are in this chapter designing a specific formalism.yay (especially the kernel that is our subject matter programming that employs this kernel may well be simpler). if necessary. These considerations arc particularly germane as we reach towards reflection.. 2-lISP: a Rationalised Dialect Procedural Reflection 278 forth. Another simple example of the same type involves pushing an element onto the front of a stack or queue. linguistic conventions).4. RPLACA main pointer to the stack reset appropriately. since a subsequent would fail. because the list has to be passed back. with some awkwardness. in this kind of fine detail. to consider why we care. except minimally in defining meta. Some readers may think it is a waste of time to pursue aesthetic issues in what ought to be an analytic investigation. so that expressions of the following sort: (PUSH <NEW-ELEMENT> <STACK» (54-85) will change see CONS 51ACK in such a way that anyone who now inquires after its first element will 1-LISP. Whereas a simple PUSH can be defined in 2-lISP using RPLACT 0. as is set out in the next section. is another choice much like the present one: seemingly innocent but of tremendous import in reflective work). It is also more difficult to use. version from the 1-LISP In particular. what distinguished the 2-LISP an empty NEW version were the limiting cases - or an instance of TRIGGER in first position. NEW-ELEMENT.

thus we have: PROPS == C ATONS -+ we will RAILS J 2-LISP (54-90) Thus we have the following tentative definition of the too broad.} 11 {J. this is an appropriate time to add the pre/perty-list concept to assume that all property lists are rails. mathematical characterisation must support the behaviour manifested in all these examples. rather than the other way around. the first mapping a rail onto its first element (if it has one). it is the desired behaviour that drives the identity conditions. we will define five meta-theoretic utility functions: CAR CDR FIRST REST - - - AS AS AS AS AS PROP - - AF Af AF AF AF [F 1 (S)] [F 2 (S)] [F 3 (S)] [F 4 (S)] [F 6 (S)] (54-92) . This approach is very like the standard way in which I-LISP lists are described'in terms of a first and rest. The solution will be to define two mutable first-order asymmetric relationships over rails. and the second mapping a rail onto its first tail (again if it has one). 2-LISP: a Rationalised Dialect OUf Procedural Reflection 279 But to return to specification. since.4.classes in order to handle the mutability: FIRSTS RESTS == C RAILS == C RAILS -+ [ -+ C RAILS U CARS S U {1. as we will show in a moment): FIELDS set of possible fields (this is ::: [ C. SEQUENCES == - {Q {R IQ IR is a sequence of elements of D } (54-86) (S4-S7) RAILS is a ra i 1 } We first define two pr~mitive function classes in the meta-Iangt:age . which are harder to remember than the simple 3 we lIsed in 1-LISP. CDRS == C PAIRS C PAIRS -+ S -to S 1 J 2-LISP. but of course we have the luxury of defining our meta-theoretic first and rest functions in non-constructive ways./c are adopting from. as is the case in any design.4RS X CORS X FIRSTS X RESTS X PROPS 1 (54-91) Because there are five of these. (54-89) In addition.} (54-88) 11 1- These are entirely parallel to the LISP: CARS E and CDRS function classes ".

]] then [1 'r LENGTH(REST(~.r ail f)L(l : := " [ "_[ f 0 rmu 1 a_l • "] " (54-97) (54-98) Il = U(" _ formula 1 _ formula2 _ . F) = -l l)]l} Given all of this machinery..l else1f [I = 1] then FIRST(R.] tl.F)] else 00 We can usc these functions to define the notational interpretation function for rails: L.l e (S4-93) m Therefore we will define FIELDS as follows: FIELDS Il VR == {F E C CARS X CDRS X FIRSTS X RESTS X PROPS E RAILS U[ 3Sf E S [F I RST ( R• F) = s. we have the following VR € RAILS.REST(R...R. F) = J... since rails either do or do not have firsts and rests together. 2-lISP: a Rationalised Dialect Procedural Reflection 280 lbus these functions in the meta-language take two arguments.F). constraint: In particular.en .F). Note that the definition supports infinite-length rails (such as circular ones.F) 81se NTH(l-l. R.F) = 1.]] A [3R r E RAILS [REST(R. we can define a nc\v length and a selector function (these supercede the initial versions we defined in 54-91) that will ultimately enable us to define the appropriate behaviours for that RPLACN and RPLACT in section 5.L] 1\ [R E51 ( R• F) = .b.i~k NTH( i.R. for example). [ INTEGERS U [FIRST(R. and the fact NTH is defined over such rails as well as over finite ones.R. ] I[[ e .F) = s.4. : C[ INTEG!RS x RAILS X FIELDS 1 -to C S U {-l} 11 =: AI.F) = 1.F) = l (formula1)] A [NTH(k+l. F E FIELDS [[[ 3S.. S [FIRST(R.] then 0 {CO} 11 elself [3N [NTH(N.F) = 1.] A [REST (R.F) :: Rrm V [[ FIRST (R.f) = 1. 1] 1\ 1 (54-94) [3R r E RAILS [REST(R. F • [ 1f [FIRST(R.F) = Rr ]]] ~v I[ fIRST (R • F) = .F) NTH (54-96) ] (54-96) LENGTH == hR. f • [ if : CC RAILS X FIELDS 1 -. whereas the corresponding embedded procedures within the dialect do not need the field as an explicit argument The first thing that we must do is to revise our definition of 2-LISP fields. _ formulak _ ttl") = R E RAILS Vi l:S.

F)] A [Vi l~i::. we show that rails that are in nvrrnal fonn arc self-normalising: VE E ENVS. eXDlnpl~ [NfO("3. R E RAILS.'Cts designated by their elements: 'IE E ENVS.LOS.~GTH( 52' F) UFD( NTH( i •S2 • F). . we will first set down the t/eside.4»E r (R) • E. These last two obseNations are more complex in the case of rails than with examples.3)] are As is by now lour custom.·atunl we waulet utthnatcly like to prove regarding rails: that all cxprc. F E FIELDS [[[ tIlEr(St) E SEQUENCES] 1\ [52 :: 'l'EF(Sl)]] :J [[ $2 E . whereas [NFD("(" 1 2).~. Falsit. E.~» ]])] (54-99) In order to define the procedural L. LENGTH In the next fc'h sets of equations we will express these constrajnts.4. F) U (54-102) . C) ~ ":i R . F E FIi. that rails are nonnal-form designators. tJlat rails designate the sequecce of oojt. we can review our clainl first that rails dcs1gnate sequences. F E FIELDS IT cIlEF(R) = Q] :J [[ Q E SEQUENCES ] 1\ [LENGTU(Q) = lENGTH( R.R. 1~ i ~l. [lIlE F(S 1)] I) (54-101) r 1 ]]]]J We can now specify in particular the proccd. [[ VE E ENV. F E FIELDS [tllEf(S) [NORMAL-FORM(S) ]] = 0]] A Thus for false. . as well as our recent!y introduced First we specit1~ two-argument one defined over structnral raits. ~ILS] 1\ [lENGTH(S2. C € CONTS 1f (Vi l~i~lt.y} 1 AS. then.'11 consequence of raits. E E ENVS. First.LENGTH(Q) lQt = cI»EF\NTH(1..onseql'lcncc C'f raits.lisc to a rail: V~l' 52 E S. R E RAILS. R»]] t ~an [L( R r. and third that they previou~ ~'ltisfy the requiretnents on such normal-fonn designatoffi.3)] is tl~UC.·jfjTH(R) [NORMAl-FORM(NTH( i.3)] and [NFO("$F.isions that designate sequences will (altd that normalise at all) nonn:l. because a rail is in nannal-form only if its elements are in Donnal form. 0 . it is helpful to fun~tion dcflne~n auxiliary NFD (fo J• "normal-form-designator"): NFD C[ == S x 01-+ {Truth.-LISP: a Rationalised Dialect Procedural Reflection 281 In addition. E. Note that we assume a single-argument defined over abstract sequences. F) = lENGTH(~EF(Sl» A [ Vi.

0 t. Et.L] then C(R.00 ] the n . It is c(!Sicr to state these relationships as constraints than to modify the main definition: 'In E RAILS. 've have not specified the sand in the last call to c.. As a first attempt we have: VR E RAILS.R.F) :: . ~(RE5T(R. F •C) 1f [LENGTH( R. possibly different The general computational significance of rails is more difficult to specify than any of the special cases t.E1. since .D t .1~lENGTII(D2) [ D1+ 1 = ° 1. since the first bit of any non-empty rail is itself a rail.F) = 1. ~J Til ( ~(REST(R.Ez. F•C) = j T· [ l ENG TH( R• F) =. In addition. E. [A<R z .E 2 . rather than F2 being passed back as the tinal field. however.D. S . f E FIELDS.F).erely assert that if a rail is in nonnal-fonn it will nonnalisc to whereas the prior ~quations some rail also in normal fonn.F 2> . the idea is that s is the rail whose first clement is 51 and whose first tail is Rz• Similarly.Ft.R. S4-104 as r~cscn(cd does not ensure that normal-form rails. we need to rnodify the account so that empty rails are not returned if they pass the nonnal-fonn filter. be recursively defined.F l ) • C(S. Finally. 2-LISP: a Rationalised Dialect Procedural Reflection 282 This last equation is stronger even that the behaviour implied (but not yet proved) b)· 54101. 1 D Vi 1::. C(S. RE5T(S. there is. a field should he returned thar encodes these nrw first and rest relationships. [A<Sl. Fa = F2 otherwise.R.F).E~.F t > . It can. F) = 00 oJ then J.EoF) e 15 e ~ ( tJ TII ( 1 • R. F E F:ilLDS.0 2 .(>.Fl' 1 .F J ) .D. F) . [A(R l . because of potential side'·cfTects engendered by the nonnalising of the Jnterior elements (we must also make explicit the fact that the nonnalisation of infinite-length rails will not telminate). however. because 54-102 claims that if a rail is in normal-form. it will normalise to itself: m. rrhus we need one additional clause at the oull)ct stating that.D z .reated so far.F 1> . C E CONTS [ Z( R• E. else1f [NTH(l.Fz)])j)] D There arc however sevciai problems. arc sclf-nonnalislng..F 3 )])]) where S E RAllS and D E SEQUENCES. one rcnlaining probi~m.E t . C ( CONTS [ ~(R.4.E z .E. :: O2 ' ] We arc all but done.E z . F3) :: S1 .] then C(R. other than empty ones.F.E.L elseif [NTH(l.F).F) (54-103) else ~(NTH(l.: Rz .<>. First. 0 is intended to be the sequence whose first element :S D1 and whose remainder is oz. E E ENVS. E E ENVS. E• F• (54-104) [A(S1.

4.O. Vi l~i:SLENGTU(Do) [ 0 0 1 = 4!EF(:JTH(i.E.iii below). over structures it is true just in case the structures arc one and the same. REST(S. VR E RAILS. C E CONTS [ I( R. else1f [NTH(l.F z> .Do. [A<Sl. whereas over sequences it is true just in case they are the same mathetnalical sequence - which is to say.v) modifying the last tail to a normalised rail would modify the original rail as well.F 3 ) = S1..F» 31"0 = ° 1~i~LENGTH(02) [ 1.] then C("C]. in the spirit of in. [A<Rz. NTH(1.R. because of a striking fact that emerges from our semantical bent.S.b. lENGTH(R.ils. equality over designated sequences is a coarser-grained identity than that over sequence designators.F»] then C(R.R.E 2 . just in case the elements arc (recursively) the same and in the same order.E 1 . F € FIELDS.R.f 3 )])]) where 5 € RAILS and 0 E SEQUENCES and Do E SEQUENCES. It would b~ defined with respect to rails. 1 ~(REST(R.R.D 1 . we use handles (notated with a quote mark) to Inelltioll rails. ] It should be noted that all of these issues of identity case they contain the same elements in tile same order.F) . But we will not do this. F3 ) = Rz .F) 81s61f [lENGTU(R. the following nonllalisations would hold in 2-lISP: (= [1 2 3] [1 2 3]) (= '[1 2 3] '[1 2 3]) => => $1 SF (54-106) . The identity predicate is spelled "=" (it will be defined in s-~ction 4. C(S.E.F).<>. 2-LISP: a Rationalised Dialect Procedural Reflection 283 otherwise (this is explored further in section 4.l-LIsP the type-equivalence we defined over lists.F 1 > .E.Ez. sequence identity we derive from matllcmatics: two sequences are the same just in possible to define a notion of type-equivalence over f2. Since we use rails to designate sequences.b.El.1.F) where "[1 is inaccessible in F else I(NTH(l.F) = 00] D then J. E• F.F. One can e\'en speculate that in I-LISP'S ordcr~ngs type-identity predicate of objects that the EQUAL there lies an attempt to establish identity of the 2-lISP I-LISP lists encode.F) = LENGTH(D o> 0 Vi Ot+1 :: 0 21 ]. and since = is extensional (all of these points will be more fully illustrated below).C) II (S4-106) 1f [Vi 1:S1:SLENGTH(R.F).F) [NORMAL-FORM(N1H{1. = lEHGTH(D).Fl' F3 = F2 otherwise. E e ENVS.Oz.

and from the equation given in it follows that from one point of view. we will mean. as in fonn "(" _ formul at _ formul 82 _ . (+ 2 3) (READ) (+ .4. Once again substantive examples of rails will await our definition of procedures defined over them. we will take lexical expressions of the formul at ")" (54-t08) where 1 ~ K. and \vhose For example: abbrev)ates CDR is a rail of clements notated by the remainder. all that all 2-lISP 2-lISP procedures are called with a single argument. [2 3]) (f1EAD • []) (54-ItO) ~'A (CAR (CONS 'A '8» " {CAR. ] . 'B])]) 2-lISP.a distinction between identity of designator and idelZtity of the object designated wit! largely serve our purposes. _ " ) " In other \vords. 54-38. the phrase "the number of arguments" taken by a function... in general no need for a notion of type-identity over designators will arise (although in the as-yet unsolved area of the identity of function intension we will look briefly at type-equivalence of rails). [(CONS . _ l-l ISP.. if this b~' abbreviation is used." _ "[" _ f 0 rmu 182 _ . From this convention. will be a rail of zero or more expressions. _ f 0 rmu 1 ak .. We s<lid above that we were not defining the standard list notation to abbreviate chains of pairs. Instead. and "( )" is its name. It foHows that tile expression "()" is nOlationally ill-formed there is no NIL. whose CAR is notated by the first.. 2-lISP: a Rationalised Dialect Procedural Reflection 284 In the remainder of this dissertation tllis distinction between rail identity and sequence identity . as abbreviations for the following: (54-109) " ( . for the prescnt we are constrained to such simple illustrations as these: [1 2 3] [1 2 3] (54-107) [] [[ST][SF]] [] [[ST][SF]] The final introduction to make regarding rails and sequences has to do with a notational abbreviation. It is possible to define procedures that do not honour this convention... a sequcnce of notaticnal expressions \vithin parenthescs notat€s a pair. which. It is therefore a convention procedures will be defined over sequences. _ f 0 rmu 1 al _ ". bUl all primitive 2-LISP . in in other \vards. the nutnbcr of etcmcnt~ in the sequence.

The work. It should be kept in mind that the foregoing comnlent is selnantica/: it says that the CAR of a pair are by and large defined over sequences in the fron~ It does not follow from anything that has been said that. in the treatment. the expressions given in corresponding 1-LISP and 54-112. 2-lISP: a Rationalised Dialect Procedural Reflection 285 functions obey the protocol. All in all. the fact that APPLY LISP docs not allow arguments to be conveniently objectified required the explIcit use of a situation we are at pains to avoid. we are better off able to avoid these rather . would have to be written roughly as follows: -. -+ (LET «X (LIST 4 6») (APPLY '+ X» ( APPLY •+ (tJT UCOR 2 '( 10 20 30 40») 9 70 : This is I-LISP (S4-113) (54-114) However these work only because numerals self-evaluate. the 1- present concern with rails as multiple-argument designators is also aesthetic. all functions must be called with a rail as the argument sequence designator . as mentioned earlier. CDR. approximately as in enumerations - except that rails rath~r than lists are of course used to encode it will be defined below): =:> (LET [[X [4 :]]] (+ • X» (+ . (TAIL 2 [10 20 30 40]» 9 70 (54-111) (54-112) => More such examples will arise in due course.4. It is once again appropliatc to pause for a methodological comment. we did in 54-71 ~lrough 54-85. complex manocuvrings. Some simple examples of this flexibility are given in the following (LET is I-LISP. Note as well that it is impossible to construct an application to a function with no arguments at all.that all semantically valid pairs must have f:lils as their It is in fact this very separation between sequences and rails that enables 2-lISP to natura1!y solve the problem of calling functions with a single expression that designates the entire sequence of arguments. as will all of the functions we define in our examples. CORS. a structural point of view. enabled us LO obtain a cleaner dialect. particularly because we arc adopting a 54-111 statically seoped dialect For example. but it itnpinges morc directly on our goal of reflection. if the objectified expressions contained variables the dialect would have to be dynalnically scopcd in order for the metastructural treatment to work. since it is impossible to have a pair that has no functions designated by the senlalllical dOlnain. As we con1mentcd in chapter 2.

a. whereas the relationship is not. rails. In addition.. in addition. which in our meta-language we will call the HANDLE clement of words the whereas S onto its handle. that takes each S are an infinite numher of elements of s of other types. but in two CAR other respects it is unlike the CAR and CDn relationships. and sequences. respcctively). fronl every element of relationship. First. not only because titer · function. with a variety of special properties. it is bi-directionally local. Thus flANDLE need not be encoded in the FIELDS part of our meta-theoretic characterisation.4. like the CDR its handle is locally accessible. it follows that is a total function on HANDLES. Furthennorc. and pairs. Handles We have so far introduced five structural categories: II unzera[s. boolealls. truth- values. the last two can designate entities of any type. CAR and are uni-dircctionally local. tile handl~ and CDR relationships are mutable. and designates elements of the structural I-LISP. although they have their own A handle is an atomic element of t1le field. HANDLES tlANDLE 1 is the function from clements of the structural field onto their handles. from every handle its referellt is also locally accessible. implying that every handle has a handle. vi. . but also because this claim rccurses. Firs~ for every element of s there is exactly one handle that is the canonical normal-form designator of that element (implying an infinite number Jr' handles. and so forth). Handles are not unlike quoted expressions in notation and identity conditions. atoms. field. since they are general purpose designators.. There!s a total function on s. Each handle is notated with a single quote mark ('" ") followed by tile notation of its refcr~nt These various properties arc summarised in the following equations: == {H HANDLES IH is a handle} (54-120) (54-121) HANDLE : [ S . The sixth and fina~ 2-lISP structural category is called a handle. The first three of these designate abstract mathematical objects (numbers. 2-LISP: a Rationalised Dialect Procedural Reflection 286 4. in other words. taking their designation from the context (in the case of atoms) or from the value of a function application (in the case of pairs). In other HANDLE CAR and CDR relationships. is asymnlctric. lIANDLE-~ 111C existence and identity conditions on handles arc expressed in the following two equations..

:S) E S] ::> ('I'EF(S) = f~ANDLE«i'EF(S»]] (54-126) Equations 54-120 through 54-125 are independent and posited. F E FIELDS. docs not "strip the quotes off' of IDeta-level designators (we shall have to introduce We have in consequence the following: (54-130) ~ => 1ST => => 'A '[1 2 3] ['1 '2 '3] . 54-126 is a claim we will have to prove in section 4. which expresses the fact that handles normalise to themselves.e of numerals . H E HANDLES ['I'EF(H) = H] (54-127) The normalisation of handles will of independent: cOl~rse be side-effect free. F E FIELDS. 'A '[I 2 3] ['1 12 '3] '" I' 2-lISP processor. C» = C(H. The following. H E HANDLES [~EF(B) = HANDLE-I(H)] (54-126) Similarly.. E.e proof: 'fE E ENVS. as w\J1l as environtnent- \iE f ENVS. 2-LISP: a Rationalised Dialect Proctdural Reflection 287 ~5 E S [3" E IIANDLES [H = HANDLE{S) A VJ VH E HANDLES [35 € S [H (S4-122) [J :: HANDLE{S) :J J = H l)J I-lISP = HANDLE(S) n abbreviation for (54-123) As remarked.HANDlE.h. f " '$T designates a rail of numerals designates a sequenr. <F. in other words. "_L r ] ::> [9 L (L) = HANDLE(8 L(lr» n (S4-124) That handles designate their referents in a context-independent way is implied by: 'fE E ENVS. F E FIELDS.F)] (54-128) And once again. is posited as a first step towards its ultimat. H E HANDLES. fonn): L-handle ::= "'"_<notat1on for referent> '1L € L-HANDLES [[ l = II. not an abbreviatory.1 (H). C E caNTS [l:(H. handles are notated using a lexical form similar to the quoted fonns (although in 2-LISP this is a primitive. F E FIELDS. that handles are designed to be the nonnaJ-form designators of s-expressions is captured in: 'IE E EHV~.4. S € S [( <PEo. from these conditions the following summary vB E HANDLES [NORMAL-FORM(B)] c~n be shown to follow: (54-129) We just said that all handles normalise to themselves: the a special lncchanism to do that presently).E.

ARG variable \vould be bound to the list which be returned as the value. according to the declarative semantics we adopted in chapter 4. were normalised. that the application in {QUOTE t (+ 2 3» of QUOTE t is taken to designate. 2-LISP is defined with no such quot~ function. First. AUG would be bound to the which would be returned as the nonnal-form co-designator of the original 11lus we have: . 2 3). 2-LISP: a Rationalised Dialect Procedural Reflection 288 The differences between 2-LISP'S handles and t11C corresponding met. designated the referent I-LISP notational fonns using the single quote mark were notational abbreviations for applications in tenns of this function. This is ARG l-LIS~ (S4-133) In 54-132. however (as will become plain later in the chapter). {QUOTE 2 (+ 2 3» is bound to the handle designating tile un-nomtalised argument. For cxalnplc. QUOTE function in. since FEXPRS are a meta-~tructural The I-LISP definition is as follows: This is I-LISP (DEFINE QUOTE t · (54-131) I-lISP'S (LAMBDA IMPR (ARG) ARG) ARG. Note that the body is simply evaluator. I-lISP contained a prilnitive function called QUOTE - an IMPR described in chaper 2 - in terms of which applications were constructed that.a-structural designation facility in 1-LISP are several. In coatrast. lbus we have: ( QU'JT Et (F :( ) ) -+ (F X) . ARG.. This is 2-LISP However the superficial similarity between these two definitions is misleaditlg: they work for quite different reasons. more general It is not difficult to define a capability. definition will look up the binding of Thus in the evaluation of (+ 2 3). because of QUOTE i5 dc-referencing The corresponding definition of virtually identical: (54-132) {DEFINE ~U\)TE2 (lAMBDA IMPR [ARG] ARG» .designators is more inextricably woven into the fundamental distinctions made by the category structure of the dialect itself.4. if handle' (+ application. 2-LISP. because the relationship between entit~es and thei. bu~ as we noticed. returning as a the result that un"cvaluatcd argument tCIIDS the expression. evaluating the body in this case wit! yield that handle. not (LIST 2-LISP 'QUOTE ARG). it is straightforward to define a quote function in I-LISP as well. in other words. evaluation of the body of tile In 54-131 ARG i~ bound to the unevaluatcd argument.

none of those pairs arc accessible from the referent. 1-lISP 'quoted forms arc pairs. Though tllat referent is locally accessible from the pair (eithci' by evaluation or by structural decomposition. as remarked in section 3. In standard has the LISP dialects such a runction has been variously called definition: KWCfE.f.ii. whereas in . is provided prirnitivcly in a function (rather than HANDLE because.leveI from that of one's argum. but the reason is quite straightforward: 2-lISP i3 such a procedure involves semantic level crossing in a way that the primitive processor by and large avoids. but all that this sho\vs is that quoted forms are more finely 1 distinguished than their referents: in and 3 the referents arc indeed the sanle. has to do with identity and type.e. however.. we nlay note).e. In detail the reasons arc messy to set forth. and fol1ow~ng (O[FI. Some examples that use functions wiH illustrate.. to return to our I-LISP'S K~/OTE original concern.0 NIL NIL NIL NIL (S4-136) 4: (LET «X '(A B» (Y '(A B») (EQ (KWOTE X) (KWOTE V»~) EQ In each case returns NIt. that is.:nts. as l ~. So flat obtain a designator at a caned NAME differen~ normal 2-LISP processing that there is no way to meta. neither "EQUAL" "EQ" nor EQ: identity of designator reveals the identity of the referent. it is more general tllan HANDLE! though that needn't concern us here). Finally.JE kWOTE . following examples (these are all 1: (EQ "3 "3) First we look at four cases using -to 2: 3: (EQ "(A B) 't(A 0» (LET « x '( A B») (EQ (KWOT EX) (KWOTE X» ~ -+ -+ -:. it turns out that such a function cannot be defined in 2-LISP. This is i-LISP (S4-136) (LAMBDA EXPR (ARG) (LIST 'QUOTE ARG») The 2-LI!\P version of KWOTE would be exactly the HANDLE function we have used in the equations above. etc.) the value in the 1-LISP case. therefore. QUOTIfY. !-LISP The most salient difference bct\vccn and 2-lISP'S NAME and quotation. rrhere can be in addition an arbiu·ary number of such pairs quoting (designating) the same referent. strikingly. No way.4. 2-lIS~~ a Rationalised Dialect Procedural Reflection '(F X) 289 (QUOTE z (F x» ~ : This is 2-lISP (54-134) More illustrative of the difference between the dialects are two extensional functions that take an s-cxpression as an a:-gument and "return" the s-cxprcssion that designates the result of processing it (i. the normal-jonn in 2-LISP). c will see in section 2-LI~P without primitive help: such a capability. subject to modification like any other. as is illustrated in the I-LISP).

there is 110 need 2-lISP 1: 2: 3: type-identity function. as the examples demonstrate): => => (= "3 "3) (= "(A B) "(A B» (LET [[X '(A B)]] {= (NAME X) (NAME X») 'bT SF (54-138) => => S1 SF 4: (LET [[X '(A B)] [Y '(A B)]] (= (NAME X) (NAME V»~) The 2-LISP NAME function is so often useful in nlcta-stnlctural work that it has its own one that has (= tX tV) lexical abbreviation - a~peared from titne to t. since in all instances the EQUAL arc type-identical.. 3) (EQUAL' . which is locally accessible.. thus the expression 138 would be read "equal up-x "rhus example 54- can be re-written as follows: 1: 2: (= "3 "3) (= "(A B) "(A B» 3: 4: (LET [[X t(A B)]] (= tX tX» (LET [[X '(A B)] [Y '(A B)]] => => => (= $f $F (54-139) tX tV» ~ Sf SF The NAME function. and :1alning issues in general.1nction. We pronounce this "up". that is in a sense :-lccidcntal: 1: 2: (EQUAL' '3 t.4. so that while it works out that returns T just in case the referents are type- identical. Procedural R~flection 290 and 4 the referents are different T however. refer~nts returns in each case. =" is.e on facili~i~s. on the other hand.LISP'S EQ. is not a pair. will be further explored in section 4. (A B) " ( A 8» -+ -+ T T (S4-137) 3: (LET 4: « x '( A B») (EQUAL (KWOTE (LET {(X '(A B» (Y '(A B») (EQUAL (KWOTE X) (KWOTE V»~) X) (KWOTE X») -+ T -+ T In 2-LISP. .ime in previous examples: UP-y". like 1. applications in terms of it can be abbreviated using an up-arrow (Itt"). is not modifiable. an individual identity D. meta-structural '. as the next set of expressions indicates. 2 2-LISP: a Rationalised Dialect EQUAL. The fact that the arguments EQUAL are stnlcture designators is immaterial: it happens that ail quotations of a given structure are typeidentical. and can be used to determine the identity of referent for a (2 -LISP'S . tllcre is a single handle per referent. which is the to EQUAL property is defined ovec.

and its COR. from the numerals.0. F) = Rr ]]] V [[ F~ .L] 1\ [REST ( R. 2-LISP: a Rationalised Dialect Procedural Reflection 291 4. Dec D X This 2-LI~:P semantic domain is thus typed as fonoY.s: . sip. and from a rail all of its For completeness. and truth-values). vii Category Summary The foregoing six sections completely define the 2-LISP (and 3-LISP) field. From each element of s the handle (fesignating that element is accessible.c. from a pair its elements and all of its tails. but from a handle its refereat can be reached.ce the cuntinuous functions over D ]). we define three additional sets of entities whirlt together comprise the remainder of tIle semantical domain: th~ first consisting of non-functional ~onsisting mathematical abstractions (nulnbers..4. we also reproduce here the definition of the FIELDS 2-lIS~ fields: == {F E Il VR C CARS X CORSo X FIRSTS X RESTS X PROPS 1 (54-141) E RAILS . F) = J_ ]]]]} As well as the set S. CAR. are included in the specification of D (i. [[[ 35 f E S [ FIRST( R• F) = Sr]] A [3R r E RAILS [REST(R. and atoms no other stmctures were accessible. sequences. the second of all of the continuous functions defined over the semantical domain (we will break this up into sub-categories in due course). which deserved mention only because that category is finite.t~T ( R• F) = . otherwise.4LUES U SEQUENCES (54-142) The full semantical domain i"s the union of these four: D == S U FUNCTIONS U ABSTRACTIONS U USER-WORLD (54-143) 0 Note that this is a recursive definition of D. and the thire! consisti r ~~ as usual of the user's world of objects in relationship: FUNCTIONS ABSTRACTIONS USER-WORLD = the set of continuous functions oyer 1 = the user's domain of objects in ralatlonsh1p == [ 0 NUMBERS U TRUTH-V. with the exception of ST and SF. We can summarise the six kinds of structural field element by defining s: s == CNUNERALS U BOOLEANS U ATONS U PAIRS U RAILS U HANDLES J (54-140) No individual tokens of any of these categories were mentioned. booleans. the two boolean constants.

The following is provable froID 54120 54-125: vs E S [NfD(HANDLE(S). Each of the sub-categories of the ABSTRACTIONS has its designators of the numbers. truth-values. recursively. in contrast with the parallel notion in the A-calculus. passing. Nonnal-fonn Desigllators We promised to define 2-LISP'S notion of nonnal-form from the category structure of Various comments have been made in the semantical domain.... This has the requisite sparseness: the other five structural categories remain available as normal-form designators of the other scnlantical types (since all nonnal-fonn designators.- 4. tautologically.. rails. 2-lISP: a Rationalised Dialect Procedural Reflection 292 (54-144) Numeral Boolean Pair Fun.S)] With respect to the scmantical category structure given in express~ons (54-146) 54-144. the handles themselves). respectively. whereas we will require: normal.. tion Abstra~tion~~---~~~~ ~ User's worldt----. boolcans. and sequences. where it is defined in terms of the deductive machinery. handles are normal-form designators of all s-expressions (including.0. 0' 1 structural category as normal-form designator: the numerals. canonical. in this chapter. further-more. must be clements of S.. and rails. . are cQllollical nonnal-form designators. about normal form designators.. are normal-form The first two categories arc . viii. but we can summarise them here. as discussed above... handles.vi.a. a sub-class of the s- has been used as the nonnal-forJn designator of all s-exprcssions.4. First we take the s-expressions: as we said in s~ction 4.fonn designators for all of 0). arc not..

. (fhis last.. We still have the freedom. in an infotmal sense. Another possible aesthetic.. numeral. s-~xprcssion in tlie spirit of a Atoms rIbc discussion just laid out CluSllfC.. without violating our mandate of category alignment.. of course. therefore.. however..~slgnator. would be to require a special collection of stnlctural categories. we have indicated above that by and large they are not normal-form designators. and boolean... and on the right is the category structure of the full scman tical domain..Tr~th-values Sa Udnces Abst~act1ons I--". is not a theoretically justifiable claim. Not all rails....-. to make some of them norn'~i-form designators if we choose. each of which was tIle normal-form designator of a particular category of scmantical object. is to identify nonnal-form designators for the functions and for the user's world. Two comments are in order. but rather a pragmatic one: from a Inathcmatical point of .. 2-lISP: a Rationalised Dialect Procedural Reflection 293 rfhus so far we have the following normal-fonn correspondences where on the leftt hdnd side of the diagranl are given the six available structural categories. and will therefore normalise to itself. have no place to slore that information..-. it obtains that cleanliness at the expense of rather too many structural categories (simplicity is palt of cleanliness)...~:-------.S-exp res s 10ns What remains.. are in normal-form: a rail is normal just in case its etcnlcnts are normal. (S4-146) Designator (Structural Category) Designation (Semantic Category) }- I--... Regarding the alOlns and tlle pairs.~_:--------. J-.. suggest) that either atolns or pairs nlight £crve "s the syntactic category for are too atomic: closures must be structural entities containing information. We said in tile previous chapter tllat sorne kind of closure would serve as a normal-folm function c4... and atoms..--.t-"S___ ex Atoms . however. of course. is a normal-form designator. but although this is cleaner in one sense than the proposals we will ultimately adopt. First all elements of the three of the four categories t we have just identified are always in normal fonn: every single handle.. in particular.4. then.

ignated a function: hence a type error was recognised. ) => ~ «EXPR> . 2-LISP: a Rationalised Dialect Procedural Reflection 294 view Yie could simply posit that the atoms.) Pairs. a function defined over pairs was called with an argument lhat dCf. (A .4. designator of the name of an entity section 4. In particular. B) (54-147) => => 'A «EXPR) .vi - As we will explain there. However we will not pursue arc not ruled out by this criterion. ) (CAR (LAMBDA EXPR [X] (+ X I) ) ) (CAR .. in alphabetic order.a. ilJlustratcd in section 4. and should not trouble us. SOine abstract nlachinc . arguments that Ilorlnalise to pairs. even though lve lvill take pairs /0 be the sin/clural fonn of funclion designators. 'fhcrc is in other words no type problem introduced by this choice of normal-form function designator. It is striking to realise that this concern arises out of t1le sClnantical informality of standard LISPS. it is often said.d. would be the normal form designators of the functions computed by of a certain form. The standard concern with making closures out of pairs (or any similar "accessible" type of structure) is that it is inelegant to allow a user to use such functions as CAR and COR over "functions". (We use <Exrn> since the closure that we denote by that abbreviation has no finite lexical notation. the following is defined only over those arguments whose referents are pairs.... not over 2-LISP.~')rm function designators. it does not follow that one can apply the function arguments. can only be applied: they should not look like structures open to dissection.ltcly to function designators as for exanlptc.. to review any possible al'guolcnts against using pairs as nonnal. We would have in analogs will suffice to mlkc the exanlplc clear): (CONS 'A '8) (CAR (CONS 'A 'B» (LAMBDA EXPR [X] (+ X I)} + ~ (this makes use of procedures which will be introduced in the next section. the form "t<EXP>" - designates a nonnal-form designato." of Using this .say a l'uring machine eh suggestions. therefore. how one can even tell - that normal-fonl1 in \Ve will provide ways in which it is possible to obtain a the first of our ITIcta-structural pritnitives using the NJ\ME function <EXP). It is natural.) One might ask how it is noticeable function designators are pairs. since they would seem to satisfy all of the design considerations we have explicitly adopted.&0) => (TYPE-ERROR> <TYPE-ERROR> In the last two cases.· The SCITliantics of function designators would in that case not be r compositional in any way. however. however. Closures. but tllcir l-lISP . CAR CAR indiscrimin.

in other words.. is a poor offering. found the handle '(A. primitive world. . frec (they "contain no information". expecting a pair. more general than > (CAR (CONS > 'A HANDLE): 'A '8)) (54-148) > CONS > «EXPR) . in LISPS' other words.. lIowcver such a decision will not tnuch ilnpillgc on our investigation.. B) strict sep~ration of the reference relationship and the nonnalisotioll relationship. arc of degree at least 2 with respect to the user's 2- We provide the space of primitive names (atoms) f(1r the user.. 2-lISP 3\Vay from dealing All expressions given to the processor. expecting a pair.4. which were contlatcd by traditional notion of evaluation. since they arc contcnt. means not only that we are given an affinnative ans\ver to the question of whether closures should be structures. found the function «EXPR> . in case the user wants to define the user process in a categorically con·cspondent way with the prinlitive LISP process.. For our own S U FUNCTIONS U ABSTRACTIONS. because of tIle fact that the processor we define is always at least one meta-level directly with stnlctures that designate entities in that world. Since \VC know ahead of time nothing about that user's world. ) > tCONS > '«EXPR> . but also that that answer docs not unleash any inelegance or confusion about ho\v pairs and functions can be kept strictly sepHrate. although there is no reason that this would have to be done.. \ve may simply posit that the user may usc atoms for normal. purposes. ) > (CAR CONS) TYPE-ERROR: CAR.. as nonnal-fornl designators. we will assume that no atoms arc normal-foml designators.. Two questions remain: \vhat are to be the normal-fonn designators for the user's world of objects and relationships. 2-LISP: a Rationalised Dialect Procedural Reflection 295 explicit mechanism. as illustrated in the following console session (these examples illustrate why NAME is. and will restrict our attention to It might seem that providing the atoms for the user's usc. ) > (CAR tCONS) > '(EXPR> > t(CONS 'A 'B) ) "(A • B) > (CAR t(CDNS 'A OUf 'B)) TYPE-ERROR: CAR. it will be possible to obtain explicit extensional access to tile closure pairs. and whether atolns are to be normal-form designators at all. folm designators for that part of the scmalltical domain.

and one of the 2-lISP freedoms that comes from implementing is that one enters an entirely new sClnantical framework. in fact. l'hus for tJlis reason as well we have no particular cause for worry about the user's domain. Any real systeln would in all likelihood impose an entire naming structure. Thus the cOlnbinalion of functions and atomic names is in fact a more gcnerDus In addition. Suppose she lost a hat on a trip there: I may standardly refer to that hat as the hat Caitlin lost on our trip to Niagara Falls. Such a standard name is approximately available in this 2-LISP proposal. and designation relationship. not just over its structural and mathematical components. and the name NiC!gara Falls as the Danle of the drop in the river between Lake Ontario and Lake Eric. course we don't have the definite description operator allotment than might at first appear. even though the search for context-dependent appropriate ways of rcfering is an important and difficult task. of course.designators. the "data structures" \vould designate structural elclnents of the structural field of the implemented architecture . Second. First. it is natural in English to use proper names as even as rigid . The final arrangcnlcnt of norulal·form designation. the functions in canonical FUNCTIONS are defined over all of 0. is sumtnariscd in the following diagram: . However two comments argue against this alleged meanness on our part.4. In such a circumstance. but the general poirl~ remains). would serve only to ilnplel11ent such a system. then. Thus I may have the name Caitlin as the standard name of my daughter. there is unlikely to be a serviceable notion of normal-fonn designator in an actual practical systenl. 2-LISP: a Rationalised Dialect Procedural Reflection 296 in any sense).lnctions defined over atomic and rigid proper names (uf "U1C". since jt is constituted of fi. on top of zLISP: our dialect.which would presumably be well-defined and straightfof\vardly dcnotablc. Standard names for objects that are not proper names are typically formed of functions defined with respect to other proper names.

F)} T 31 [lS. a. F E FIELDS -to S· 1 (54-161) .4. F E FIELDS [{HANDlE(S)} U [case TVPE(S) NUMERAL -+ {} BOOLEAN -+ {} ATOM -to -. S . E € ENVS. 2-LISP In the English describing the six 2-lISP structural categories we made reference to the variety of OUf accessibility relationships for elements of each category. (54-160) ACCESSIBLE : [C S X ENVS X FIELDS 1 == AS € S.F)] ]]} U { R 3 i [1 ~ i ~ l ENG TH( S) [ R = TAl L( I . ACCESIDlE*(S) is the set of all clements of S that can be reached in a finite nunlber of local relationships from s. did not deal with this aspect of the field . ACCESSIBLE- takes an expression onto the transitive closure of thus.a lack we will now correct. formulation of the import of various of the primitive LISP'S mathematical reconstructions. and graphical notation. S· J E(5) PAIR RAIL HANDLE -+ {CAR(S. ACCESSIBLE that takes an clement s of F s. CDR(S.F). .. before looking at the primitive procedures: the locality metric on the field. e) requires reference to this accessibility relationship (CONS. procedures (and even of 2- however.fccessibi[ity There arc two final concerns we must attend to. ACCESSIBLE[C S X ENVS X FIELDS 1 a AS E S.t ( s) }] ] ACCESSIBLE: -+ [ { I I -+ Similarly. ix.1~lENGTH(S) [T = NTH(N. since the 2-lISP . We will define a meta-theoretic function and a field F. F) ]] }] {HANDLE. for example. will require such a treatment). 2-lISP: a Rationalised Dialect Procedural Reflection 297 (54-149) Designator (Structural Category) Designation (Semantic Category) Abstractions Functions S-expressions User's world Atoms 4. E E ENVS. onto the set of structures in s accessible in from s.S.

It will be useful. Graphical Notation \Ve tum finally to graphical notation. Since pairs and rails are created new upon reading. booteans. Thus we can defme: VISIBlES == 'IS E [ ATONS U NUMERALS U BOOLEANS the union of ACCESSIBlE*(S) 1 (54-162) It is this set. 2-lISP: a Rationalised Dialect [the smallest set T C S such that Procedural Reflection 298 IT ACCESSIBlE(S) C T] A [ \IS' € T [ ACESSIBlE( S') C T]]]] What we then need a name for is the set of all structures that can be reached. in addition. and usc it instead to notate rails. REST. The handles. in a given context. any Dlunbcr of boxes. for example. circles. can be ignored (they will be included automatically). therefore. and handles. it is clear that the graphical notation we defined in chapter 2 \vill no longer apply.4. and triangles. and arrows for the relationships. some of them will arise when we characterise the full computHtional significance of structure generating procedures such as 4. appropriate 2-lISP In this section. so as to allow CDR. 11lus we have the following sample of these five types: . matters here. from structures that can be typed in. furtllermorc. that would have to be saved by a garbage collector on a marking or collecting pass. FIRST. types. the left hand used for the CAR. We wHl generalise the "two-box" icons we lIsed in with a diamond. but by and large we will simply usc tlleir lexical names rather than particular icons. and booleans will be notated with dots. Pairs will be demarcated instead the right hand side for the Numerals. atoms. we \vill briefly define an and PROPERTY 1-lISP graphical notation. It is this set. in some of the subsequent discussion to have a notation whose objects correspond one-ta-one with the structural field entities they notate. comprising an icon type for each of the six structure CAR. by our account of 8. Though we will not spell out these CONS.ax. in which pairs and rails notated by parentheses and brackets must not fall. since they are accessible from their referents. for pairs. CDR. atoms. Since we have redefined the structural I-LISP elements out of which our field is conlposcd. this reduces to those accessible from the numerals.

we need to be able to indicate that graphically (since we have to preserve the one-to-one nature of e). such that the first tail of Y was the same rail as the second tail of x.4. Since there is exactly one handle per other structure. notation for its referent. and at its right hand end with the left hand border of the box notating the tail. Thus if x was the rail would. 2-lISP: a Rationalised Dialect Procedural Reflection 299 (54-163) <J> Numeral: • Pair: Rail: Boolean: £or~ Atom: or IT] or 0 ITIID etc. be appropriate: [1 2 3 4]. Thus between any adjacent boxes in a rail icon we will admit if necessary a double linc. distinct rails can of course have no eletncnts at all (this is what is indicated by the isolated single line at the left of the bottom row of 54-153). the foltowing notates the structure (JOIN (RCONS) (NAME (SCONS») (\ve immediatley begin to use the standard extension of allowing lexical items to replace graphical icons where that is appropriate particularly for the constants): (S4-166) JOIN NAME RCONS SCONS Finally. and Y was [0 3 4]. connecting at its left hand end with the right hand border of a box. Thus. the following notation (54-164) X: Y: In addition. I or D There is one complexity here: since rails can share tails. we need a convention whereby the handle icon is uniquely associated with the We will adopt the following protocol: a small box sitting itnmcdiatcly adjacent to and above (usually to the left) of a structure will notate the handle . we need a notation for handles.

. 2-lISP: a Rationalised Dialect Procedural Reflection (peONS 'A 'B) 300 of that structure.. one would internalisc the structure (54-168) However there is another reading of that expression.. If one were to read in the expression notated as follows: (RCONS • ( F) .4. g~ven our protocols pn hacdle~~ t'le 9 p~ssibi1ity of using two different llandles. etc..). ( F) ). by which the appropriate graphical notation would be this: (54-169) "fhough we will not usc graphical notation often. Thus the structure lexically notated as following graphical image: would have the (54-166) ~1ultiple handles would be notated in the obvious way. thus the following notates the (= ' (+ 2 3) expression . it will sometimes be crucial in order to demonstrate the token identity of certain circular and shared structures. of course. one of which is the other's referent (or the other s referent's referent. ( + 3 2) ) : (54-167) There is.

and. in other words. The manner in which these procedures are made available is this: in the initial 2-lISP environment (to which we will again meta-theoretically refer using the name Eo> thirty-two atoms are bound to thirty-two primitively recognised lIormal-fonn jitnction d~~sigllalors. 2-lISP: A Rationalised Dialect Procedural Reflection 301 4. these names can be redefined. we will simply illustrate their use. rather than in virtue of any recursive procedural decomposition of tllcir "body" expressions. in "unit time"). There are thirty-two primitive 2-LISP procedures. . are treated primitively and atomically (i.4. 2LISP differs from I-LISP. listed in the table below.b. although we have introduced more of 2-LISP than would traditionally be the case at such a points since we defined much of the declarative semantics. in particular.. so to speak. It is siJnpler and more elegant to have all primitives be in Donna] fonn (whicl1 closures are) rather than l1aving certain context-relative atoms be primitive in some standard initial environment. with respect to the field itself: rather than with respect to primitive functions defined over it Nonetheless. in terms of its effect on the structural field laid out in the last section. and other names can be bound to the primitively-recognised closures. we must now tum to 2-LISP behaviour. Though it is convenient to provide standard names for them in the initial environment. in that it is the closures tllat are primitive. however. Just what nomlal-form designators are LAMBDA. without any observable intcnllcdiate states.d after we introduce Reductions in tCffilS first. of these primitive closures. structurally like will become clearer in section 4. rather than their names. and also such formal notions as accessibility. Simple 2-LISP Primitives We have not yet introduced any of the primitive 2-lISP procedures.e.

vii.. Arithmetic Prbnitives The four simple "arithmetic" functions (addition. as enlbodicd in the full significance function :t.4. -. . IMPR. RPlACD RPLACN. substraction.c) we will deal with the first two. three kinds of account are relevant: its declarative import. "" the first of. -. "rhus we have (all of the examples in this section will be given relative to Eo> the following normatisations: (+ 2 3) (* 10 -4) (I (* 4 4) (+ 4 4» =. sequences. PREP A!odifiers: RPlACA. these: that the pair normalises to the numeral 5. not de-referencing. CAR. modify. CDR LENGTH. TAIL RCONS.b through 4. LAMBDA lvalnillg: Functions: EXPR. and an account of how it is computationally tractable (i. and bind names three types of function designator to mediate between sign and significant primitive access to the processor functions For each procedure type.. We will (+ 2 3) look in particular. 2-lISP First. they illustrate a profusion of facts about 2-LISP.h. multiplication. => ~ 6 -40 2 (54-166) Sirnple as these examples appear...i.d. SCONS. it should be clear that. a computational account of how it can be made to work). truth-values. In this and the following sections (4. wh. REDUCE (S4-166) as usual defined over 6 syntactic and 4 semantic types s-expressions. . TERPRI Control: IF SET. I Typing: TYPE Identity: • Structural: peONS. and I. although the driving behaviour of the processor is one of Ilonnalisation. 2-lISP: A Rationalised Dialect Procedural Retlection 302 The Z-LISP Primitive Procedures Arithmetic: +. 4. REFERENT Processor: NORMALISE. PRINT. RPlACT I/O: READ. 11umbers to construct and examine pairs to examine rails and sequences to constnlct" to modify pairs to modify rails It II as usual an if-thcn-else conditional to define.en we discuss the 2 -lISP meta-circular processor. its proc~dural consequence. and division) are designated in Eo by the atoms +. these functions (and most other we will examine) . the third will be taken up for the dialect as a whole in section 4.e. in considerable depth. MACRO Semantics: NAME. NTH.

this is a pair. it engenders the normalisation of its argulncnts. [2 3])".that is circular and primitively recognised (it is the normalisation of the rather un·infonnative lambda abstraction {LAMBDA EXPR [X Y] (+ x Y»). yielding numerals. whic:t. Similarly. First we look at (+ 2 3) declaratively. (CAR '( A • B» namely. 2-LISP: A Rationalised Dialect Procedural I:teflection 303 are declaratively extensional. of course. argument. whose first element is the numeral 2. normalises its to speak. it designates an extensional function. not a pair. whose CAR is the atom + and whose CDR is a two-eletnent rail. the atom A. not the number that is the sum of its normalised arguments. ~ of the prhnitive addition closure (in all contexts) is the cxtensionatisation of the addition function: \f E E ENVS • F E FIELOS [f) EF{ Eo ( " +» = EXT ( +) ] (54-167) where EXT is the 2-lISP cxtensionalisation function. and whose second ctclnent is the numeral 3. being a handle.4. applications fonned in terms of it nonetheless designate the number that is the sum of the numbers designated by its arguments. but in our present circumstance only the tllat CDR designates a sequence (which it must in order for the whole reduction to be wcll- . In Eo the atom + is bound to a closure . designates the CArl of the pair designated by that handle - A nannalising processor and an extensional selnant. a different story needs to be told). Thus CAR.cs are fully compatible. in the sense that from a declarative point of view they are defined over the referents of their arguments (although procedurally. if multiple arguments. of course. Thus. how in combination they enable us to prove that + We will sec the consequences of both of tllese facts in eacll of the following two stories. nonnalises to itself: '( A "receives" as its intennediate value a handle. as of course the x-calculus and all previous mathematical calculi make manifest overarching fact that will lead us to a particular definition of enable us to align EXT It is this and will EXT for 2-LISP. and will then show satisfies the over-arching normalisation mandate. From tJ1C fact that this is an EXPR two tllings follow: declaratively.a normal-form function designator . Structurally. SO Nonetheless. I-LISP The version of this meta-theoretic CDR function that we constructed for was cOlnplicated by the fact that it had to deal with needs to be examined. We will consider the (+ 2 3) example in more detail. as we will see below. and procedurally. although + is a procedure which normalises its arguments. (CAR '(A • B» • B). and EXPR. since "( + 2 3)" is an abbreviation for "(+ .

In particular.M(NTH(2. [~(S. we designate the circular closure sketched in 4.D t 2 .5 z.AE.F 1 > • G(D t t . (54-168) E.4. we would more simply say (since this has inherently to do with tllC fact that + is an EXPR): (54-171) To translate this into English. In particular. [A(St.D 2 . it would be convenient if. instead of writing 54-170 . but before turning to an example we should straightaway define some tneta- theoretic nlachinery that will enable us to say what we have just said much more compactly.F z )]] This is sufficient characterisation to prove anything we need to prove about (binary) addition. Ez. continuations. [~(S..F z ».F 2 > • C(M. its full characterisation will be examined in section = "«EXPR> Eo ex Y] (+ x Y)) (54-169) Finally.~F..E t . numeral addition processing applications formed in terms of it its arguments.E. as we might expect. . since we expect a rail): ~(Eo(n+» over the results of its arguments (actually over the first and second clement of the result of = AS.E 2 . F.1 (+(M(NTH(1. the .nlernalisalion of this closure - the function computed by the processor when is. as noted earlier. this sinlply states that the intcrnalisation of the (primitive) addition closure is EXPR of numeral addition. if the out in 54-105 will show how that EXT CDR is a rail (the typical case). . Dt.AE.S2. We had no need to talk of the full significance of the argulncnts.Otk)]]] The closure itself is a pair of the following form (by <EXPR>. or the rest .F l ») • .F. 2-lISP: A Rationalised Dialect Procedural Reflection COR 304 formed semantically) then the computational significance of thc goes. (54-170) [A(Sz. then the significance of rails set will will playa role.~C.dJii): Eo("+) 53-200. However in general the following definition of suffice (we start straight away with a definition phrased in tenns of the full computational significance 1:): EXT == AG [AS. note that tile internalisation of the plus closure contains some complexity having to do with the nortnalisation of its arguments.AF.

a function (to be extcnsionalised).N 2 ) .M(N 2 »)]) SIMPlE("I..G Z ) • (54-176) ITEo(l) = r"(EXPR> ED [V 1 V2 . C(E o(L). vkJ (1 VI Vz .AF .F t ).[A<N 1 .t (*(M(N 1 ). lOllS we can assert: (54-116) This single formula encodes all we need to say about addition.F. C(G<NTH(I.AC . that need to be stated: the form of the primitive closure. the designated function. and we can define the following uleta-theoretic function: internal function.D t . El . 2-lISP: A Rationalised Dialect Procedural Reflectiun 305 What this requires is a suitable definition of EXPR. we collapse these two into a single notion of being silnple. [l:<S. Vk ))l] A [~(Eo(L» = AE.F t ).-characterisation. thus we can use it to cOlnpletely characterise the semantics of the other three arithmetic operators: SIMPlE("·. [A<Sl. E. l'hcrefore SIMPLE == A<l.E..F)] ex (54-173) Yl '(+ x Y)).M(N 2 »)]) (S4-117) . First. M.AE.t (-(M(N l ). and the additional internalisation of = AE.NTH(2. there are three pieces of information beyond tllat.-. we can then set out the full computational significance of the atom its local procedural significance: ~(Eo("+» + in the initial envirODlnent 11lis takes two parts (as we saw in the last chapter): its l.EXT(G 1 ). M.AC.1 (/(M(N t ).E 1 . Second.N 2 > • M.Sl.Sl.AF.4..M(N 2 »)]) SIMPLE("-. and another function that is the internalisation of the primitive closure.F)] A [ & [ Eo ( L)] = EX PR( G2) ]] The variables l.. which is easy to define: EXPR == AG • [AS.I. GIt and 6 2 in this definition arc intended to be bound to an atolnic label. all Ule signified computations are side-effect th~ free.F t )]]] (54-172) Thus 54-171 can be taken as equivalent to 54-170.~C.N z> .F t > . [C("«EXPR> Eo EXT(+). and (54-174) Finally.G1. There are two salient facts about the previous t\VO equations.[A<N t .·.AF. To review.E.[A<N 1 .

F)] VA E A TONS. C) = C(E(A}.F t > • [(AS t )(F I 2 (P) .F.[Dt(F12(p). C ~(P. and rails. But this could all be taken care of without interest) In order to see this characterisation at work.E. where S 0 E NTfI(1. REST(S. as the intent is clear. is not restricted to SIMPLE: we would need special versions of EXT.E2.F 2 ) • (54-178) (54-179) E CONTS (54-180) C(Sz. F E FIELDS. and 54105 that give the declarative import of numerals.Do. We repeat here.F) elself [NTU(l. Vi l:$i=:.F a)])]) Do E SEQUENCES. 54-38. [A(SI. SIMPLE would need to know the number of arguments (K) of the functions in question. furthermore.S.F) :: lENGTH(D o) = LENGTH(D). E.E 2 .E.D 1 . The problem. C E CONTS [~(N.F t • [A(5 2 .Et.E. E E ENVS. 54-29.F a ) :: "2. we will look in full at the significance of the term (+ 2 3). F E FIELDS. 2-LISP: A Rationalised Dialect Procedural Reflection 306 (Strictly. in Eo.E t . E. and returns We will look. E2 .E2.F» (+ 2 3> ° 1. atoms. C E CONTS [~(A. as the reader will have noticed.4.F»] then C(R. respectively: 'iN E NUMERALS. M(N). C) = C(N.Ot. we can prove that the ntuner'll 5.R. in particular. [A(St.F . E E ENVS.(>. E E ENVS.F). for reference.R.E. 1 E RAILS and [~(R2.F 3 ) = 51. C E CONTS [L(R.E 1 . designates the number five. E. ] In tenns of all of these. This could be repaired either by passing that number to latter case 54-115 SIMPLE as a fourth argument. F)]· VP E PAIRS. LENGTH(R.E 1 . E E ENVS.F) = . F. or by using an indefinite number of different versions of SIMPLE.E.L] (54-181) then C("[1.R.F). = 0 Vi l:Si:SLENGTH(D z ) [ Oi+l = Dzt ].F) [NORMAl-FORM(NTH(i.C) = ~(Ft(P).LENGTH(Oo> [ 0 0 1 :: «I>EF(NTII(i .F. rather than as a definition itself: We will not worry about this here.e) :: if [Vi l::.R. at the meta-thcoretie tern1: .F 1 ) • I(REST(R.. of course. and so forth.E. F3 :: Fz otherwise.D2. EXPR..i~lENGTH(R. F E FIELDS.D.F2)])]]) VR E RAILS.Ft)]. pairs.F) where "[1 is inaccessible in F else ~(NTH(1.F2> SEQUENCES and · C(S. equations 54-21.F. F E FIELDS.f 1 . <IlEF(E(A». F. in the could be taken as a definition schema.Et. E.

Ez.D 1 .F z>])]] Y] (+ X Y».EXT(+}.E z .F 2 > .E z . G(01 1 .F 1 > . Eo. <Sz.E z .E.E z. and ridding ourselves of the inco. Olk)]]]] This extensionalisation can be reduced: = ([A<SI.F 1 )].F 2>])]] <E o("+) .Ft> .E z . .F z>])]] (~ x Y»).01. F1 .Fo.ID(S2.E t .F o.Fl> Eo .f 1 .F 1 .F z> . 2-LISP: A Rationalised Dialect 2 3). (54-186) [(AS 1 )(F t 2 ("(+ 2 3).F 2>])]] Y] (+ x Y».E o . we get: ([~<Sl.AE. .f 1 )].F 1 )].Dl. leads to: ~("+.nscquential = 10. [AS.E 1 .[Ol(F?("(+ 2 3».[D t (F t 2 (.F t • [A<5 z .OI 2 .Eo.F 1 )].E 1 .E o.[D 1 (F 12 ("(+ 2 3).E 1 .F t • [A<Sz.F o» Expanding next the extensionalisation of the (meta-theoretic) addit::)n function. Fo>) [~(S. (54-188) <"«EXPR> Eo ex [A<Sz.F a» We are now ready for some addition-specific reductions.Eo.F 1)].E 1 .F2>.E t .E 1 . Eo.F t ) 2 • [ ( &5 1 ) ( F1 ( " (+ 2 3).[Dt(FI2{"(+ 2 3).Dl. [A<S2.(+ 2 3».4.Et.F1> .El. [A<Sl. D t .F. thus 54-179 applies: ([A<Sl. In particular. +).F 2 > .AF. <Sz. 3). Et • F1 .F 1 )].D 1 .E1. (54-184) l.F z)])]]) Performing the CAR on Fo to extract the function designator.E [A(Sl.. .Ez.Dt."«EXPR> Eo ex Y] ([AG .ID) Procedural Reflection 307 ~("(+ (54-182) First we apply ~(~(+ 54-181 siuce (+ 2 3) is a pair: (S4-183) = ~ ( F0t ( " (+ 2 3 J). . [A(Sz.Eo. .E 2 . .F z>])]]) The term "+ is an atom.E 1 .El.E 1 .ID) [A<Sl. (54-186) [(as 1) ( F1 2 ( " (+ ·2 <"«EXPR) Eo ex [A<Sz.[D t {f 1Z{"(+ 2 3).F 2 > . and its designation in that context: ([~<Sl.E z. F0' 2 3).4>E oFo{E o{"+» .[D t (f t 2 ("(+ 2 3). <Sz.E 1 . [(&Sl)(f 1 2 ("(+ 2 3).E 2 .F z> • <Sz. we insert tile binding of the atorn +.F o .Fl> .E 1 .E 1. EZ. <Sz. (54-187) [(&Sl)(F 12 ("(+ 2 3).F 1 ) • [(AS 1 )(F 12 ("(+ 2 3).E z . E1 .

Ot )]] Fz»]>] We tum now to the full significance of the expression [2 3] in the initial context.AE.E o. after all. Eo. E2 r Fz>]>] ex (54-189) • +(0 1 1 . +(0 11 . [A(Sz.0 1 2 .3>. +(Ot1.F. 2-LISP: A Rationalised Dialect .E 1 .F.4.Olk)]]]. Fz > • ex Y] (+ x V))]) (54-190) [1:("[2 3].0 12 . F0 2 ( N (+ to "[2 3]): = [(d["(EXPR) Eo <52' (F 0 2 ("(+ Z 3). is the A-calculus but applicative order seems the most natural way to rroceed): = [(A["«EXPR> Eo Y] (+ x Y)J]) <F 0 2 ("(+ 2 3).AF. E2 . [A<S2.OI.F 2 > .F o• [>"<5 2 .<2.F o». Procedural Reflection 308 [:E(S.Ft> . after perfonning that straightforward Z 3) CDR on F0 (reducing.E o.~•.f 1 > . . There are no further reductions applicable to the four arguments to the continuation.F t > . in other words. .this.012 . . We have indicated straight away that all of the clements of tIle designated sequence are numbers.0I. ..F 1 > (f 02 ("(+ 2 3).D 1 . E2 • +(0 1 1 .F Ot [A<Sl. of course.Ol lc )]]] We can reduce the innennost application formed in terms of the extensionalised addition function. thus a usc of 5-1-181 is indicated.F o» Ez . [A<SI.E.AF • [:E(S. thus the rail itself is returned rather straightforwardly. we can therefore reduce it (not. In the present case all elements of the rail are in normal-form. where we wilt carryover this formulation intact.E 1 ..E. Though term in question» of course. Fz>]>] (+ x V})]) (54-19") ([A<Sl. is we do this in full here.E o..E z . it win (as was the case in the examples of last chapter) arise again below.. . k .. [AS.Dl. . Ez • F2 ) • <52' ([}.F o.E1. AE. this is implied by the significance of numerals manifested in 54-178: = [(A["(EXPR) !l ex Y] <F0 2 (" (+ 2 3}). [A<SI. . l~he a rail. <52.E 1 .E o .0 12 )] <"[2 3].E o . f o.. that the reduction order matters .

F z)]» In preparation for the next reduction.Sz»).E o.A.F2.F.E 2 .3> is ignored): . 6 • E3.F o. (S2.Fz.E2. E 3 > • <Sa.fz> · C(M-l(+(M(NTH(1.F o» Applying this.S2»). F3>] <M-l(+(M{NTH(1.Ez.F z) .E o. f l>])] ex (S4-1Q3) Next we need to explore the internalised function engendered by the primitive addition closure. (54-195) [A<Sz.S2»).<2.F z> • ([A<S3.F2. F0 • Performing the addition.fz. [:t(S.Ez.F2.F2.E 2 .3}.[A<Sz.SZ»).F2.SZ».Ez.F 2 ) • <Sz.E z.F l ) .F3>]» Then applying the arguments: = [1:("[2 3]. we need to perform an a-reduction to avoid potential variable collisions: = ([AS. [~(S.E 2 . it leads to: = ([AS.+(2.E.E o. F3> · <S3.E z. We can also execute the outstanding CDR to obtain the arguments to the internal addition function: = [(4["«EXPR) Eo Y] (+ x V))]) (W[2 3]. 5 •E3.F o• (54-196) [A<Sz.F 3 >] 3.AE.Dz.F o.F z> · <S2.Fl.f2)]]] <"[2 3]. E3. simple reduction leads to: = [(~[W«EXPR> ED < 2 F0 ( " [X Yl (+ X V))]) (54-192) [A<Sz.Dz.AC. 2-lISP: A Rationalised Dialect Procedural Reflection 309 .[A<Sz.5.AF.F o.E. once again it is = ([A<Sz.Fz»] <"[2 3].E2.S2».F2»]] Once again we need the full significance of the nonnal-form rail simple: [2 3].Dz. we are set to perfonn the numeral addition (note that this time the abstract sequence <z .M(NTH(2.E3.3>.S~».F z> · (S4-197) ([A<S3.D2 .AC.E2.E 3 .M(NTH(2.4.E 2 .Sz». we have proved that (+ 2 3) designates the number 5.E o. Eo.E o.M(NTH(2.F 3 ) • <S3.Fz)]]] <"[2 3]. This was set forth in 54-174.6.AE. (54-194) [A<Sz. C(M-l(+(M(NTH(l.M(NTH(2. 6•Ez..F <M-l(+(M(NTH(1.[A<S3.Ez.f.F 2>]>] (+ 2 3) .AF.

In order to complete the ana1 from the third.1 (+(M(NTH(l. and because of the ancillary fact tllat numerals are nannal fonn. 2-LISP: A Rationalised Dialect Procedural Reflection 310 • ([A<SJ.Eo.iv. 6 • E3.t (+(2. Because of this fact.ysis. whereas the I-LISP expression (CAR '(A B C» designated what it returned. inquiring as to how it is actually manipulated by the fanna) processor."[2 3J»).F 3 ) • <S3. we have proved tIle following very particular instnnce of the nornlalisation theorem: ([ ~EoFO(i'EoFO("(+ 2 3)) = cl»EoFQ("(+ 2 3)] [NORMAl-FORM('i'EoFo("(+ 2 3)) n A (S4-204) We have looked carefully at (+ 2 3) from two points of view: declarative and .M("3».1 (+(M("2).E 3 .F 3 ) 2 <S3.E o .E 3 . 6 • E3. computational.e.F o» (54-199) The numeral addition is simple: = ([A<S3. F3>] (M-l(~). however) we have shown how the result and the designation need not be the same. we will very briefly exalnine it procedural selnantics. standpoint. the top level continuation puts togetl1cr the designation (the number five) and the result (the numeral 5). 6 •E3. unlike that case.E o . In particular."[2 3J».F o . in a proof that in many ways resembles the example comprising section 3.E3.E3.E o.4. <S3. First. how a complete derivation of the full significance of an expression yields both its designation and its result. this case involved no side effects.F3>] <M. as well as manifesting any side-effects that may have occurred during its processing. F3>] <M. Thus the local procedural import of (+ 2 3) is the nunlcral that designates the declarative import.6.. the 2-LISP term (+ 2 3) designated an abstract number. have shown. for a full significance of: = ("6. but returned the numeral.F o» (54"'198) Expanding the a NTHS: ([A<S3.F o» <S3.Fo» (54-200) (54-201) (54-202) ([A<S3.F o .3).6.E o. Like that example. E3.F3> . F3>] <M.F o> (54-203) \VC What then have we done? A number of things.M(NTH(2. F3> Finally. .

However two important points should be made here. in our particular case. the binding of + is retrieved (mandated by 54-173). We have shown how a particular example of a pair satisfied the theorem. which would be required in order to show that a/olns satisfy the theorem in all contexts. and is therefore "returned" as tJte normalisation The closure and the nonnal-fonn rail are then reduced primitively. [2 3] designates the abstract sequence of numbers. Nor have we shown that bindings arc in nonnal-foIm.4. from the point of view of the processor. there is no sense in which the designation of any tenn is produced. In our case there are two elements. We have shown tllat four of the six 2-lISP stnlctures satisfy the nonnalisation mandate: the booleans. the processor first detcnnines whether the rail is a nonnal-fonn designator already . 2-LISP since the closure is a primitive closure.when a rail is normalised. still in Eo. The entire machinery in our meta-language dealing with declarative import merely assures us that our structures remains alligned wittl what the processor docs. I'~ We will. It is part of the definition of the processor that the appropriate numeral addition function is effected in a single step. One other general comment needs to be made before we look at other primitive procedures. the handles. in a less mat11cmatical way.d. Since that closure is discen'. be taken up in section 4. We will see how "answers" are returned in terms of continuation in due course. Since that CAR is an atom. both of which are numerals. 2-LISP 5 is returned as the nonnalisation of the More details on how the processor may be embodied will. the numerals. when the pair (+ 2 3) is normalised in Eo. the CDR of the original pair is normalised. but we have of course not shown that pairs do in general. from beginning to end. is fonnal.a condition true just in case the elements are themselves in normal fonn. The COR in this ca~Jc is the rail [2 3]. next. as promised. not do tltis: the basic structure of such a pro()~ however. Nor. the CAR of the pair is normalised in Eo. in the last case. is exhibited in the . It in no way knows that (+ 2 3) designates five. for the time being we can merely see that. for that pre-theoretic attribution of meaning to 2-lISP does it care. First.vii. of the CDR. and the raits (providing. examined. . in this case. hence the rail is in normal-fonn. yielding the closure «EXPR> Eo [X Y] (+ x V»~. because this is a cOlnputalional system. or anything else. that their clements satisfy it). looked at. the ounlcral original expression (+ 2 3). Computation. . 2-LISP: A Rationalised Dialect Procedural Reflection 311 First. as we mentioned earlier. '1bly an EXPR. as mandated by 54-180. nor does it know that matt~r.

it would emerge in the line of the that the real addition function would be applied to the abstract sequence <3. is semantically strict. the expression ". and addition is defined over numbers. This is 2-LISP '4 (54-206) TYPE-ERROR: +. 2-LISP. expecting a numoe •• found the numeral This is of course correct. because in encounter the following: numerals evaluate to themselves. of course. In on tllC other hand. Since ~he 2-lISP expressions. But the matllematics has been sufficient for our present purposes. we would > (+ 3 '4) . then the pair itself would satisfy it We would then show that all primitive procedures were standard. and if the function were standard. where we discussed proving the corresponding evaluation theorem for I-lISP: we would show that if all arguments to a pair satisfied the theorem. Consider for example the following example of l-L ISP evaluation: . For such very trivial examples as these this strictness might seem an inconvenience or even a mis-feature. however." 4>. questions of reflection. it may be said. designating a numeral. which of course is inadmissable. is easily demonstrable by making some errors. 11lat this is not so. This is I-LISP t-LISP > (+ >7 3 '4) (54-205) This "works". these few simple examples have shown how this general property can be straightforwardly embodied in an approximately familiar examples of the use of the 2-lISP arithmetic functions arc so simple. We conclude this section with a final comment about 2-lISP arithmetic. quoted numerals evaluate to numerals as well.4. thcre is a tendency to think tllut there are no disccrnable surface differences from the behaviour of I-LISP. In what follows we will ease up on formalism. 2-LISP: A Rationalised Dialect Procedural Reflection 312 structure of the examples we have given. we will see that the ability to rely \Vhcn we turn to O~l the scmantical . not derivation corresponding to 54-201 DVC!" numerals. If this example were analysed semantically in the manner of our long example above. 4" is a handle. The strategy would be similar to that suggested at the end of the previous chapter. in order better to convey the subtlety of the particular properties of the procedures to be introduced. whereas 2-lISP. and that all procedures composabtc and definable within the dialect were standard if their consituents were standard. The nonnalisation tllcorem mandates a general scmantical cast to be honored by all dialect.

.y. engendering great flexibilit. .4.levels - in particular. on the fact that nonnalisation process never crosses semantic is a great boon. 2-LISP: A Rationalised Dialect Procedural Reflection 313 strictness mcta.

(CAR '(A.)4-211) behavio~r designator of that atom.[A<S2. The whole expression. which is a handle that designates the pair (A • B). [AS t . of the structure designated by x in the context of use.e. designates the atom A.iL Seleclorson Pairs We turn next to the simplest of the 2-LISP primitives that allow one to examine structures: CAR CAR and CDR. F)] = [AE.~F.~El. First C("(EXPR Eo [X] (CAR X)). CDR F is bound (we will focus on is entirely parallel): (54-210) SIMPLE("CAR.1(NTH(l. the internalisation of the primitive 4[E oC"CAR)] = AS1. The expression witt therefore normalise to the normal-form In other words: (. [~(Sl. (54-212) ~(51. the pri'llitive closure (the binding of CAR in Eo> signifies a function that nOffilaliscs its argument (SI). we cannot define them in tenns of EXT or SIMPLE.Sa.AF1. (CAR '( A • B» will designate the CAR of the pair designated by the argument. AFt. because we need to use the field passed in as an argument What we aim for is something that captures the indcnded meaning of the following formula i. These are extensional functions. thus (CAR X) will designate the 1-LISP.El. [AX.AC. Both the declarative and procedural treatments.1 (X).F»] For example.F a)])] CAR In English.. are formulated in tcnns of the full significance of that argument: what it returns is called both 52 and 53.D3 . F3»». CAR(D 2 .AC. As was true in however. as usual. therefore.F 3 > • C(HANDlE(CAR(HANDLE.4.will engender this tile full significance: ~(Eo("CAR» are straightforward.b.E 3 . B» => 'A The semantical equations that.F)].F 2 )])] Second.Flt CAR closure: (54-213) [A<S3. 2-LISP: A Rationalised Dialect Procedural Reflection 314 4.Ft. Aft. [i\X. which is the handle · A. what these two together imply is that in any context.CAR(X. the appropriate modification of this that ensures that CAR.Et. E.E2IF~> .02. what it designates is .E a .HANDLE(CAR(HANDlE.

[A(X I . we lise E1 and F1 to establish the designation O2 of RI • rather than E and F.F. E € ENVS.E. similarly (from the internalised function) we can sec that it will return a handle designating that CAR. The first move in our proof is a recasting of the definition of although 54-214 best manifests the intent of the predicate. Secondly.F 1 • [A<R 2 . Falsity} 1 (54-217) [VP € PAIRS.E z . .F 2 > · [[0 1 = Oz] 1\ [NORr~Al-FORM(Rl)]]])]]]] There are a variety of things to note straightaway about this fannulation. in particular) is the following: STANDARD : C S == AS E S .AS • .AF. it follows. F) = S] :J .X3'X.F. ~ • [A<R I . Falsity} 1 (54-214) ['1P E PAIRS.E.e.F) = 5] [:t(P.4.F .X2. F E FIELDS [[CAR(P. -+ {Truth.> [~(S.[A<Xl. because of the nonnalisation theorem. [~(S. we know that S3 designates 03t and we have just pointed out that 03 and O2 are the same entity.E. We know this because it returns a handle of the CAR of the referent of 53.As from S3-t30: (54-216) == AE.E 1 . E E ENVS. The appropriate definition of that tenn for 2-LISP (for a normalising language. 2-lISP: A Rationalised Dialect and Procedural Reflection 315 called both of the CAR 02 03. as it would be analogous in structure to the one given in the previous section. It follows from the equations that any app1ica~ion fonned in terms CAR function will designate the of O2 in the field that is returned. -+ {Truth.X 3 .> . F € FIELDS [[ CAR (P. this was Incntioned earlier as being the more proper approach.D I .E 1 .F 1 ) I{R t . the following obviously equivalent formulation is evidently easier to prove: STANDARD : C S == AS E S . Xt])] Xz])] STANDARD.AF . First.X 2 . and.v.D z . What we wish to prove is the following: STANDARD(Eo("CAR» We will need the following definitions of 4' and it in tcrnlS of 'I' cit =: AE.X. if we can prove the NORMAl- . We need not prescnt a complete derivation of an example. [[ «flEF('1'EF{P» = epEF{P)] 1\ [tJORMAl-FORM('I'EF{P» 1m (54-Z16) ~. Of more interest is the fol1owing proof that CAR is standan( in the sense of that word first introduced in section 3.

F z ) - C(S2' ([AS 1 . the second part of this can be expanded.F t ).Fl.Fl). F E FIELDS. [A<Sz.Fl' E. :a C E CONTS.Fl).E I .El.F t > · l.Ez.Fl)].F. F E FIELDS. by applying 'IE € ENVS.E.Et. F• (54-220) [A<St.F) = Eo("CAR)] J [1:(P.F z> · C(S2.El.F2)])]]) 54-212: (54-221) Now. The first step is a statement of the full significance of pairs (thitJ is S-1-38): VE E ENVS. P E PAIRS [[CAR(P.Ez.C) ~(CAR(P.F) = Eo("CAR)] J [I(P.Et.Ez.El.Ez. F E FIELDS.Aft.F».E.Ez. P € PAIRS [[CAR(P.E. F)] .C(SZ.AF 1- I{Sl.Ez.F).[A<Sz. P E PAIRS (54-219) l:(P.Ft).F t ).F).F z)] <CDR(P.E.Ft)].D I .F 1 .Ez. [AS t .E [X<Sz.F .F z) .F2)])]]) ("(EXPR Eo [X] (CAR X)).E.F 1 > • t.Fz)])]]) If we particularise tllis to a situation in which tile CAR of the pair in F is Eo{ CAR) vIe get: '1 VE € ENVS.F.Fl).C) (54-222) = [(~["(EXPR Eo [X] (CAR X))]) (CDR(P.F2> [(~Sl)(CDR(P.E 1 . F € FIELDS. D 1 .F I ) [(4S t )(CDR{P.E [(AS t )(COR(P. however. D 1 .F 1 • [A<Sz.F z)])] We can reduce this: \IE E ENVS.C(SZ.F z> .F) = Eo("CAR)] [~(P. C E CONTS.Fl.D2.F.Ez.F).Dz.Fl)]. [i\<Sz.CAR(Dz.E t .[Ot{CDR(P.E.F.C) :I ~ [([A<St. C E CONTS.CAR(Dz. that: :I Procedural Reflection 316 FORM{ RI ) [[E I Ezl A [F 1 :I Fz]] (S4-218) since all nonnal-form expressions must be side effect free.Et.E.C) = 1:( Eo{" CAR) • E.4.F.E2. P E PAIRS [[CAR(P.[A<S2.[Dl(CDR(P.F2> . C E CONTS. E2 • Fz)])]]] .[Dl(COR(P. [A(Sl.AE t " ~Fl~(St. 2-LISP: A Rationalised Dialect part.

Dz. D3.El.E.E C(HANDlE{CAR(HANOLE( [AS 1 • i\ E1 • i\ F1 - 1 (NTH(I.F. P E PAIRS [[CAR(P.F. [A<S3. f € FIELDS.F a) a.F 2 )])] <CDR(P. F E FIELDS.F).F) ~ Eo("CAR)] ~ [l:(P. Fa) . Ea . [A<S3.E.Ft. El • Ft.F.F).AF 1- (HANDLE(CAR(HANDLE.e) = [~(CDR(P.F».CAR(Dz.D2.F).AE t . CAR(02. F E FIELDS.[A(S2.S3. D Ea. FJ»»' I{St.Fl.F2> . C(Sz. 2-lISP: A Rationalised Dialect CAR Procedural Reflection 317 Now we may substitute the internalised function from 54-213: VE E fNVS. ([AS 1 _AE 1 ·AF t - [1:(5 1 . P € PAIRS (54-226) [[CAR(P.F).E2. <CDR(P.F>}.E.Sa.53 .F.E. And again: 'IE E ENVS. P € PAIRS [[CAR(P.F) = Eo{"CAR)] J [~(P.El.F.E. Fa»».Ez. C € CONTS.E 3 .F3 ) • C(HANDlE(CAR(HANDLE-l(NTH(1.C) = (54-223) ([AS1·AEt·AFI·AC. C E CONTS. C E CONTS.F2) .[A<S2.E. P E PAIRS [[CAR(P.() (54-225) = [1:(CDR(P.Fl.F z)] ([AS t . Fa»]) ]]] <CDR(P. Ez • Fz)])]]] ~(SI.El.F).F3)])]] <CDR(P.F2> .E.F .F).E2. E3. .E.E.F z)] This too can be reduced: 'IE E ENVS.F).F».F) = Eo("CAR)] [l:(P. Fa)])]]] And again: YE E ENVS. Fz> C(5 2 • CAR(Dz.F) = Eo("CAR)] ~ [~(P.C) = [~(CDR(P.F. ~ [A(S3.Ez. Ez • Fz) ] ~(Sl.D3 . Ea .F z> .F3»».Dz. D a .F. [A<Sz.[A<S2. 3. F E FIELDS. F3> t_ ([A<S2. C E CONTS. EZ.Ea. .E. (S4-224) [A<S3.1 {NTU( 1.E.4.

>] <HANDlE(CAR(HANDlE. <RI. It is exactly what we would expert. since this is essentially a null continuation.D I . F E FIELDS. ~(CDR(P. 2-lISP: A Rationalised Dialect Procedural Reflection 318 C(HANDlE(CAR{HANDLE.S a . D 3 .S a .E.E.F.F. with a particular (S4-227) In particular.Dt. a designation (03).F).[A<R 1 . The significance of the whole application will be the four-.EI.F a»». CAR(D z . tlle second part of this can be reduced: VE € ENVS.E 1 .F 3 > · 3.E.F.Dl.F.DI. = F E FIELDS.E t . <Rt.[A<Rl. P E PAIRS (54-228) [[CAR(P. 2.F 3 > • ([A<R t .El.E.E.F) = Eo("CAR)] J [~(P.E.4.F).f t >]) (54-229) = [~(CDR(P. ~(CDR(P. F3 >)])]] .F). construct a morc· particular version of continuation c: namely. we cao. the actual CAR of the result.F 2> .E 3 . since CAR is an EXPR (this is the fourth line of 54-226).F 1 > • <R t .D 3 . which will return a result (53). and a revised context (E a and F3). we get the following instance: VE E ENVS. E3 • F3 »])]] However.E2. E3 • Fa)])]]] This is as far as we can reduce without knowing about the CDR.Sa .F 2 )].F) = Eo("CAR)] ~ [I(P.E2. the continuation 54-226. P E PAIRS [[CAR(P.1 (NTH(1.F. D E2.F).tuple of the handle designating the CAR of the result.[A<S2.F t >]) [~(CDR(P.F 3 »». <HANDLE(CAR(HANDlE.[A<S2.1 (NTU(I.Ft> .F2>.f t .[A<S2.F z)]..F 2 )].F2>.F 3 »». I(CDR(P.F.F.D2.E. CAR(D 2. CAR procedure itself doesn't further modify the Two steps remain.D2.1 (NTH(1.F. [A<S3.the full computational significance of any application in terms of the CAR function will be the following: it will nonnalise the CDR of the application. the application of the context).F t > . and the context as received from the arguments (Le. [A<S3.D t .F). First. it is a good time as well to review what this says. CAR(D 2 . using We are almost done with our proof: universal instantiation.D 1 .EI.E E3 .

(In fact we have not proved the semantical type theorem.1 (S3).F»] [ 4>EF(S) = CAR(D 3 F) ]] t (54-235) :J Finally. in particular. we know that: [HANDLE-I(Sa) = 03] (S4-233) From all of these it follows that: VF € FIELDS [CAR(HANDLE. assume its truth 011 the argulnellls to CAR. F E FIELDS [Is = UANDLE(CAR(HANDLE.) because of the declarative import of handles. we can assume that 02 is in s. In addition. F E FIELDS [c)EF{S3) = 3 ] ° (54-232) and similar versions for CAR ( X• F) Sz and 02' in the appropriately scoped contexts.F») ]] n (54-230) Thus we can assume that NORMAL-FORM(S3) (54-231) and that 'IE E ENVS. since we are taking ourselves to be illustrating not a full proof but the proof of one step of an encompassing inductive proof. we know that: (54-236) simply in virtue of the fact that functions yield the same answers for the sallIe inputs. since is a partial function defined only over x in s.F» = tltEF(CDR(P. P € PAIRS tl»EF('I'EF(CDR(P.F»] 1\ [NORMAL-FORM('I'EF(CDR(P. we are allowed to assume.F)] (54-234) and therefore that VE E ENVS. since ~E F(Sa) = 02' because of the sClnantical type theorem we know that S3 is a handle.F) = CAR(03. 2-LISP: A Rationalised Dialect Procedural Reflection 319 The other component of the proof is the inductive part.1 (Sa). In addition. that 'IE E ENVS t F € FIELDS. but it would be proved in step with the normalisation theorem we are currently proving - hence it is legitimate to Finally.4. Putting all of this together we have: . we are allowed to assume that the nonnalisation theorem holds for the arguments to CAR.

combinations of the structural selectors can be combined in the usual way: designates the atom 8. it seems that works in much the way in whicl1 worked. Again in a manner exactly parallel to the numeric functions.Fl) .[A<Rt.Dl. F E FIELDS. except that it "puts on a quote mark" just before returning tile final answer.F t [A<Rz. From an informal 1-lISP point of view. that whereas in I-LISP there was SOlne question about the identity of CAR and CDR of NIL.F) = Eo("CAR)] J [~(P.Fl) = Eo("CAR)] (54-239) ~ .E. we have no suell troubles in 2-LISP. [[NORMAL-FORM(R 1 )] A [cItEF(R 1 ) 0 1 ]]]]] Discharging the use of tI» yields: (54-238) 'dE E ENVS.[A<Rl.[A<Rl.E 1 .Dz.Ez.Fl) . F E FIELDS.Dz. incidentally.::.F) = Eo("CAR)] e J PAIRS =r (54-237) [~(P.F.Dl. P € PAIRS [[CAR(P.F z) · [01 = D2]])]]])]] It is only a question of introducing the conjunction into the body of the lambda expression to yield: 'IE E ENVS. Some more examples: (CAR (COR '(A 8 e») (CAR (CAR (CAR '««A»»)» ( CAR '( ABC) ) ( CDR • (A 0 C» .EtF.E 1 . the proofs would be similar in structure.4.F) [~(P.El.F.E. (8 • C»» and nonnaliscs to the handle 2-lISP '0. • l:{R t .Dl.El. . We will not prove that any other procedures are standard.F t • [A<Rz.Ez. and so forth. (CAR (CDR '(A. 2-LISP: A Rationalised Dialect Procedural Reflection 320 YE E ENVS. F € FIELDS. since there is no NIL..F z) · [[D 1 = D ] 1\ [NORMAL-FORM(R 1 )]]])]]] 2 But this is exactly STANDARD(EO("CAR}) (54-240) Hence we are done. => => =. P [[CAR(P. [[NORMAl-FORM(R 1 )] 1\ [l:(R 1 .El. P € PAIRS [[CAR(P.-> 'A (54-241) '[B C] <TYPE-ERROR) '(A) Note.

as the following examples illustrate: . and (TYPE $F) to the handle designating rfhe expression in the fourth line returns the handle 'FUNCTION. 2-LISP: A Rationalised Dialect Procedural Reflection 321 4. as we will examine in a moment. is extensional. because its argument. thus. and the other with object identity. Examples of the behaviour of TYPE on each of ·the ten primary extensionally discriminable categ9ries are given in the following tist: (TYPE (TYPE (TYPE (TYPE 4) [1 2 3]) .b. numeral designates a number. althougll the argument in the first line of this list is a numeral. TYPE need not be called with a normal-foml designator of its argument. handle designating tile atom TRUTH-VALUE. were types of functions. Likewise. (TYPE [1 2 3]) nonnalises to the the atom SEQUENCE. called TYPE. the last six lines discriminate among TYPE. depending on tlle category of the semantic domain into which that argument falls. requiring intensional access to discriminate. however. (TYPE '4) (TYPE 'HELLO) (TYPE 'SF) (TYPE '(+ 2 3» (TYPE '[1 2 3]) (TYPE "4) => => => => => => 'NUMBER 'SEQUENCE 'TRUTH-VALUE 'FUNCTION 'NUMERAL 'ATOM 'BOOLEAN 'PAIR 'RAIL 'HANDLE TYPE (54-242) Like the arithmetic functions. the designation of (TYPE 4) is the atom NUMBER since that (TYPE 4) normalises to the handle Similarly 'NUMBER. Twelve semantic categories were listed in three of them.iiL Typing and Identity Before examining the other simple predicates over the field. which in turns designates the number that is the successor of three). the six stnlctural categories: in each case a handle designating an instance of the category is used as the argument to The last case is of particular note: the handle "4 designates the handle '4 (whicll in turn designates the numeral 4. The first is a procedure. the atom +.. that ~aps its single 54-144. it is useful to examine two special primitives. since that is the normal-form designator of the atom NUMBER.. argument onto one of ten distinguished atoms. SF) +) ~ => => ::. designates a function. one having to do with the typing of the semantic domain.4.

. no check need be made for them explicitly.4.~l(S») HANDLES] · eJse1f [5 E NUMERALS] then "NUMBER else1f [S E BOOLEANS] then "TRUTH-VALUE 01S91( [5 E PAIRS] then "FUNCTION e1581' [5 E RAILS] then "SEQUENCE)]) We can see here how the ten types emerge from the six stnlcture types: the handles designate six of them (discharged through TYPE of their referent).•PAIR =. 54-244 54-246 54-242 54-243 we need say no more to characterise fuliy. IMPRS. over functions. [AS. => => 'NUMERAL => ~ 'SF (TYPE SF» '(TYPE SF» TYPE) 'TRUTH-VALUE ' TRUTH-VALUE tOOOlEAN 'ATOM =. HANDLE(1f [S E then TYPE(HANDlF.. and MACROS.PE II (S4-245) TYPE. we first define a corresponding Dleta-linguistic function of the same name: TYP" e : CD'" S 1 AD • [If [0 € S] then If (54-244) [0 E NUMERALS] then "NUMERAL E BOOLEANS] thsn "BOOLEAN else1f [0 E ArONS] then "ATOM elEslf [0 € PAIRS] then "PAIR elself [0 E RAILS] then "RAIL 81s81) [0 eJse1f [D € HANDLES] then "HANULE 81se1f [0 E ABSTRACTIONS] then 1f [0 E INTEGERS] then "NUMBER else1f [0 E SEQUENCES] then "SEQUENCE 81581' [D E TRUTH-VALVES] then "TRUTH-VALUE 81s81f [0 € FUNCTIONS] then "FUNC~10N It is then straightforward to define the significance of TYPE within the language. ~ 'FUNCTION In order to characterise the primitive semantics of TYPE. it is natural to designators.. a cotnment worth making about the use of We have sorted procedures into three categories: EXPRS. since it is an extensional procedure: SIMPLE ( " T'. TYPE There is. From and . and four of the other five categories designate the other four semantical types.til of the behaviour in TYPE Since atoms are not nonnal-form and follows directly. . 2-lISP: A Rationalised Dialect (TYPE (TYPE (TYPE (TYPE (TYPE (TYPE (TYPE (TYPE (TYPE (+ 7 (I 3 4») ~ Procedural Reflection 'NUMBER 'NUMBER 322 (54-243) (NTH 1 [6 '6]» (Nl'H 2 [6 '6]» (= 1 1» SF) ::. however.

require intensional access to the arguments. as an argument in chapter 3 showed us. and among the various kinds of abstractions. Thus. Furthcnnore. and MACRO.structural capabilities of definable procedure to engender just such behaviour. in the latter dialect. the difference between and IMPRS cannot be decided in virtue of designation alone. rather than the undifferentiating atom FUNCTION. is not easily open to us. EXPRS 111US 3-lISP. since. it might seem that we would prefer the following behaviour: (TYPE +) (TYPE LAMBDA) (TYPE LET) ~ 'EXPR (54-246) => 'IMPR 'MACRO => instead of what we have currently defined: (TYPE +) (TYPE LAMBDA) (TYPE LET) ~ 'FUNCTION (S4-247) ~ 'FUNCTION ' FUNCT I )N TYPE ==> This would seem particularly indicated since we have chosen to have rather than simply designating the atoms S-EX~RESSION discriminate among the various kinds of s-exprcssions. This option. There is another reason for this. 2-LISP: A Rationalised Dialect Procedural Reflection 323 wonder wl1cther a better definition of TYPE might be definecL to return one of the three atoms EXPR. categorisations made by however. where tile TYPE procedure will retain its TYPE present definition. IMPR.4. since the mcta. we can define a procedure called PROCEDURE . to modify it in a generally extensible fashion so as to discriminate among user procedures. or ABSTRACTION. there is no need to have the prilnitivc typing predicate make such a discrimination. TYPE.TYPE as follows: (54-248) (DEFINE PROCEDURE-TYPE (LAMBDA EXPR [PROCEDURE] (SELECT (CAR PROCEDURE) [tEXPR tEXPR] [tIMPR 'IMPR] [tMACRO 'MACRO] [S1 (ERROR "Argument was not a closure")]») . it is therefore far more consistent to leave the definition as it is. such a EXPRS TYPE would have to be an None of the other intensional procedure. which is less than elegant for a primitive procedure. however. 2-lISP allow a user- In particular. it will be possible for the user to define procedure types otlter than those in order to accommodate an intensional that sorted among and IMPRS we would have. on this view. In provided primitively..

4. IMPR.that performs reduced with function designator designators. tLET) 'EXPR 'IMPR 'MACRO (54-260) We \vill from time to time aSSUlnc this definition in subsequent examples. Note in 54-248 that difference is that PROCEDURE-TYPE is an extensional function. Before leaving the discussion of category membership. Similarly. therefore. 2-LISptS :=l distinction. 2-LISP: ARationalised Dialect Procedural Reflection 324 This examines the closure in the function position of the closure to which a function designator nonnaliscs (the EXPR. in other words. For example. (CAR PROCEDURE). the atom + (in the initial environnlcnt) will normalisc. in true just in case its two arguments arc the same. not like I-LISP'S [QUAL (we . we will define ten useful utility predicates for use in later examples: (DEFINE (DEFINE (IJEFINE (DEFINE (DEFINE (DEFINE ATOM RAIL PAIR NUMERAL UANDLE BOOLEAN (LAMBDA (LAMDOA (LAMBDA (LAMBDA (LAMBDA (LAMBDA EXPR EXPR EXPR EXPR EXPR EXPR [Xl [Xl [Xl [X] [Xl [Xl (= (= (= (= (= (= (TYPE (TYPE (TYPE (TYPE (TYPE (TYPE X) X) X) X) X) X) 'ATOM») 'RAIL») 'PAIR») 'NUMERAL») 'HANDLE») 'DOOlEAt~) (54-261) )) (DEFINE NUMDER (LAMBDA EXPR [X] (= (TYPE X) 'NUMBER))) (DEFINE SEQUENCE (LAMBDA EXPR [X] (= (TYPE X) 'SEQUENCE») (DEFINE TRUTH-VALUE (LAMBDA EXPR [Xl (= (TYPE X) 'TRUTH-VALUE») (DEFINE FUrJCTION (LAMBDA EXPR [Xl (= (TYPE X) 'FUNCTION») explicitly~ Predications in tcnl1S of PROCEDURE-TYPE we will do ~fhc procedures TYPE and PROCEDURE-TYPE deal with the call'gory identity of their is arguments. will designate the <EXPR) closure. it is tllcreforc like I-LISP'S EQ. would generate the following behaviour: (PROCEDURE-TYPE t+) (PROCEDURE-TYPE tLAMBDA) (PROCEDURE . and so forth. and MACRO selectors in the SELECT statement. is called "=" - defined over individual identity. It is tIle magic of shifting up one level. Definition 54-248. in other words. to the closure «EXPR) ~ [X Y] (+ x V»~ (S4-249) Pinus in the reduction of the expression (PROCEDURE-TYPE t+) the term PROCEDURE will desigllate the closure just described. The prirnitive function that deals nlost directly with individual identity. (CAR tLAMBDA) would designate <IMPR>. as is TYPE: the NAME - PROCEDURE-TYPE cannot be reduced with function designators: it must be the up"arrow . designate closures). as we have already mentioned.TYPE.

? ? 7 .5 t . however: the prcdiCc:1tc given in SIMPLE 54-263 51 and 52 arc as tile third argument to EQUI-OESIGNATING.. =0 SF ST It might seem that .functions 'being the .1 2) (. examples (we have already seen some of these in section 4. we can lise equality predicates with relative impunity.. characterised by the following formula: (54-263) We assume we can use Eo and Fo immaterially in this equation. f then "$f [s 1 "$TJll € PAIRS] ... Suppose. but there are of course many cases .99 98» (. is not computable. in partic'Jlar.( 52)] A [ Vi 1:5 i ~LENGTH( 51) [EQUI-DESIGNATING(NTft(1. • is an extensional function. f [[ TVPE( 5 1) = TYPE( S2)] A [ 1f [SI E [HANDLES U BOOLEANS U NUMERALS 1] then [51 = 52] else1f [51 E RAILS] then [[ lENGTJI( 51) = lENGT.a): (a 1 1) (.. they designate functions). since guaranteed to be context independent designators. in With this predicate. we encounter our first troubles with tile tractability of our definitions. There is a problem. In our mathclnatical meta-language. ]] else "$F The difficulty is that we do not have anything to put in case other words.4. z::o.S2.F). 325 Some discuss type-identity in 2-LISP below). would be rather stragithforward. from a seman tical point of view.. NTH(1."'2 "'2) ~ ST ST SF SF ST (54-262) . that we call it and SF attempt to construct an algorithmic and syntactic definition (the intent is to define a constructive procedure defined over s-expressions that yields the boolean constants ST or depending on whether its two normal-form arguments designate the same entity). =0 J:OI . We would be led to something like the following: EQUI-DESIGNATING : == ASt·AS z • CC S X s 1 -+ BOOLEANS J (54-264) ..1 (. 2-LISP: A Rationalised Dialect Procedural Reflection Like TYPE.1 '1) (a [ST Sf] [ST SF]) (a '[ST SF] 'CST SF]) (..F» e 1se . 51 and 52 arc pairs (when... in other words.

whether or not this can be decided by algorithmic means. it follows from what we said above that equality is in fact defined in those cases. and functions.where the identity of two objects is not a decidable question. llte LISP equality predicate. Over sequences there is no guarantee of its being well-defined. Equality is decidable (and • is therefore defined) over all sexpressions. The difficulty with sequences has to do with the fact that the identity of a 2- sequence is a function of the identity of tile elements: equality (at least for finite sequences) can be decided just in case equality of the corresponding members can be decided.. We have our semantic domain divided into three main types of object: s-exprcssions. or we could say tJlat it designates a truth-value just in case the arguments are the sante. (:I TYPE +) (=. Thus we arc led to the following (54-266) A<Nt.~. However. 1f [[ C)EoFo(N 1 ) E FUNCTIONS] V [ ~EoFo(Nz) E FUNCTIONS]] els8 [T-l(~EoFo(Nl) = lIJEoFo(N z then <ERROR> »]» Froln the fact that = is not defined over functions it should not be concluded that it is not defined over nonnal-forln julletioll designators (closures). and over numbers and truth-values and some sequences.4. and not over functions. and there can be no doubt that temlS of the form characterisation: SIMPlE(". abstractions. but not over functions (it will produce an error. on the contrary. therefore. as shown below). but that the procedural consequence is simply partial compared with the declarative import.'TYPE '+) (:I ['TYPE '+] ['TYPE '+]) (a ['+ 'TYPE] ['TYPE '+]) (= [TYPE +] [TYPE +]) Some examples: <ERROR> SF (54-266) ST SF <ERROR> We have a choice in deciding how to characterise the semantics of = in light of these tractability problems. since these latter are s-cxprcssions.N z> . 2-LISi': ARationalised Dialect Procedural Reflection 326 paradigmatic example . the identity of function designators is much finer grained than of the functions they designate. (:or X Y) designate truth just in case x and Yare co-designative. In . as discussed in the preceding section. is defined over all s-cxpressions and all abstractions. because our metllodological stance is to reconstruct scmantical attribution. It is the latter approach we will adopt. We could say that :I designates a truth-value just in case its arguments are of a certain form. and therefore equality of function designator cannot be llsed as a substitute for equality of function.

2-LISP: A Rationalised Dialect Procedural Reflection 327 such a case the type-identity of a function designator becomes relevant (in tlte sense in which we defined a type-identity for I-lISP lists in chapter 3).4. Thus for example . nonetheless type identity on function designators is still a finer grained metric than identity of function designated.. The idea . since type-identity is a coarser grained metric than strict identity. and is undefined otherwise. booleans. and that pairs and raits are type-identical just in case their elements (where the CAR and CDR will in this context be taken as elements of a pairl are recursively typc-identical. atoms.similar to the definition of EQUAL in I-LISP . and handles are type-identical only with themselves.will be to say that numerals.. The form as a whole designates the sequence of entities designated by the sequence of applications thus generated. truth if all designate truth. We have natl!rally extended its domain to include not only s-exprcssions but also numbers. (TAIL 1 [:F MAP ST]» :::. ~Ibus for example we have (AND $T ST $F) (AND (= '[] '[]» (AND) => :::. In order to illustrate this last point. stepping down them.. truth-values. and those sequences over whose elements it is defined (we assume in this and other examples that (NTH 1 X» 1ST is (LAMBDA EXPR [Xl and that REST is (LAMBDA EXPR [Xl (TAIL 1 X»): (DEFINE TYPE-EQUAL (54-267) (LAMBDA EXPR [A B] (COND [(NOT (= (TYPE A) (TYPE B» SF] [(= (TYPE A) 'FUNCTION) (ERROR "only defined over s-expression & abstractions")] [(= A 8) ST] [(MEMBER (TYPE A) '[NUMERAL ATOM BOOLEAN HANDLE]) SF] [(= (TYPE A) 'PAIR) (AND (TYPE-EQUAL (CAR A) (CAR B» (TYPE-EQUAL (COR A) (CDR B»)] [(MEMBER (TYPE A) '[RAIL SEQUENCE]) (AND (= (LENGTfI A) (LENGTU 8» (AND. that it applies successively to the elements of as many other arguments as it has. AND is a procedure defined over a sequence of any nunlber of arguments: it designates falsity just in case one or more of tllose arguments designates falsity. An appropriate definition is given below. suppose we define a type equality predicate called TYPE-EQUAL. (MAP TYPE-EQUAL A 8»)]») The penultimate line requires some explanation. SF SF ST ST (54-268) is a function that takes as its first argument a function. => $T (AND.

as the following examples illustrate: (TYPE-EQUAL TYPE TYPE) (TYPE-EQUAL tTYPE ~TYPE) (TYPE-EQUAL t(LAMBDA EXPR [Xl (+ x 1» t(LAMBDA EXPR [X] (+ XI») => TYPE-EQUAL overcolnes this particular <ERROR> $1 $T (54-262) => ~ However even TYPE-EQUAL counts as differellt function designators that not only provably designate tt!e same function.4. was to look at the type-equivalence of function designators.. 2-LISP: A Rationalised Dialect (MAP (LAMBDA ElPR [X] (+ XI» [10 20 30]) Procedural Reflection 328 (54-269) [11 21 31] [3 6 7] (MAP + [1 ~ 3] [2 3 4]) Thus the expression (AND • (MAP TYPE-EQUAL A B» will first generate a sequence of 8. (TYPE-EQUAL (TYPE-EQUAL (TYPE-EQUAL (TYPE-EQUAL (TYPE-EQUAL (TYPE-EQUAL 1 1) 1 2) ST SF TYPE-EQUAL: (54-260) [ST SF] [$T SF]) '[ST SF] '[ST SF]) "[ST SF] "[ST SF]) '(CAR X) '(CAR X» ST Sf SF Sf The reat reason we constructed TYPE-EQUAL. it is too fine-grained to count as equivalent even two function designators that have identical spelling. (54-263) => SF tllCSC as we have several times mentioned. limitation. but that on any reasonable theory of intension ought to be counted as intellsionally indistinguishable as well: (TYPE-EQUAL t(LAMBDA EXPR [V] (+ Y 1» ?(LAMBDA EXPR [X] (+ XI») 11tUS.TYPE tTYPE) (= t(LAMBDA EXPR [X] (+ XI» "(LAMBDA EXPR [X] (+ X 1») => => ST SF <ERROR> (54-261) As the last example shows. we will not in dialects be able to provide either extensional or intensional function identity predicates. booleans depending on the type-identity of the elements of A and will be true just in case all the elements are type-identical. however. the whole expression We can first illustrate some straighforward uses of . it is defined over function designators: (= TYPE TYPE) (= . . Note first that although simple equality is not defined over functions. however.

the present case is one in which we have a well-defined algorithm that has the property that it will run forever.4. In ruling functions out of the source domain for the procedural version of • we were excluding arguments for which we have no algorithm at all. however. then (TYPE-EQUAL x Y) will never terminate. \Vhat done and what we will not do in this investigation - have not is to make explicit those conditions under which procedural consequence will engender infinite computations. since LISP is fundamentally oriented towards tree-structured objects. 2-LISP: A Rationalised Dialect Procedural Reflection 329 It will have been clear to the reader that there is another computational problem that we have consistently ignored: that of non-terminating programs. 1be contribution of 2-LISP is more in the realm of what programs mean than in whether they terminate. A more adequate semantics might map non-terminating expressions onto 1. This may be an area of legitimate study. but it would not be in the spirit of to focus on such issucs. "Thus the distinction between non\VC tenninating and semantic ill-formedness is maintained in our account. In constructing meta- theoretic predicates we have attempted to fannulate them in ways that are well-behaved in the case of infinite structures. we have mapped (= + +) onto <ERROR>. For example. which is different. will be made to define computable predicates guaranteed to work correctly on circular structures (in LISP tllC sense defined in chapter 2).. if x is a rail such that it is its own first element. no attempt. .

we will assume the same is true for TAIL. Furthermore. which arc the set of all possible rail versions of the two primitive relationships maintained in a field: . Before laying out careful characterisations. D)] ) ) => ~ Ie $T '[] (LET [[X '[NEVER MORE]]] (= X (TAIL 0 X») (LENGTH []) (LENGTH [1 2 3 [4 6]]) (LENGTH '[1 'I]) (LET [[X '[QUOTH THE RAVEN]]] (NTH (LENGTH X) X» "r'--' ~ ~ o 4 => ~ 2 'RAVEN In order to set out the relevant semantics.b. some examples of "the behaviour we will be characterising will be illustrative: (NTH 3 [1 2 (NTH 3 '[10 (NTH 3 ['10 (NTH 1 (CDR (TAIL 0 []) (TAIL 0 '[A (TAIL 3 '[A (TAIL 6 '[A 3]) 20 30]) '20 '30]) '(FUN ARGI ARG2») ~ ~ ~ 3 '30 '30 'ARGt (54-267) ~ ~ ( CAR • ( TAl L 1 [' ( A • B) '( c CASTLE OF PURE DIAMOND]) CASTLE OF PURE DIAMOND]) CASTLE OF PURE DIAMOND]) ~ ~ ~ [] '[A CASTLE OF PURE DIAMOND] '[PURE DIAMOND] . and First we define FIRSTS and RESTS. we assumed that our meta-linguistic LENGTH were defined 'over abstract sequences as well as over 2-LISP rails. however. however.iv. When we introduced tails. It should be recognised. NTH. Selectors on Rails and Sequences In 54-62. we were forced to modify our defInitions of these two functions to take explicit field arguments. we will again expand their domains to include both sequences and functions and rails. and recognised the mutability of rails in both element and tail position. for completeness and convenience. 2-lISP: A Rationalised Dialect Procedural Reflection 330 4. NTH when we first introduced rails. As we now tum to the use of these functions within 2-lISP.4. REST. FIRST. it is convenient to define a notion of vector to subsume both rails and sequences: VECTORS == C RAILS U SEQUENCES 1 (54-268) We can then introduce new versions of the meta-theoretic functions lENGTfI. The resultant equations in S4-96 and S4-96 dropped abstract sequences from the domain of the two functions. in that (TAIL N SEQ) will designate the sequence consisting of the Nth through last clements of the ~equencc SEQ. that the identity and mutability conditions on syntactic rails and on mathematical sequences are radically distinct.

AF • 1f [V E RAllS] thsn F4 .1] A [R EST ( R) = 1.L] then .F) = .L} 11 (54-273) eJse1f [.L} 11 (54-271) Av..F) = s. we would like: . U3S.V) .....AF • If [V E RAILS] then F3(V) else Vi REST 51 (S4-270) : CC VECTORS X FlfLDS 1 ..F) :I 1.L] then [1 + lENGTH(REST(V. Except for the binding of the field argument. •yt) where k • LENGTH(V) : NTH a CC AI. n (S4-276) Finally. D 1 a AV.F»] else 00· We need in addition the following constraint saying that rails have firsts and rests together ..V.elcctors overs rails and sequences can then be defined in the saIne way in which CAR and CllR were defined..AF ..3N [NTH(N. if [I INTEGERS X VECTORS X FIELDS 1 -+ 0 1 a 1] then FIRST(V. F E FIELDS [ 1 f Q = <) the n [[ FIRS T( Q.AV.F) (54-272) LENGTH: == AV.AF . F E FIELDS E S [FIRST(R. e J se <Y •V3.AF X VECTORS X FIELDS C VECTORS U { J. F) = J. the prinlitivc'.demonstrably true of Fo and provably true of all fields constructable in virtue of the form of the primitive operations: VR E RAllS.F) II .F)] Given these new definitions. Ie VECTORS x FIELDS J -+ if [FIRST(V.L else [TAIl(I-l.F) = [[ FIRST ( R) = ..REST(V).L} 11 C RAILS U {J. m 1 srl]l v (54-274) The corresponding constraint on sequences is provable: \fQ E SEQUENCES.. C VECTORS U {. € RAILS [REST(R.. F) = -l A [RE51 ( Q.REST(R).F) else NTH(I-l. Ok>] .4.. -to C s u {.] then 0 C INTEGERS U {. Ok> ]] wher'e Q = <Ql Qz 03 .} (54-269) ]] We can then set out four defmitions: FIRST : CC VECTORS X FIELDS 1 .} J1 (54-216) == • if [I = 0] then V else1f [REST(R.AV. 2-LISP: A Rationalised Dialect EI EI Procedural Reflection 331 FIRSTS RESTS C VECTORS C VECTORS . we can define a meta-theoretic TAIL : TAIL function: J -+ CC INTEGERS ~I.. elS8 [[ FIRST(Q) = 0 1 ] A [REST(Q) = <Q2 03 ..]] A [3S . ..

. 1f [X E RAllS] then LENGTH(X. such as [1 2 3]. tile fonn .Dz.FZ).02.F)] [A<N.F)] [A<N.Fz». [A<SI. that fact that TAIL 1138 to do with the is defined over both rails and sequences. there is a question about the relationship between the syntactic identity of the result that is returned in tenns of the identity of the argument In particular.AF.F z).F 2 ) • [ i f [NTH(2.Sz.F)]) Thus instead we have to posit the following (we give the equation only for theory.1 (lENGTH(HANDLE. TAIL(N.F) else HANDLE(NTH(M(N). F1) • E. In addition.D2. if [X e RAILS] then NTH(M(N).D z . ~(Eo("NTH» NTH.F z)] else [C(HANDlE(TAIl(NTH(1.HANDlE. Ez.F 2 ).F»]) SIMPLE(" LENGTH. The problem.F) else M.F 2 )])]. E2 . is that even if the arguments designate a sequence. (54-281) [A<Sz.D z.El.X) .HANDLE.F 2 )]]]) There is some subtlety in this equation that should be explained. NTH(N.F 2 ). (54-277) (54-278) [A<N.F) else HANDLE(TAIl(M(N).F2).NTH(2.1(X). Note as usual how the field. tacit in the language itself: is explicit in the meta- = [AE. fonn rail. if [X E RAILS] then TAIl(M(N).[A<S2.F 2 } E RAILS] then [C(TAIl(NTH(1.F»]) SIMPLE("TAIl. in brief.4. El.X.D2 . if the argument in a reduction is a nonnal.D 2 .NTH(2.1 (X). (54-280) C("(EXPR Eo eN V] (NTH N V)).D 2 .X.AC .X) . we need the intemalisations of the three primitive closures.F).X) .NTH(2. 2-LISP: A Rationalised Dialect Procedural Reflection 332 SIMPLE("NTH.1 (X) . (54-279) [AX . F)] ~(Sl. Ft.X) . E1 .E z .X.F2> · NTH(NTH(1. [A<N. the others are similar).Fl.F)] [AX . NTH(N.X.E2.X. this time we take TAIL as our example: A[EO("TAIL)] = ASI·AE1·AFt·AC • :E(Sl.F 2 )..

as we noted. Thus we would have (these will be better explained after described in section 4. which are what the original arguments designated. and the third is the current field Thus the application in tenns of the mcta.02.b. four.iii: the referellt of applications formed in terms of it is a function purely of the designation of the arguments. predicate in the will be true. In terms of re3u/t. 2-LISP: A Rationalised Dialect (TAIL [1 2 3]) Procedural Reflection 333 will return as its result the aClualfirst tail o/its argument. if we had (fAIL (+ 0 1) [3 4 6]) (54-282) then the result of normalising the args would be a fail consisting of the integer 1 and the rail [3 4 6]. is strictly extensional in tile sense we defined that tenn in 3. rather than some different two-element rail [2 3] that designates the tail of the sequence designated by the original argument NTH and TAIL.S2.F 2 ). not 02' is used. theoretic function will yield the tail [4 6]. there is a strict dependence of the result on the fonn of the argument: the actual tail of the nonnal.F 2 ).1 or HANDLE needs to be used to preserve semantic level. This is expected. not shnply a co" designative tail. which will be returned. form version of the argument will be returned. no function like M. and the "then" clause will be relevant The continuation is thus applied to the result of applying the meta-theoretic function (because the second is TAIL TAIL to three arguments: the first is the number J in our NTH(l.F z example (because the flfSt argument is NTH(2. The consequence is that the primitive TAIL procedure.c. given an application of the fonn has its standard binding. returning a rail consisting of nonnal-fonn designators of the index and the vector. have aspects of their procedural consequence above and beyond that implied by their declarative import The conditional in 54-281 makes this behaviour clear. Thus the.vii. because this rail will designate the sequence consisting of the condition~l number one and the sequence of the numbers three. which might have been expected). in other words.4. assuming that TAIL will be normalised. the second is the rail [3 4 61 not NTH(2..D z . F2' ». and five. however. the arguments to TAIL (TAIL <K) <V».. Because s~. but the intent will be clear): ) (SET X [2 (+ 1 J) (+ 1 1 1)]) > [1 2 3] > (SET Y (TAIL 2 X)) > [3] (54-283) RPlACT has been ) (RPLACT 1 tY '[4 6]) > [4 6] >y as expected extend Y a little . In particular. For example.

6J ) X ) [1 2 3 4 5] It turns out that this behaviour has its very useful aspects. LAST. . the situation is much simpler.. 54-281 ~ the "else" part of the conditional in makes evident Before leaving the subject of vector selectors. (54-287) (54-288) and EMPTY are self explanatory. that we will assume in later examples: (DEFINE 1ST (LAMBDA EXPR [VECTOR] (NTH 1 VECTOR» (DEFINE LAST (LAMBDA EXPR [VECTOR] (NTH (LENGTH VECTOR) VECTOR» (DEFINE REST (LAMBDA EXPR [VECTOR] (TAIL 1 VECTOR» (54-284) (54-285) (54-286) (DEfINE EMPTY (LAMBDA EXPR [VECTOR] (= (LENGTH VECTOR) O)} (DEFINE FOOT (LAMBDA EXPR [VECTOR] (TAIL (LENGTH VECTOR) VECTOR» FIRST. 2-LISP: A Rationalised Dialect Procedural Reflection Y of course has been modified X has been modified as well 334 ) [3 . and the identity considerations more straighforward. Further examples of the interactions of side-effects and general vectors will be investigated in section 4. our present concern is merely to illustrate how it is entailed by semantical equation 54-281. 4. REST. intended to be used FOOT will be illustrated in section primarily over rails.vii.4.b. Fooi is a procedure.b. we will define a variety of useful procedures in terms of the three primitives.vii. that returns the particular empty rail at the end of a rail. In the case where TAIL (or NTH) is applied to a rait. This is useful since RPLACT of the foot of a rail will extend a rail.

in that their proceJural +. 2-LISP: A Rationalised Dialect Procedural Reflection 335 4. v. which creates pairs just as in 1- Infonnally. I. RCONS. -. TYPE." The new pair is designated by the whole application. takes an arbitrary . . on the other hand. the basic structure creation mechanisms were two: the use of parentheses in the lexical notation. of the second. which creates rails. and calls to the CONS function. and whose CDR is the structural field element designated by the second. Because 2-tISP has both rails and pairs. RPlACD. RPLACN. and ReONS. in that their procedural consequence involved a preservation of syntactic identity of arguments above and beyond that mandated by declarative import and nonnalisation requirements. RPlACA. were what we will call proc(. There are in addition two procedures that generate new structure: LISP. and RPLACT. consequence was simply a consequence of their declarative import coupled with the nonnalisation mandate. SCONS and PREP. CD~. and one having to do with the modification of the mutable relationships in the field. In I-LISP. Some examples: (54-291) 'A '0) . aDd designates a new rail whose elements are the referents of its RCONS is not unlike the I-LISP LIST. ReONS.4.~ peONS. Two others NTH and TAIL - were slightly more involved. None of these.b. We will look at each class in tum. The Creation o/New Structure Most of the primitive procedures we have introduced and LENGTH - II.+ '[2 3]) '(A. therefore a handle designating the new pair will be returned as the result argumentst (peONS (peONS (RCONS (peONS (RCONS) number of arguments. there are two notations that create structure: parentheses and brackets. 8) '(+ 2 3) 'NOW 'IS 'THE 'TIME) 'NAME (RCONS 'X'V» '[NOW IS THE TIME] '(NAME X Y) '[] (peONS) <ERROR) .. have involved any side effects or creation of new structure. Members of the frrst class include peONS. however. peONS is rather like 1-LISP'S CONS: it is a function of two arguments that engenders the creation of a new pair whose CAR is the structural field element designated by the first argument. . CAR. There are two additional classes of structural primitives to be introduced: one having to do with the creation of (or access to) structure otherwise inaccessible.dural1y simple.

CAR terms the designation of an otherwise inaccessible pair. manifesting .Et. facilitating the use of an indeterminate number of them.[A(S2.f 2 ) [NTH(i.E 1 .AF. since it is here where the side-effects arc manifested: ~[EO(RPCONS)] (54-293) = ASt·AE1·AF1·AC • ~(Sl. rather than a rail of atoms. P])] F)] where [[P E PAIRS] A [CAR(P. section 4.4. 2-lISP: A Rationalised Dialect 2-lISP peONS is Procedural Reflection as in I-LISP.AC .[A<Sz.' ( 2 • Sz• F2 » e 1se [[ F• ( p ') = Fz1 ( P . in 336 of The mathematically described. C(HANDLE(P).Et.Fc:.AF.E z .F l »] A [ Fd ( P t) = HANDLE-1 ( NT.Fl.Dz.F 1 ) E.D2tE2.F 3 )]) where [( P E PAIRS] A [fa = <F a .S z .4.) = F2Z( P f D ) ])]]) Similc:rly. ARGS)J.F2) .[A(S2tD2tE2.Ft.F z) = 0 22 ]] Of more interest is the internatisatioD.F t > • ~(Sl.F z) = O2 '] A [COR(P.(P') = HANDLE. The foHowing equation expresses the intcrnalisation of tile the structure creation: nCONS closure. )] A [F d ( P .El.c. C("(EXPR Eo ARGS (R .F.AC .1 (NTH(1. sign i tiC&. F)] where R E RAILS] A [Vi lSiSLENGTtI(D z .E 1 .F z) U = O2 ']]] RCONS Of note in this characterisation is the fact that in the primitive closure the list of tllus fannal parameters is a single atom ARGS ARGS. we have the following account (54-292) [AE.Ft.ce: ~(EO(RPCONS» :z More formally. [A(St. As a consequence This practice is explained in will be bound to the arguments as a whole. with the and COR relationships of the field F"irst the full moaified appropriately.E2. Fz&)] A [INACCESSIBLE(P. • B1 (peONS A 8)).F2> . ~(Sl. R])] E. rather than to them one by one.E2tF~)] A [ Vp t E PAIRS [ l' [p' = r] then [[ F. FZ3 .F2) . C("(EXPR Eo fA [A(Sl.R. we have the following significance for 1:( foe" RCONS) ) = RCONS: (S4-294) [AE.

F) in the internalised function. defined below.y of consequences that stem from them.Fa)]) <fzt. peONS and RCONS return new served as A striking difference between I-LISP has to do v/ith "empty" enumerators.endent on the procedural treatment. In tllis sense the "declarative" meaning is dp. First. and REST were defined above.Fz2. being an atom.a F24 ( R' ) n Un] Though these equations completely two procedures. all rails can be extended using (to be defined below).t (NTH«1+1).E 2 . there are rather a wide charact~rise the designation and import of these - vari~.L] A [ F r( R') • J.Ez. C(HANDLE(R o). the crocial fact about these two flavours of CONS the first syllable of "constfJ':Ct" is part of their name ditTerent s"expressi~il is that on each nonnalisation a is designated. FIRST.( R') • .4.Fr.F z »] A [Fr(R') II Rt+tll eIsel' (R' • Rt J then F.S2.. . E.F2) . This is the weight borne by the tenn INACCESSIBlr::. it could not be extended.F2) [3Rt E RAILS [INACCESSIBLE(Rt. as the example in Since in 2-lISP 54-61 made clear.]] e 1se [[ Fr( R') • F23 ( R' )] A [f r( R') .Fr.F2)ID A [v~' € RAILS [ 1f [31 0 S is[ LENGTH ( 02 • F2 ) -1] [R' • Rt ]) then [[Fr(R ' ) • HANDlE.Ez. In RPlACT the atom NIL the null list. which this is why should be illustrated. Consider for example the following program to reverse a list: (54-296) (DEFiNE REVERSE (LAMBDA EXPR (L) (REVERSE. This is a different kind of dependence than procedure£ (like PRINT) that have procedural consequence above and beyond tlleir declarative import (applications in tcnns of PRINT always designate The reason we are concerned about the fact that calls to s-cxpressions is of course in case of subsequent 2-LISP and I-lISP side-e~ects.D2. l~ruth). It. 2-lISP would be tIle following program defined for rails PREP. These are I-LISP (LAMBDA EXPR {OLD NEW) (IF (NULL OLD) NEW (REVERSE· (CDR OLD) (CONS (CAR OLD) NEW»») (54-297) A simple-minded translation into (EMPTY.'cturns a new rail whose . 2-LISP: A Rationalised Dialect Procedural Reflection 337 A[Eo("RCONS)] • AS1·AE1·AFt·AC • where [[F 3 II (S4-296) ~(Sl.Fz6)] A [Vi OS1~LENGTH(D2.L NIL») (DEFINE REVERSE.Fla[A<S2.El. it is clear that I-LISP one cannot in general use a constant as the starting clement when building up an enumeration.

but the rail within the procedure is changed as well.can remain as is.l '[WITH A NEW TAIL]») (54-301) A corrected version of 54-298 is the following: (54-302) (DEFINE REVERSE (LAMBDA EXPR [l] (REVERSE· l (RCONS»» The definition of REVERSE. and thus any modification of If the this empty rail will affect every reversed rail. as expected > '[THE SECOND IS DIFFERENT] . In fact.l '[l») (DEFINE RE·~ERSE· (54-298) (54-299) (LAMBDA EXPR [OLD NEN] (IF (EMPTY OLD) NEW (REVERSE.4. body of REVERSE were printed out following the console session just illustrated. 8S expected ) '[THIS IS THE FIRST EXAMPLE WITH A NEW TAIL] ) Y Y is changed as wel11 ) '[THE SECOND IS DIFFERENT WITH A NEW TAIL] The problem is that the very same mutable empty rail designated by '[] in the first tine of 54-298 is used as the foot of every rail returned by REVERSE. as the following session demonstrates: ) (SET X (REVERSE '[EXAMPLE FIRST THE IS THIS])) (54-300) ) '[THIS IS THE FIRST EXAMPlE] ) (SET Y (REVERSE '[DIFFERENT IS SECOND THEJ)) > '[THE SECOND IS DIFFERENT] ) (RPLACT 6 X '[WITH A NEW TAll]) ) t[WITH A NEW TAIL] ) X X is changed.(REST OLD) (PREP (FIRST OLD) NEW»») This definition of REVERSE. not only is every other tail produced by this procedure affected. has a bug. 2-LISP: A Rationalised Dialect Procedural Reflection 338 first element is the first argument and whose lint tail is the second): (DEFINE REVERSE (LAMBDA EXPR [ll (REVERSE. With the new definition we would have: > (SET X (REVERSE '[EXAMPLE FIRST THE IS THIS])) ) '[THIS IS THE FIRST EXAMPLE] > (SET Y (REVERSE '[DIFFeRENT IS SECOND THE])) ) '[THE SECOND IS DIFFERENT] ) (RPLACT 6 X '[WITH A NEW TAIL]) ) '[WITH A NEW TAIL] ) X ) '[THIS IS THE FIRST EXAMPLE WITH A NEW TAIL] ) Y (54-303) X is changed. the definition would look as follows: (DEFINE REVERSE (LAMBDA EXPR [l] (REVERSE. as expected Y is unchanged. however.

of course. The moral is simple: the rationalisation of side effects to work on empty as well as non-empty rails implies that quoted empty rails should be used with caution. the facilities demonstrated do not enable us to construct a rait consisting of the numerals designating the . versus the creation of pairs implied by occurences of the procedure peONS. but the handle that this notation notates forever designates the same empty rail. the string u(RCONS)" notates a pair. (I. in other words.. the difference between '[] and brings out the difference between structure constnlction by the reader and stnlcture construction by the processor. The point is that the notation'" []" causes a new inaccessible rail to be selected by the reader. in I-LISP I-lISP'S CONS and 2-LISP'S RCONS and peONS has to do In with the inherent typing of the results from 2-lISP'S semantical characterisation. in (peONS 1 2) (RCONS 2-lISP => => all of the following generate type errors: <TYPE-ERROR> <TYPE-ERROR> (54-306) ST SF) In both cases the functions in question are extensional functions defined over s-cxprcssions. each normalisation of which designates a different empty rail. The difference is exactly the same as tllat between the . entities.4.construct~on of pairs implied by parentheses and dots. however - for example. 2) 'CST SF] (54-307) ll1ere is more to be said on this subject. we have such well-fonned evaluations as: -+ (CONS 1 2) (CONS T NIL) . 2) (T) : This is I-LISP (54-306) On the other hand. is potentially quite different from l-lISp·S '(). that there is a single empty rail designated by '[]. 2-LISP'S '[].. 2-LISP: A Rationalised Dialect Procedural Reflection 339 This is as it should be. as the following demonstrates: (:I '[] '[]) =:. rather than structural. On the other hand.» $f (RCONS) (54-304) Rather. and should therefore be given s-expression designators as argumcnts_ All four arguments in the two examples in 54-306 designate abstract. Of course the following arc well-behaved: (peONS '1 '2 ) => ::> (RCONS 'ST 'SF) '(1. Another different between particular. It should not be concluded. expressions of the fonn (RCONS) are by and large safer.

such as the 54-299 REVERSE example of that we make it a primitive part of 2-LISP. \vhcre the basic reflective powers enable one to define non-primitively a variety of procedures one would expect to find as primitive (including SET and LAMBDA). given our separation of pairs and rails. its functionality so very useful . It is possible to define PREP as rauov/s: (DfF IfJE PREP (54-3il) (LAMBDA EXPR [FIRST REST] (LET [[NEW (RCONS fIRST)]] (BLOCK (RPLACT 1 NEW REST) NEW}» ) This definition. in other words. The correct solution. however.particularly because of its natural use in recursive functions that build up structure. is ugly: it awkwardly uses a side-effect in order to provide a very simple behaviour. In addition. It has already been tacitly implied that our 2-LISP definition is not strictly minimal. since the following yields another type error: (LET [[X 3] [Y 4]] (RCONS X V»~ => (TYPE-ERROR) (54-308) and tile following attempted solution fails in intent: (LET [[X 3] [V 4]] (RCONS 'X 'V» '[X Y] (54-309) What we wanted was the rail [3 4].4. we use instead a procedure called PREP (pronounced to rhyme with "step" but short for prepose or prepend) which is defined to return a new rail whose first element is the referent of its first argument (which must be an s-expression). this is even more true in 3-LISP. 2-lISP: A Rationalised Dialect Procedural Reflection 340 numbers designated by two variables. a list whose 1ST is its first argument and whose REST is its second. the CONS procedure serves an ollen-useful function of prepending an element to a list: returning. That this was so followed directly from the way in which lists were implemented in I-LISP. As hinted in the example given in 54299 above. to be designated by the handle' [3 4]. . but we do not have access to this solution in 2-LISP. and whose second tail is the referent of the second argument (which must be a rail). is the following: (LET [[X 3] [Y 4]] (RCONS ~x ~V» => '[3 4] (54-310) In the I-LISP derived notion of a list:. using' the primitive naming facility yet to be formally introduced but so often illustrated. The present example is thus just one example of a situation in which utility over-rules rninimalism as a design aesthetic.

2-LISP: A Rationalised Dialect Procedural Reflection RCONS 341 It should be noted that. as illustrated in the following examples (actually this works because of a subtlety regarding the relationship between a designator of a rail of s-expressions and a sequence of designators of s-exprcssions - see section 4. then the expression \ RCONS • X) serves as a one-level-deep copying function. > '[THIS WAS A TEST] ) Y ) '[THIS IS A TEST] but Y. <At». whose CAR is Again it is useful to define a utility .. . will designate a new redcx is the rail [<At> <A 2 > . which is a variant of that takes its arguments in (XCONS <F> <At> <A z> <F> and whose CDR ..x Y) ) SF > 'WAS ) X ) (RPLACN 2 X 'WAS) X was modified.c. for constructing rcdcxcs (not to CONS objccts. PCONS: if X The same is of course not true of ( PCONS • X) designates a pair.iii): (54-312) > (SET X '[THIS IS A TEST]) > '[THIS IS A TEST] > (SET Y (RCONS • XJ) ) '[THIS IS A TEST] > (. will nonnatise to a different rail with the same elements. because of the ability to objectify arguments.4. Suppose in particular that expression x designates a rail. because PCONS expects an argument designating a sequence of two could readily be defined.. (REST ARGS»») Thus for example we would have: (XCONS '+ '1 '2) (XCONS 'RANDOM) => '(+ 1 2) (54-314) => ~ (XCONS '1ST '[2 3 4]) XCONS '(RANDOM) '(1ST [2 3 4]) will of course be useful primarily in programs that explicitly constnlct other programs. However a simple pair copier - generalised copier defined over pairs and rails be confused with reverse order).call XCONS MACLISP'S XCONS. <At>]: (54-313) (DEFINE XCONS (LAMBDA EXPR ARGS (peONS (1ST ARGS) (RCO"5 . then or a will fail. in particular. and x designates a pair. the cOPY. such as (A • B). not a sequence.. was not.

we discussed only those circumstances in which rails were mentioned (by using handles.iv we defined the tenn vector to include both rails and sequcllces. therefore. even from the point of view of structure creation. (LENGTH []) Thus we had. they do not . we said that some. for example: (S4-316) (LENGTH '[]) (NTH 2 [10 20 30]) (NTH 2 '[10 20 30]) => => 0 0 20 => => '20 In the first and third example.and we noted that this was a morc stringent requirement on the processor than that all normal-form designators normalised to themselves. independent of the state of the field.b. vL Vector Generalisations So far our discussions of structure creation have focused exclusively on procedures that designate s-expressions pairs and rails .b. as this section will demonstrate. mention the creation of new sequences: all sequences are mathematically abstract and are assumed to exist Platonically. creation and accessibility with regard to elements of the structural field. In particular. a rail was used in order to mention a sequence. and LENGTH - to include vectors of both types. For example.b. In section 4. 2-LISP: A Rationalised Dialect Procedural Reflection 342 4. In section 4. llonnal-fonn rails selfnomla/ise. and by llsing applications fonned in terms of RCONS and so forth).quences as well. It will tum out that we need to SCONS define a constructor function for sequences. those whose elements were in normal-form were themselves considered to be in Donnal fonn. However we cannot afford to ignore sequences completely. mere satisfaction of the normalisation mandate - We stipulated further . TAIL.iv we commented that the three selector functions TAIL NTH. and were defined over both sequences and rails. It is this question that deserves attention. lbe relevance of these observations here is this: when discussing rail creation in the previous section. to designate sequences.since it is only meaningful to talk of We did not.. in the second and fourth. a handle was used in order to mention a rail.4. and extended the 40mains of the selectors functions NTH. What we did not discuss was the issue of the identity of rails in contexts where they are used. In other words. rails were nannal-form sequence designators. Some relevant facts have already been stated. LENGTH. and to extend PREP to work over sr. but not all.

First. however. 54-322 through 54-324 are explained because ill each case .) This property of 2-LISP'S processor can be noticed using. 2-lISP: A Rationalised Dialect Procedural Reflection 343 simply normalise to an arbitrary normal-fonn rail designating the same sequence. each of them will nonnalise to itself. rather than to any other. 3. is the identity of the rails on the right hand side of these normalisations. once again. F E FIELDS ['I'EF(S) = s]]] (54-326) This explains how rail identity is preserved in 54-316. 54-317.4. In other words. that in 54-316. although there can exist in the field any number of distinct rails consisting of the numerals 2.d): [2 3 4] '[2 3 4] 1"[2 3 4] [2 (+ 2 1) (+ 2 2)] '[2 (+ 2 1) (+ 2 2)] t[2 (+ 2 1) (+ 2 2)] ~ => [2 3 4] '[2 3 4] (54-316) (54-317) (54-318) (54-319) => => => => '[2 3 4] [2 3 4] '[2 (+ 2 1) (+ 2 2)] '[2 3 4] (54-320) (54-321) What is not apparent from these examples. In addition. and why it is not preserved in 54-319 and 54-321. and 54-320 the rail on the right is the same rail as that on the left. The answers. we observe that nonnal-fonn rails 1"(EXP> normalise to lexically indistinguishable rails. as do handles of rails. however. as the following illustrates: (= [2 3 4] [2 3 4]) (= '[2 3 4] '[2 3 4]) (= f[2 3 4] t[2 3 4]) $T SF Sf (54-322) (S4-323) (54-324) The ruling equation (provably true for the 2-lISP processor) is this: vs E S [NORMAl-fORM(S) := ['IE € ENVS. and 54-320. whereas in 54-319 and 54-321 it is obviously different. were all predicted by the equations in section 54-105: namely. but that nonnal-fonn designator to which its argument would normalise (this will be reviewed in section 4. intensionally as well as extensionally. all ~c raits that are type-equivalent lexically (in these six examples) are in fact identical. in tenus of the identity of those on the left. we can see that of the referent of its argument designates a normal-form designator and furtltennore. the ubiquitous ope~ator that designates the name of its argument. not just any nonnal-fonn designator of the referents of its argument. although that is of course not generally true. and 4. 54-317. In other words. the result of the first is the exactly the same as that of any further ones. but not rails that are not in nonnal-fonn. 54-318. (This is important in part in underlying the fact that multiple normalisations are harmless.

to recognise that t <EX P> designates the result of nonnalising <EXP>. It is. in interpreting this figure. double-lined arrows signify nOJmalisation relationships (it). However they normalise to different handles. That it does is again predicted by 54-106. not as immediately obvious that 54-318 can be accounted for by the same considerations. because it is not in normal fonm. thus t(EXP> normaliscs to the handle of the result of normalising . whereas Y is not self-normalising. Another example illustrating this point is the following: > (SET Y '[2 (+ 1 > '[2 (+ 1 3)] > (. These are of course different rails ~x and ~y normalise to equivalent expressions because the referents or X and Yare co-designative terms.(NORMALISE X) (NORMALISE V») ) SF ) (N X (NORMALISE X») > S1 > (.4. because it is in normal form already. On the other hand both X and Y normalise to self-normalising expressions. 2-lISP: A Rationalised Dialect Procedural Reflection 344 the two lexical rail-nolalors (elements of L-RAIL) notate a distinct rait 54-322 designates tnlth because the equality predicate is applied to the designated sequences. X is self-normalising. which normalise to themselves): I t is crucial. > (NORMALISE X) > '[2 4] > (IJORMALISE Y) > '[2 4] ) (. not to the designating rail.x Y) ) SF > (SET X > '[2 4] '[2 4]) 3)1) (54-326) . however.Y (NORMALISE V») ) SF > (LET [[W (NORMALISE X)]1 (a W(NORMALISE W))) ) $1 > (LET feW (NORMALISE YJ11 (a W (NORMALISE Ii»)· ) $1 The circumstance explored in this dialog is pictured in the following diagram (single-lined arrows signify designation relationships (tIJ). and boxes with heavy outlines are normal-form expressions.

Often this is not a problem. Thus we have the following innocuous example (note the use of SET rather than SETQ.th variables which are not nonnal-form.tX t(COPYJ • X)) > (SET X ['FOUR 41) > (COPYJ 1 > [1 2 3] 2 3) (54-331) X of course designates a single thing Furthermore. 2-lISP: A Rationalised Dialect Procedural Reflection In other words: 345 <EXP).x X) > $1 > (. thus if that rail is normalised before being returned.c. X is in normal fonm They d9$1gnate the same sequence . than that rail can be modified. (LET [[X []]] (= tX tX» Sf (54-a28) The consequences of all of this investigation are this: any given empty rail witi self- normalise: if the naming operator t is used to obtain mention of this rail. this will be explained in section 4. because in a typical procedure body rails are used wi.vi): > (SET X (TEST > (3 4] > TEST > (DEFINE TEST (LAMBDA EXPR fA 81 fA 8])) 3 4)) (54-329) ) (SET Y (TEST $f $F)) ) [$T SF] ) (RPLACT 2 tX '[10 20 301) ) '[10 20 30] >X ) [3 4 10 20 30] > y ) [ST SF] ) (PRETTY-PRINT TEST) (DEFINE TEST (LAMBDA EXPR [A 8] [A 0]» no problems are encountered no problems are encountered The troubles arise only when elnpty sequences are designated. using the PREP function: (DEFINE COpy. (REST ARGS»»» (54-330) The intent is to engender the following sorts of behaviour: > ['FOUR 4] ) (. a new rail is generated. Suppose we for example define a recursive copying procedure intended to construct a new designator of the sequences of its argument's referent in every case.4. (LAMBDA EXPR ARGS (IF (EMPTY ARGS) [] (PREP (1ST ARGS) (COpy! . Thus t[l will always normalise to the same handle.tX tX) > ST > (a X (COPYJ • X)) > $1 > (.

indeed constructs a new rail. which. (REST ARGS»»» TIle solution. (REST ARGS)))))) X (COPYz 3 4)) > (SET Y (COPYz 6 6)) > [6 6] > (RPLACT 2 tX '[10 20 > [3 4 10 20 30] >y > [5 6] ) (PRETTY=PRINT COPYti > [3 4] 30J) No problems arise. in Y or in COPYz (DEFINE COPY2 (LAMBDA EXPR ARGS (IF (EMPTY ARGS) (SCONS) (PREP (1ST ARGS) (COPY2 . as illustrated in: > () $T ) Sf ) (. but only if ARGS is non-empty. like RCONS. > (DEFINE (54-333) > (SET ) COPYz (PREP (1ST ARGS) (COPYz . So has the definition of COPY I : .against the original intent .(COpy!) (COPY J )) t(~OPYJ) (S4-332) : This is as it should be ':"(COPYJ )) > [3 fSET X (COPYJ 3 4)) ) [3 4] ) (SET Y (COPY J 6 8)) > [6 6] > (RPLACT 2 ~x '[10 20 301) > : But this should be SF 4 10 20 30] : X has been modified as expectod : But Y has been modified as well . (LAMBDA EXPR ARGS (IF (EMPTY ARGS) [10 20 301 ) Y ) [5 6 10 20 30] (PREP (1ST ARGS) (COPY•.(the modified part is underl ined) > (PRETTY-PRINT COPY1 ) (DEFINE COpy. Furthennore . 2-LISP: A Rationalised Dialect ) SF Procedural Reflection : But they are different designators 346 These intended results are all generated by the definition given: COpy.4. a new (otherwise inaccessible) designator of the sequence of referents of its For example: COPYz (LAMBDA EXPR ARGS (IF (EMPTY ARGS) (SCONS) arguments. is to call the primitive function retur~s SCONS.every rail returned by COpy 1 shares the same foot. (REST ARGS»»» > (> ST (COPYz) (COPYz )) : As expected (both designate the . instead of using [].

.4. in that one is likely to lose any clear sense of the possible range of side-effects. Furthennore the distinction is far more principled than that between EO and EQUAL in 1-LISP. for a number of reasons. which apparently gives so much trouble. f-Iowever this is inelegant and dangerous. and so forth. to distinguish structural entities from their That fact. by defining a type-equivalence predicate defined over vectors whose elements were individually identical. different designators. in fact. and for reflection in particular - encompass both. by foundational assumptions. The following examples illustrate in brief how (SCONS) (RCONS) (peONS) SCONS. coupled with our inclusion of the crucial for such meta-structural considerations leads straight away to the fact that we must structural field in the seman tical domain in general. if we include a derivative notion of type-equivalence on vectors. . First.)) It should be apparent.t(COPYt ) t(COPY. We are forced.. The answer is an unqualified yes. A possible reply is then that the system might provide automatic conversion between rails and sequences just in case all of the sequence's clements were internal (elements of the field). ~ <ERROR: Too few arguments> ['A '0 'e] (SCONS 'A '8 'e) (RCONS 'A '0 'e) (peONS 'A tB) (SCONS 1 2 3) (RCONS 1 2 3) (peONS 1 2) (54-336) => ~ -~ '[A B C] '(A. This suggestion is just the same as the one we . in other words. RCONS. but they are . in the way in which we did in order to define I-lISP'S EQUAL - it: in other words. In addition. like large cities without violating the very basis of computation..~ equivalent to some degree. and another over vectors whose elclncnts were type. all semantically well-defined. and peONS differ: ==> :::::> [] '[] (54-334) => :::.. B) [1 2 3] <TYPE-ERROR: Expected an s-express1on) <TYPE-ERROR: Expected an s-express1on) (54-336) ::. is worth the effort. that SCONS is COPY2. 347 ) SF > (. we have no choice: it may be that the difference between an abstract sequence of numerals and a rail of numerals is slight. The reader may well wonder whether the distinction between rails and sequences. 2-LISP: A Rationalised Dialect Procedural Reflection i empty sequence). we define a procedure TYPE-EQUAL as in 54-267 - we obtain three levels of grain in tenns of distinguishing orderings. but we simply cannot have a rail of arbitrary objects referents. In fact an infinite number of levels could be distinguished..

1 1) ) ST > (TYPE-EQUAL > Sf (S4-337) 1 1) > (TYPE-EQUAL X (RCONS • X)J > $1 We will use the~e > SF > (SET X '[THIS IS A RAIL]) > '[THIS IS A RAIL] > (. By and large this will simply be admitted.X (RCONS .4. with due regard for the potential confusions they engender. even this extended version of PREP could have been (awkwardly) defined as follows: . and LENGTH are defined over vectors of both types. bllt one important c<. Furthermore. is also defined over both types: it will return a new designator of the same type as its second argument: (PREP (PREP (PREP (PREP 'A '[B e]) 3 [4 6 6]) 'A (RCONS» $f (SCONS» 'EA B C] (S4-338) [3 4 6 6] '[A] [$1] Though primitive. the use of TYPE-EQUAL is rarely mandated. Though RCONS and SCONS are different. There is no confusion in 2-lISptS behaviour in this regard. X)) distinctions when appropriate. What remain arc possible programming use/mention type-errors: using a rail when a sequence was intended. In practice" such confusions are slight: if one consistently uses (SCONS) in place of [] and (RCONS) in place of '[]. 2-LISP: A Rationalised Dialect Procedural Reflection I-LISP 348 passed by in defining type-equivalence over lists in illustrations: We again give some > (a [1 [1 21 [1 [1 21) > SF > (TYPE-EQUAL [1 [J 21 [1 [1 21) ) $1 > (. where a sequence of Ilandlcs will be made to bind in a manner exactly parallel to a rait of referents.iii. quite the contrary: the programmer's problem is usually 2-lISP'S unswerving strictness. and vice versa. This will be discussed further in section 4.c.>ncession to user convenience will be made. regarding the binding of variables. all of the identity problems effectively e'"aporate. we have observed that PREP NTH" TAIL.

4. 2-LISP: A Rationalised Dialect Procedural Reflection 349 (DEFINE PREP (LAMBDA EXPR [ELEMENT VECTOR] (CASE (TYPE VECTOR) [RAIL (LET [[NEW (RCONS F.lE~ENT)]]] (BLOCK (RPLACT 1 NEW VECTOR) NEW» ] (54-339) [SEQUENCE (LET [[NEW (SCONS ElEMENI')]] (BLOCK (RPLACT 1 tNEW tVECTOR) NEW»]») .

in this section we will present them more cart:fully. since pairs are no long(:( the basis for an inlplementation of lists. When we show how the processor works. In 3-lISP uncl~ar that in any natural sense expressions of this sort stand JilT or refer 10 anything: it would seem that their entire import we will examine a rather elegant way in which to embody in the formal machine the intuition that expressions with side effects should not be made to designate anytlting. or tail. RPLACA and RPLACD are as in I-LISP. We have already used all of these functions. and RPLACT t that change elements and tails of rails. What is rather unclear. CDR. since it is rather is conveyed in their structural effects.ne side-effects effected by RPlACA RPLACD manifested in the characterisation of their full procedural consequence. we expect that . having a new element. in terms of~. NIL. "'" . in ordrr to demonstrate the salient identity conditions on the structures involved. as the case may be. COR. Some examples: > (SET X '(LENGTH [IT WAS THE 8£ST OF TIHES])) > '(LENGTH [IT WAS THE BEST OF TIMES]) ) (RPLACA X 'TAIL) (S4-343) > '(TAIL [IT WAS THE BEST Of TIMES]) > (RPLACD X '[2 [CITIES]1) ) '(TAIL 2 [CITIES]) Because we no longer use lists. however. terms of local procedural consequence they are straightforward: they return the nonnalisation of their second argument. Each is defined to "return" CAR. is what their declaralive semantics should be. and similarly not to return anything. no questions arise and will be In Semantically. and have no distinguished atom about modifying the ends of lists: or of Inodifying NIL. implying that their local procedural consequence is null (even though their full procedural consequence is substantial).b. except of course they are not used to modify en\1merations. FIRST. the D'Jodified pair or rail. that change the CAR and CDR of a pair.4. 2-LISP: A Rationalised Dialect Procedural Reflection 350 4. vi. we can demon~trate a way in which the primitive procedures that exist in order to change the field can call their cOfitinuat!ons with no arguments.' Structural Field Side Effecls The final category of structural field primitives we have to introduce are those that modify the mutable first-order relationships: and RPLACN CAR. rIbere are four such functions: RPLACA and RPLACD (as in I-LISP). We will . and REST.

since we don't have machinery for a function any declarative import. RPlACN (for "replace Nth") and RPLACT (for "replace tail") each take 3 arguments: tile first .Dz.F 3 )]) [[ F3 = <F21 • Fd ' F23 • F24 • F2 6 )] A [VP E PAIRS [ if [p = ffANDlE.Fl.El.AF.Sz.52 . (54-344) 2 °2 ])] C("(EXPR Eo [PAIR A] (RPLACA PAIR A)J.5 2 .Oz.F z).NTH{2.NTH{2. ~(Sl. [[ F3 ['IP ::: <F•• Fz2 • F23 • F2 4 . but rather is just like r2 except that the CAR or CDR of the argument is modified. particular. TIle two rail modifiers are more complex.E2.F z»] And similarly for RPlACO: I( foC" RPLACD» = [AE. [A<Sl.E 1 .F z» ) e I s e [F d ( P) = F2 2 ( P) l]]] In both cases the field passed back to the main continuation (as evidenced in the third line of the equation setting forth the internalised function) is not Fz.E z.S z .F1> . f)] A[E o{" RPLACA) 1 = AS1·AE1·~£1·AC wh ere (54-346) ~(Sl.F z).AC .D2.1 (NTH( 1. which is the one received from the normalisation of the arguments. however. as previous examples have inthnated.1 (NTU(2.Fl. C{NTH(2. l:(Sl. we have the significance/intemalisation pair for 1:( Eo{ It RPLACA» RPLACA: In = [AE.f2) • E. e 1S 8 [F I ( P) = F2 1 ( P) ]]]] .F 2 ) • D2 ' ] ) ] F)] d[E o{ "RPLACD)] wh 8 r e (54-347) = AS1.E 1 . [A<St.AF.F2> . FOI function that demands an "answer" only dcnyin~ the time being. as one would expect.E 2 . we will say that each of these (and RPLACN and RPLACT.El.F 1 ) • E.S z.[A<S2.El.F 1 . thus satisfying the nonnalisation mandate.AC .[A<Sz.F2> . discussed below) designates the new fragment.t ( NTU( 1. C.[A<Sz.4.fl. Fl »] . 2-lISP: A Rationalised Dialect ~lOCK Procedural Reflection 351 at that !Joint define a more sophisticated from the last fonn within its scope.E z.F 3 )]) then [F.Ez. I(Sl.Sz.D2.El. Fz» ] then [Fd{P) = HANDlE.(P) = tfANDlE·".~El·AF1·~C . Fz5 ) ] A E PAIRS [ 1f [p :: HANDlE.[A<S2.Ez. (54-346) C("(EXPR Eo [PAIR D] (RPLACD PAIR D)).

splicing the remaining parts together. (54-360) JOIN can be defined in tenns of the FOOT utility defined in 54-28S: (54-361) (DEFINE JOIN (LAMBDA EXPR [Rl R2] (RPLACT 0 (FOOT Rl) R2») Another example is the following procedure.(+ N 1) ELEMENT RAIL»] (54-362) (54-353) . the first argument to N should designate a number between 0 and ttle length of the rail. to illustrate the u~e of these procedures. the straightforward COpy is defined in (DEFINE JOIN (LAMBDA EXPR [Rt R2] (RPLACT (LENGTfI Rt) Rl A2») (DEFINE APPEND {LAMBDA EXPR [Rl R2] (JOIN (COpy Rt) R2») Equival~ntly. called EXCISE. respectively.4. since for any rail of length there are N+l defined tails. First we give simple definitions of the 2-LISP rail analogues of 1- LISP'S NCONC and APPEND - two procedures that destructively and non-destructively 54-916): (54-349) construct the concatenation of two enumerations (we use the term JOIN in place of NeONe. In both cases the modified second argument is returned as ~avc the result We illustrated both of these functions from time to time in preceding sections. 2-LISP: A Rationalised Dialect Procedural Reflection 352 designates an index into the rait that is designated by the second argutncnt. the following examples review their straightforward behaviour: X btJfore: [CAVE CANEM] [] [I LIKE TO WATCH] [1 2 3 4 6 6] Form normaJ1sed: (RPLACN (RPLACT (RPlACT (RPLACT 2 X 'CANTEM) 0 X '[NEW TAIL]) (LENGTH X) X '[TOO]) 3 X (RCONS» X after: (54-348) [CAVE CANTEM] [NEW TAIL] [I LIKE TO WATCH TOO] [1 2 3] It is instructive as well to define several standard utility functions on rails. and returning the number of occurenccs removed: {DEfINE EXCISE (LAMdDA EXPR [ELEMENT RAIL] (EXCISE* 0 ELEMENT RAIL») (DEfINE EXCISE(LAMBDA EXPR [N ELEMENT RAIL] (COND [(EMPTY RAIL) N] [(= ELEMENT (1ST RAIL» (BLOCK (RPLACT 0 RAIL (REST RAIL» (EXCISE. The first argument to RPLACH should RPLACT designate a number between 1 and the length of the rail. the third designate~ the new element or tail. that takes as arguments an element and a rail and destructively removes any occurenccs of that element in the rail.

N ELEMENT (REST RAIL)}]}» Procedural Reflection 353 For example: > (SET X '[I'LL NEVER SAY NEVER AGAIN AGAIN]) > '[I'll NEVER SAY NEVER AGAIN AGAIN] > (EXCISE 'NEVER X) ) 2 ) X (54-364) > '[I'LL SAY AGAIN AGAIN] Straightfonvard as these examples seem. ) to change all of a rail is a facility that t-LISP did not have. and lists were being used in place of rails. worth mentioning particularly because they yield behaviour substantially different from that of I-LISP. Such a design would nullify all of the cleanliness we obtained by making our procedures work equivalently at any rail .. If this were l-lISP. we have poitltcd out that the ability to use (RPLACT 0 . In particular. arc visible even if 0 is not used as a RPLACT index. as expected The question. the consequences of this behaviour. however. 2-LISP: A Rationalised Di~ect [$T (EXCISE. is WllC:lt Y designates in the resultant context. the answer would clearly be the "list" (NOT BECAUSE).. Consider for example the following session: > (SET X '[IF NOT BECAUSE]) > '[IF NOT BECAUSE] > (SET Y (TAIL 1 X)) > '[NOT BECAUSE] ) (RPLACT 1 X '[AND ONLY IF1) > '[AND ONLY If] ) X (54-366) ) '[IF AND ONLY IF] . In other word~ we have the following: i ) (S£T X '(IF NOT BECAUSE)) > (If NOT BECAUSE) This is i-LISP (54-366) > (NOT 8ECAUSE) > (RPLACD X '(AND ONLY IF)) > (AND ONLY IF) ) X ) (SET Y (CDR X)) >y > (NOT BECAUSE) ) (IF AND ONLY IF) as expected Y doesn't see the change to X 2-lISP - In some sense we have an option in example given in RPLAC. 54-366 Y in that \VC could simply posit that in the but this would meail that choic~ should designate [NOT BECAUSE] - if its first argulnent was other than zero. would have a disccrnably different behaviour from that when its argument is zero. however.4. there are some subtleties that emerge on a closer look..

Therefore the only acceptable choice is to have 54-365 unifonn. rather than having I-LISP specify particular behaviour at the beginning and end. because it merely manifests the declarative import. Thus we can simply specify that in the state that results from the execution of a RPLACT instruction. Semantically. moreover. This is encoded in the following two equations. in the RPLACT fashion. implying that y at the end of it REDIRECT - should be bound to the handle '[AND ONLY If]. is that it brings with it all of the problems of I-LISP'S RPlACD on lists: it cannot be used on the first element. One option would be to encode. for a procedure ~ we will call can always be defined that mimics the I-LISP style of behaviour. Thus we are better off in general with our uniform definition. Such a choice. which is virtual1y identical to that of the other modifiers: .4.d. We can in particular define the following: (DEFINE REDIRECT (54-367) (LAMBDA EXPR [INDEX RAIL NEW-TAIL] (IF « INDEX 1) (ERROR "REDIRECT called with too small an index·) (RPlACT (. of course. every occurrence of the old tail will be changed to an occurrence of the new rail. however. must be provided by an implementation (one is given in the appendix). From this point of view the behaviour of RPlACT is easily stated: the rail that is changed should simply be different in the resultant context. The first is straightforwa. 2-LISP: A Rationalised Dialect to Procedural Reflection 354 position. a constructive algorithm that engenders the proper behaviour. we have some choices as to how to characterise this behaviour. Such an algorithm. however. represents no loss of power. It is far simpler. to use a nonconstnlctivc specification that merely states the constraints that such an implementation must satisfy. within the meta-language.INDEX 1) RAIL (PREP (NTH INDEX RAIL) NEW-TAIL»») Thus we would have: > (SET X '[IF NOT BECAUSEJ) > '[IF NOT BECAUSE] (54-368) > '[IF AND ONLY IF] ) y > '[AND ONLY IF] >X > (SET Y (TAIL 1 X)) > '[NOT BECAUSE] > (REDIRECT 1 X '[AND ONLY 1F1) as expected Y did not seo the redirection of X > '[NOT BECAUSE] What is striking about this definition.

S z.F2) .Ez. HANDLE.S z.fa)]) ] A (VR E RAILS [If [R ~ TAIL(M(NTH(I.F z).E 3 .[A<Sz.Sz.El.Ez.Dz.Dz.E z. C(NTH(3. ».AE1·AF1·AC • (54"'360) ~(Sl.F z» .El. F2Ii) ».ft.Fz} • Oz'])] The work is done in the following: A[E o( "RPLACT)] • AS~. F)] (54-369) NEW-TAIL)).E t .AC . I(St. Fl Fz) ) ·"E where (( F3 E FIELDS] " [ F3 = <f 2 t .f t ) . F2 ). C(W(EXPR E.Dz. [A<5 1 .1 (NTH(2. both of which we have constrained appropriately.5 2 .D2.F z» in ([[ E3 € ENVS) A [F 3 E FIELDS]] " [VA E ATONS [ 1f [fz(A) = OLD] then [E 3 (A) • NEW] else [E 3 (A) ['IS E S. [ i f [flt(S) II II Ez(A) NEW] lD A OLD] then 8 JS 8 [f 3 t (A) :a [F 3 t ( A) • F2 t CA) lm This works because it constrains every possible access to the old tail... C("(EXPR Eo [INDEX RAIL ELEMENT] (RPLACN INDEX RAIL ELEMENT)). 2-LISP: A Rationa!ised Dialect Procedural Reflection 3SS I(Eo(WRPLACT» • [AE. and simply states that such accesses will henceforth point to the new rail. and other ways in which previously existent rails can be accessed must be mediated by the environment and the field.e.AF. Vi lStS6 . F2Z • F. in virtue of lexical notation) structure can reference a rail directly: all occurrences of lexical brackets construct new ones.Et.Ez.Fl.F 1 ) • 1:(Sl.[A<Sz.Ez. 0 2 3 ])] E.Fz) .El. W1 NEW = HANDLE (NTH(3. 111c equations for ~(Eo(WRPLACN» RPLACN are simpler: (54-361) • [AE. Eo [INDEX RAIL NEW-TAIL] (RPLACT INDEX RAIL [A<Sl. Fl] (54-362) A[E o( W RPLACN)] • AS 1 1 ·>'F 1 ·AC • I(Sl.f z HANDLEWICNfU( 2.AF.[A<Sz. .Ft.f 3 )]) where let OLD • TAiL(M(NTH(l.4.F1 ».Fl.[A<Sz.S z.F2) · C(NTH(3.F z).E I ..AC .Sz. It is crucial that there is no way in which an external (i.Sz. as we have seen. F24 .

t (NTH(3. along with a general discussion of procedure construction. we may observe that the machine. and the conditional. is straightforward (although semantically rather interesting). rather than designating its . in the style of the M. viiL Input/OupUI ) '[NOW WHEN] ) Z > '[NOW WHEN] We have by now dealt with ~'. as well. The three input/output procedures in 2-lISP are sufficiently similar to those in I-lISP that they can be dealt with quickly. Finally. and binding protocols.(R) a fz3(R) nn As a kind of postscript. the last two categories the seman tical and processor primitives - will occupy our attention in section 4.T. In this and the next sub-section we will deal with these two groups.F z ») 356 then [F.e first five of the categories listed in table 54-165. although in each case the argument designates the expression printed or read. so that chains of invisible pointers do not get constructed containing cycles. Some subtlety is required. of the sort that inadequate implementations are likely to fail on.(R) II elS8 [F. One final example. 1 2-LISP rail behaviour can be LISP implemented using a style of "invisible-pointer" mechanism.4. environments. but the code is short and straightforward.c.S 2 .I. 2-lISP: A Rationalised Dialect Procedural Reflection HANDLE.b. is the following: > '[IF NOT TO TURN AGAIN] > (SET Y (TAIL 2 X)) > '[TO TURN AGAIN] > '[AT THE BEGINNING] >y ) '[AT THE BEGINNING] ) X > (SET X '[IF NOT TO TURN AGAIN]) (54-363) ) (RPLACT 2 X '[AT THE BEGINNING]) > (SET Z Y) > '[AT THE BEGINNING] > (RPLACT 0 Z (TAIL 2 X)) > ) [IF NOT AT TItE BEGINNING] ) '[AT THE BEGINNING] ) (RPlACT Z X '[NOW WHEN]) > '[NOW WHEN] y no change to anything >X > '[IF NOT NOW WHEN] 4.d. the last six remain. The two naming primitives will then be taken up in section 4. 2-LISP TIle three input/output functions of are adapted from I-LISP.

declaratively. it is also semantically mandated. since the processor is designation-preserving. can be thought of as designating the structure notated by the "next" lexical expression in A console session illustrates (we underline both input and output that is READ-NORMALISE-PRINT independent of the reading and printing engendered. illustrative of the sort of code we will encounter when we construct the circular processor. which is just ~hat should also designate 2 3) the handle '( + does. since that s"expression is not in nornlal form. We have. what we are discussing is simple reading. whose value is the nonnal-fonn to which that expression would nonnalise. Not only is this by and large what is wanted. we will look at examples. and to return a designator of that expression as a result Thus. ma\ntaining the use of italics for input): > (READ) 24 ) '24 ) (READ) (54-364) [TIME INEXORABLY DOES ITS THINGJ ) '[TIME INEXORABLY DOES ITS THING] ) (TYPE (READ)) Sf > (+ (READ) (READ)) ) 'BOOLEAN Not TRUTH-VALUE I 4 6 TYPE-ERROR: +. and is also the natural design choice. normally. not signified entities. not a full (READ) READ-and-NoRMALISE processor.4. normalised tile string It Suppose in particular that when the s-expression (READ) (+ was (+ 2 3)" was present in the input stream. (READ) designates an expression. by the loop. NORMALISE 2-LISP meta- is an extensional function defined over expressions. In particular. found the numeral '4 The reason that the last example produced an error is that Yihat one "reads" arc ill fact expressions. 2-LISP: A Rationalised Dialect Procedural Reflection 357 referent This protocol follows from general semantical requirements. the normal-fonn of that expression. The s-expression 2 3) could not be returned as the result. And even from an intuitive point of view. but since it yields somewhat different behaviour from that of !-LISP. and to return the numeral 6. That this behaviour is generally appropriate is shown by the following example. Furthennore. it would be entirely inappropriate to nonna/ise that exprc5sion. expecting a number. there is a single procedure called (READ) whose procedural (REAil) consequence is to read in the lexical notation for a single s-expression from the input stream. for example: > (NORMALISE (READ)) ) '6 (+ 2 3) (54-366) . the input.

j.'ill be underlined for pedagogical clarity): (54-367) > (PRINT 'HELLO) 'HEllO > ST > (BLOCK (TERPRI) (TERPRI)" '[MADELEINES AND TEA?] (PRINT '[MADELfINES AND TEA?]) (TERPRI)) > $1 > (PRINT '(RPLACN • [2 '[GOOD BYE] 'BUY])) '(RPLACN 2 '[GOOD BYE] 'BUY) > Sf 11le last example in this set demonstrates that the standard lexical abbreviations are employed by the printing routine when possible. not expressions. Their use almost entirely resembles that of I-LISP (in this and subsequent examples. not of 2-LISpts It is straightforward that 2-lISP'S READ and PRINT are entirely parallel in designation.j. Lest the last example of 54-364 s~m awkward from a programming point of view. which prints out the lexicalisation of the expression designated by its argument. whose procedural consequence is to print an "end-of-line" on the output stream and to return the boolean ST. the expression will be shown to designate the referent of the referent of Thus the following is facilitated: > (+ . We add numbers.rgument to (READ) designates an expression to be nonnalised. y.<EXP> operator we have used so often)c In genf?ral. we can again point ahead to a "level-crossing" operator not <EXP). yet introduced (the inverse of the . rather than in the normal course of running the READ-NORMALISE-PRINT loop.(READ) .j. (54-366) ) 30 With regard to printing.4. NAME in spite of this semantical argument. there are two primitives: and PRINT.(READ)) 10 20 TERPRI. which nonn&lises to the numeral 6 - in this case designates the pair (+ which numeral is designated by the handle returned. whereas PRINT looks remarkably sinlilar. not numbers. 2-lISP: A Rationalised Dialect NORMALISE 2 3). as illustrated in tile following: . tile lurking 2'lymmctry is in fact evidence of the semantics of I-LISP'S evaluation. Procedural Reflection 358 In other words the a. Although 2-LISP'S READ READ may look from these examples to be (one meta-level) different from the normalisation. in I-LISP. we read and nonnalise expressions. structures that are printed by explicit invocations of PRINT.

Therefore. However. Since we have not included input/output streams in our general significance function. like a number.e. and perhaps streams as It would have to be decided. an external object.. whether a string is. . of course. since our interests lie elsewhere. we will not give input/output considerations any further attention. 2-LISP: A Rationalised Dialect (HELLO) (HELLO) Procedural Reflection 359 > (PRINT (READ)) ) $T (54-368) > (BLOCK (TERPRI) (PRINT 'IN:) (LET [eX (READ)11 (BLOCK (TERPRI) (PRINT 'OUT:) (PRINT X)))) IN: [DOUBLE TROUBLE] OUT: [DOUBLE TROUBLE] ) S1 Like the various versions of RPLAC-. we cannot formally state the consequence of these primitives.4. or whether they are structural eleraents (in which case they would be nonnally designated by handles). be cle:1r from our other examples. The comments made in chapter 3 about the inadequacy of functions hold equally true for primitives functional objects. The manner in which such characterisations would be made win. especially in applicative environment TERPRI LISP'S It is not clear." . however. in which case a normal~form string designator would have to be selected. 2-LISP. however. that there is any substance in having PRINT and PRINT return a nonnal fonn. it is nonetheless evident that it should return an expression. . the output routines are important solely for their effect Though it is only arguable that (READ) can be said declaratively to designate an expression. when we explore the option of having and TERPRI the structural modifiers return no form. I-LISP'S input/output A practical system would require more flexible strings as valid elements of the structural field. in all environments). we will also make (i.. make VE("(PRINTJ) return no fonn and 4JE("(TERPRI) be J.

b.. and potentially nontenninating computations. in the following strict sense: the referent of an application in terms of I F is a function only of the referents of its arguments.as straight-forward user functions. and the third would never return: (IF Sf 1 (PRINT 'HELLO» (IF Sf (RPlACA X 'TAIL) X) (IF (. QUIT. like all extensional functions. 0 As the last two of these illustrate. each of the following examples would engender different behaviour if IF were an EXPR: the first would print an atom. . ways. it is a function of tllcir reference in a possibly modified context of use). 3-LISP to define more radical control functions - and and so forth . and will therefore not need to make them primitive in that dialect. the second would modify the field. there is little point in introducing them in this preparatory version. Since we will be able in CATCH. however. conditionals can be combined with the higher-order . if demanding. whereas procedurally it is crucially an them: the premise and one of the two consequents). We have used the conditional many times already. 2-LISP: A Rationalised Dialect Procedural Reflection 360 4.ix. We noted in chapter 2 that tlle computati~nal conditional is semantically striking: IMPR. with respect to their form or intension.4. For example. Our characterisation of the procedural aspects of the conditional will involve us in some complexities. Control The only control operator we will introduce in 2-LISP is the primitive conditional THROW IF. havinS to do with unexpected interactions between argument .1 1) (+ X Y) (LENGTH (54-373) (JOIN Rl Rl») In spite of this. in normal use it is just like the corresponding conditional in (IF (= 1 1) 'YES 'NO) (IF (a 1 '1) 'YES 'NO) I-LISP. not of their intensional form (although. facilities of 2-LISP in potent. declaratively it is an extensional function. in order to avoid unnecessary side"effects. en·ors. since it must adjust the order in which it processes its arguments (it always processes just two of It in no way examines those arguntents. conditionals are extensional. Some simple examples: => => ~ «IF (EVEN 3) + -) 4 6) «NTH 2 [+ If LAMBDA]) Sf 0 1) 'YES 'NO -1 (54-372) :=. it merely holds off un-necessary processing.

F 2 > • if [52 = "$T] then elseif [52 = "$F] then ~(NTH(2. the equation were the simpler: (54-376) }:[Eo("IFJ )] [AE. l:(St.F)] ~[Eo(" IF. different The behaviour would be it: instead.Et. ~(NTH{[1f 02 then 2 else1f -'Oz then 3]. is on this account bound in the initial environment to a primitive Note. Procedural Reflection 361 These are best illustrated by presenting a natural semantical account and showing how it yields unacceptable behaviour.) . EI • F. C("(IMPR Eo [PRED A 8] (IF J PRED A B». in other words.[A<S3.F2.E2.F z). .D3.Ft).F2> .E 2 .E3. [A<St.Sl. C{"(IMPR Eo [PRED A 8] (IF J PRED A B)J.F2).Et.)] = ASt·AE1·AFt·AC .f.Ft. whereas on the account we have given this designates two: and it certainly nonnaliscs to 2. Ez. since we will look at other proposals presently): l:[E o(" IF J }] (S4-374) :.> .F2).F z> .El. ~(NTH(l.F)] since this would make the context in which the second consequent was examined potentially vulnerable to unwanted side-effects of normalising the first consequent. that even the declarative closure that designates a conditional function. for example.Sl.Sl. in order to obtain the designation of the appropriate consequent in that context.St.F2'C) ~(NTH(3. Given what we have said about how I F processes its arguments.Dz .AC . that (LET [[X 2]] (1F t SF (SET X 3) X» (54-377) It would designate the number three..F [A<Sz.Oz. the straightforward semantical characterisation would seem to be the following (we will call this version of the conditional 1F t .F3> · 03])])] (54-316) E.E2.[A<5z.AF.AF. designation of the 1F t closure must explicitly obtain the pcssibly modified context engendered by processing the first argument (the premise).Ez. if D t then 022 else D 3])] 2 2 E.E. however.Fl' [A(Sz. [AE.Fl).F2'C)]) IF.Ez. would imply. [A<Sl.AC .Sl.4. 2-lISP: A Rationalised Dialect objectification and non-standard order of processing. ~(NTH(1.Dz.

First. of which the conditional is a paradigmatic example. whereas the function designated by the closure can be defined in tenns of the actual truth value designated by that premise.2 3)) 'YES 'NO) 2-lISP (S4-378) TYPE-ERROR: 1f t • expecting a truth-value. but it is rather serious in consequence. 2-LISP: A Rationalised Dialect Procedural Reflection 54-376 362 TIle internalised function given in is essentially similar in structure to the full significance: it too tests the first argument. that the variable x designated the sequence of Truth.. the semantical typing of 2-LISP requires tllat the first argument designate one of tile two truth-values. although of course it checks to see whether the result of the premise term is a boolean. the number 1. Fk ]) - in order better to exhibit tile structure [$T 1 2]) ) [Sf 1 2] > (IF 1 • X) >1 > (SEr x ) (IF J • [$T 1 21) (54-379) (ERROR: 1F t . and the nunlber 2. A variety of things should be noted about the two equations. It turns out that there is a rather curious interaction between any IMPR. of using any expression other than one designating truth. "'. for example. as one docs in j I-LISP. LISPS in general.. We have the following rather disquieting result (in the first example we avoid the standard lexical abbreviation . in first positioD in order to have the second expression normalised: ) -1 ) (IF J (- 2 3) (+ 2 3) (.. depending on the result of normalising the first These two points arc merely observations: the third begins with an observation. found the atom 'X> . thus one does not have the freedom. [F z . Suppose. and our touted CDR ability to give as the of an application a non-rail expression that nonetheless designates an appropriate sequence of arguments. expecting a rail. as described in chapter 3. found the number 6 > (IF J (+ 2 3) Secondly.(F t Fz . and in particular. it is this ordering difference that enables unwanted processing to be avoided. employs what in the lambda calculus is called normal order.. on the contrary. This fact is reflected in the equation 54-375 in which it is obvious that only one of the two consequences will be processed.4. under analysis): Fk ) for (Ft. The conditional. process the arguments to EXPR procedures In what is called applicQtive order.4 .

d. using CDR peONS explicitly. examples. and put down as the which of course is t~ not the atom Y but the ra:l to which it is bound.0 of the trouble is most clearly demonstrated by a set of further proc~ssed. the expr·~ssions printed by such proce:. We have in particular the following (continuing with the same binding of v): > ~(PCONS '1Ft > Sf ~Y) (S4-381) or equivalently (REDUCE will be explained in section 4. In the illustrations below we have chosen consequents with obvious side-effects. 2-LISP: f . since x is not a rail.--- > <ERROR: IF l (1F t • Y) • expecting a rail. that it is immediately apparent when they are (In addition. argument.4. non-processed. This is predicted by equation 54-314 and 54-376. Y cannot be used in the CDR of a procedure reduction. In which is of the wrO!lg type for an argument to example shown in 54-319. the argument structure designated by 51 in for example equation 54-375 will be the atom x.sing are underlined. even though the equations in 54-374 and 54-375 predict it What makes the situation even more confusing is the fact that by employing meta-structural machinery it seems possible to get around the odd behaviour illustrated in 54-379 and S'4-380.O GOOD-BYE > [ST $T $T] .) ~nce again avoid the standard lexical First we duplicate the basic character of our results so far: (54-380) > (IF 2 • [$T (PRINT 'HELLO) (PRINT 'GOOD-BYE)]) HEllO > $1 > (SET Y [$T (PRINT 'HELLO) (PRINT 'GOOD-BYE)] HElL. Rationalised Dialect Procedural Reflection 363 The problem is that meta-theoretic NTH IF 1 cannot select the first of three arguments for nonnalisation. Because IF i does not first process its arguments. and we abLreviation. we can of course bypass tIle problem. the pair generated by is (IF $T $T $T)t normalised without trouble. However if we construct a procedure ourselves..ii): > ~(REDUCE '1F t tY) > ST (54-382) What is going on 11ere is this: the variable Y is bound to a rail of booleans. NTH. The exact nature :. which as written apply the function to the total. --. in order to extract the ~e first argument (tile premise tenn) for nomtalising. (peONS '1F t tV) In particular. found the atom 'V> The first four lines here are as we would expect: the firh and sixth are what is troublesome. that function is given the conditional and the rail [ST $T . The second alternative also bypasses the problem: since is processed upon the call to REDUCE.

"making trouble an even les~ likely occurence. 2-lISP: A Rationalised Dialect Sf] Procedural Reflection 364 as argumeuts. (54-383) <ERROR: 1F t • e~pecting a rail.sing COIlstntct a pair \\'ithout the two printing requests first: we need to bind a variable (we will use z) to the handle designating the appropriate rail. for a number of both ac£thctic and theoretical reasons. . This is a totally unacceptable suggestion. One would be simply to live with the situation as described: one could argue that it will arise. after all.'bly more investigation. We have stulltbled on what is a remarkably deep problem: our first serious challenge -.lig the intensional (procedure) type of the function being called. if ever.. it is easy to image a definition of MAP along the following anes (this is far rroln efficient.. depending on t11~ result of nonnalising the premise.Rtentioned in the first chapter . rather than to the rail itself. which arc presumably less COlnmon than EXPRS. Furthennorc. since tbe processing of the PRI~TS happened when Y was bound. only after considcra. Of course there is something odd about these solutions. For one thing.4. A variety of potential solutions present themselves. as the examples just cited illustrate. only in the case of IMPRS. For example. and it ~Norks): . Furthermore. r. But the meta-structural approach also enables us to proc~.to the clahn that objectification can be achieved in an intensional object language (for it is 1F t 'S procedural intcnsionality that is causing the problems). and it would be nice to b~ procedures will be able to usc objectified arguments without knoJv. however. found the atom 'Z> > ~(PCONS '1(j Z) HEllO ) $1 ) (IF J • Z) > ~(REDUCE 'IF J ) Sf Z) UELI. it represents an abandoning of effort 2 -L ISP ~hat a conclusion we should adopt. it will be the case in a higher-order dialect like passed as arguments. v/hich are again handled without trouble. In particular. we can have: > (SET Z 'CST (PRINT 'HELLO) (PHINT 'GOOD-BYE)]) > '[$T (PRINT 'HfLlO) (PRINT 'bOOD-BYE)] .. meta-structural machicery apparently enables one to get around the problem in cases where it does arise.O In other words ('n this approach we can even manage to have just one of the two expr~s3ions processed. it arises only wIlen IMPRS artd objectified argulnents arc cOIn bined. but it is relatively easy to understand. inally.

Nor docs it seem reasonable to require that pr~vent distinguish procedure type: nothing to the following. given the fact that in 54-386 is called with a non-rail tllcrc is . . If If<:PRS nlust be especially excluded from such general company..4. The trouble here stems from the static scoping . our retreat to meta-structural machinery is much less general tJlan the examples so far presented Inight suggest. Furtllcnnore. a better reason needs to be offered than we have yet put forward." CDR. 4] (54-301) and MACROS are procedurally distinct from EXPRS. INcnEMENT [1 2 3]) [2:. 2-LISP: A Ratiolla1ised Dialect (DEFINE MAP (LAMBDA EXPR ARGS (MAp· (FIRST ARGS) (REST ARGS»») Procedural Reflection 365 (84-384) (DEFINE MAp· (LAMBDA EXPR [FUN VECTORS] (IF (EMPTY VECTORS) (fUN) (PREP (FUN.x (54-390) 1» =::. for cxanlpte: (X] '(+ (DEFINE INCREMENT (LAMBDA MACRO (~AP . (DEFINE RESTS (LAMBDA EXPR [VECTORS] (If (EMPTY VECTORS) VECTORS (54-386) Handles both rails and sequences (54-387) (PREP (REST (FIRST VECTORS) (RESTS (REST VECTORS»»» lltis definition would support the following: (MAP + [1 2 3] [4 6 6]) (LET [[l '[ONCE UPON A TIME]]] (MAP NTH [4 3 1] [X X Xl» ~ [6 7 9] (S4-388) => ['TIME fA 'ONCE] However it would not support (MAP 1F t (54-389) (~ [(D 1 1) 1 'I)] ~ ['A '8] ['e '0]) ['A 'D] FUN MAP as we might reasonably expect. (fIRSTS VECTORS» (MAp· FUN (RESTS VECTORS»»» (DEFINE FIRSTS (LAMBDA EXPR [VECTORS] (IF (EMPTY VECTORS) VECTORS (PREP (FIRST (FIRST VECTORS» (FIRSTS (REST VECTORS»»» .

4.

2-LISP:

A Rationalised Dialect

Procedural Reflection

366

**protocols of 2-LISP that are part of its general ability to deal conveniently with higher-order
**

functions. In particular, we said that

'1F t Y)

(54-392)

~(PCONS

where

Y

was bound to

(54-393)

'[1T (PRINr 'HELLO) (PRINT 'GOOD-BYE)]

**would have the same general significance as
**

(1F t $1 (PRINT 'HEllO) (PRINT 'GOOD-BYE»

(54-394)

However the fact that this works is due in part to the- fact that there are no free variables

within the scope of Y. If we use a slightly more complex example, we will not be so lucky.

**For example, the following is straightforward:
**

(LET [[X 3] LV 4]] (IF (~ X V) X V»~

(54-395)

**However the expression
**

(LET [[X 3] [Y 4]] (LET [[Z '[(3 X Y) X V]]] ~(REDUCE '1F t V»~)

(54-396)

**would generate an error, because the variable z is bound to a hyper-intensional expression,
**

so that when the In

3-lISP REDUCE

function is given it, the bindings of x and

Y will,not

be available.

we will have more powerfiJl meta-strucnJral abilities, so that wIlen

**processing crosses meta-levels in this way explicit environment designators will be available
**

for explicit lIse.

Thus in

3-lISP

**one could construct the following:
**

(54-397)

(LET [[X 3] [Y 4]] «LAMBDA REFLECT [[] ENV CONT] (LET [[Z '[(= x Y) x V]]] (REDUCE '1F t Z ENV CONT»»)

; This is 3-lISP

which would first bind

ENV

and

CONT

to the environment and continuation in force at the

point of reflection, and would subsequently give tllcm as explicit arguments to REDUCE.

lhus 54-397 would nonnalise to 4. But, as we have maintained all along, full procedural

reflection is required in order to tnake sense of meta-structural 111aniputations in a higherorder calculus with static scoping. OUf present arguments to the conditional.

~1sk

is merely to Inake sense of objectified

What we have illustrated here is that the apparently

straightforward resort to meta-stll1ctural facilities is in fact not so straightforward: to make

4. 2-LIS.': A Rationalised Dialect it general <"waits 3-lISP.

Procedural Reflection

367

Hence we have yet another argument for finding a palatable

solution within the object language.

A second option would be to define a version of IF willl more complex behaviour: it could check explicitly to see whether its non-processed argument vias a rail, and if so work

as

indi~3ted

above, but if not, it could normalise it explicitly, on the grounds that if

someone used (I F • X) there is no other way in which the value of the premise term constituent of x can be determined. Such a conditional - we call it IF 2 - would have tile

foll~wing

meta-circular definition (this is easier to comprehend than the corresponding APRED

calculus equations in the meta-language). For perspicuity, we have not included other type checking (such as ensuring that

would need to be added.

(DEfINE IF z (LAMBDA IMPR ARGS (IF (~ (TYPE ARGS) 'RAIL) (IF (= (NORMALISE (1ST ARGS» (NORMALISE (2ND ARCS»

(NC,:rtJ,·~. T~E

returns a boolean) -

in a real implementation this

(54-398)

'$T)

(3RD ARGS»)

{LET [[ARGS (NORMALISE ARGS)]] {If (= (1ST ARGS) 'ST) (2ND ARGS) (3RO ARGS»»»

**Note that the inner conditionals cannot be simple "if-tJlcn-else" conditionals of the fann
**

(IF (NORMALISE (1ST ARGS» (NORMALISE (2ND ARGS» (NORMALISE (3RD ARGS»)

(54-399)

since in a well-formed conditional redex being explicitly processed by the definition of IF 2 given in 54-398, PRED will designate a boolean, not a tnlth-value (since we are In etacircular); explicit equality testing is therefore required (i.e.,

PRED

will equal 'ST, not

ST).

Also, the definition as given is more complex than needed: because NORMALISE (2-lISP'S '1') is idclnpotent, it is harmless to normalise an expression tnore than once. following is equivalent:

(DEFINE IF z (54-400) (LAM8DA IMPR ARGS (LET [[ARGS (IF (= (TYPE ARGS) 'RAIL) ARGS (NORMALISE ARGS»]] (IF (= (NORMALISE (1ST ARGS» 'ST) (NORMALISE (2ND ARGS» (NORMALISE (3RD ARGS»»)}

Thus the

4.

2-LISP:

A Rationalised Dialect

Procedural Reflection

368

**The argument for such a conditional is this: in the normal case it is unlikely that this
**

extended behaviour will engender unwanted side-effccts, since the normalisation of the

CDR

is necessary to decipher any meaning of the conditional application as a whole, and

**presumably it will not in tum spawn further unwanted normalisations. In the following
**

example, for instance. the side-effects involved in nonnalising the (PRINT ... ) expressions happen when x is set, rather than when the conditional is applied:

> ST

) (SET X f(- 1 2) (PRINT 'YES) (PRINT 'NO)1) YES NO

(54-401)

> ST

) (IF z

•

X)

: Since all PRINTs normalise to ST

**Ilowcver there is still anomalous behaviour where two nonnalisations are invoked, when
**

the dc-referencing operator (oJ.) is used. Consider for example tile following:

(54-402)

> (SET Y '[(a I Z) (PRINT 'YES) (PRINT 'NOJ]) > '[(= 1 2) (PRINT 'YES) (PRINT 'NO)]) ) (IF z • +Y) YES NO > ST --

TIle nonnatisation of the expression ~ y caused the referent of the handle to which y is bound to be normalised (why this happens is explained in section 4.d); there is a sense in

**which one might argue that the nonnalisation implied in the third line of 54-400 should
**

merely have nonnaliscd Ollce, not twice. I!l particular. to the handle' +v;

YES

ARGS

was bound in examvlc

54-402

tile

**normalisation of ARGS produced
**

'NO)].

'[SF ST S1]

**after printing out both
**

1

and

NO.

**What intuitively was wanted was for the nonnalisation of Y to produce '[ (=
**

'YES) (PRINT

2)

That we were unable to provide such behaviour is particularly unfortunate given the fact, mentioned earlier, that explicit construction of the procedural reduction (Let, explicit use of tile meta-structural machinery) satisfies this intuition.

**Not only do we have
**

(54-403)

> Sf

) +(REDUCE 'IF z Y)

> ~(PCONS 'IF2 Y) > ST

~

YES

but this does not even require

IF 2 :

(54-404)

**> ~(PCONS 'IF Y) YES > $1 > ~(REDUCE 'IF Y) YES
**

) $1

. ''''.1

**4. 2-lISP: A Rationalised Dialect Note, however, that we have solved the
**

(MAP IF z

[(~

Procedural Reflection

MAP

369

problem.

**We have, in particular:
**

(54-406)

1 i) ['A '8] ['e '0])

(~

1 'I)]

['A 'OJ

IF z

In sum, then,

solves one of our two problems: it allows non-rail total arguments

tl' IF, but it doesn't provide an easy way in which nonnal-order processing can be used in

that situation. Nor do we yet have a solution to the second problem: tncta-structural machinery is still necessary to deal \vith such a circumstance, but, as we pointed out above,

meta-structural solutions can be made acceptnble only in a reflective dialect What then are we to conclude? The situation we find ourselves in is this: declaratively, the conditional is defined over a sequence of three entities, but procedurally

**the designators of these entities arc processed in a peculiar manner Oust two, in fact, are
**

used in any given case). The objectification mandate suggested tllat a designator other than

.

a rail could be used to designate sequences of entities. The conditional has a prob~.em, in

.

such a case, since it needs access to a nonnal-fonn designator of L'le first element of the sequence. [[three discriminable element designators are provided, then the conditional can

process them individually. It: however, such discriminable designators are not provided, we were led to conclude that designator of the whole

be a rail.

IF

was forced to process the full sequence designator. and then to which is guaranteed (by the semantical type theorem) to

**extract the nonnal-fonn designator of the firsl sequence element from the resultalll
**

sequcncc~

Once we sec the issue in this full light. it is clear that the only way in which partial nornlalisation can occur is for some party to be able to take a sequence designator and dissect it into structurally distinct designators of the sequence clements. The very machine is able to do this with rails designators. In fact if we could

/lol

2-LISP

**which happen to be the standard sequence
**

EXPRS

pull apart all rails (not just those in normal fonn) the

**problem would have arisen for every function we have seen so far, since
**

extracted. However in the

EXPR

arc all called

with sequence designators. from which designators of the individual arguments are to be

**case that sequence designator is the result of a
**

i~

nonnalisation; hence it is guaranteed to be a rail, so we did not encounter the current difficulty. In the procedurally intensional case. at least as we have so far defined we

4.

2-LISP:

A Rationalised Dialect

Procedural Reflection Hence we were led to

370

IF 2.

have no protocol for doing this in the general case.

It is natural to ask whether we could define such a structural decomposition process

in the general case. But in order to ask this question we need to be clearer on what we

**mean. From one point of view we do have a method of taking any sequence designator
**

and yielding a structurally discriminable designator of an element: we norraalise the

**designator as a whole, which is guaranteed to return a rail, whicll
**

whi~h

w~

can then disect. TItuS

**we are led to put our Question more carefully as follows: is there any general algorithm by
**

we can take a sequence designator and, withoUI processing it, extract a designator of

each argument. But again this needs clarification: what is it to process an expression? What we arc concerned with, it becomes clear, is that we wish to avoid any unwanted sideeffects of processing the inappropriate element designator.

It might seem that one way albeit impractical - would be to suspend the

CUITcnt

state of the computation, and to process the whole sequence designator in a completely new and isolated context (into which, say, the whole original context was copied so that the ground will have been appropriately set up). We could then process all of the sequence designator, look at the designator of the first element to detcnnine whether the premise

**crone out true or false. It might seem, that is, that if we knew whether the premise was
**

true or false "ahead of time", so to speak, we could select the appropriate part ()f the

sequence designator.

But there are two problcnls. The first has to do ·with termination: it is not clear that, if any sense could be made of this suggestion, it would be possible

to

guarantee that this

pre-processing "hypothetical" pass could be executed in fashion which wou\d be guaranteed to tenninatc. Secondly, it simply is not in general definable which parts of the processing of a sequence designator "belong" to which element of the designated sequence. Consider

**for example the following expression:
**

(BLOCK (SET X S) (SET Y 4)

(SET Z 6)

(54-406)

[X Y Z])

**A,ny presumption that the expression
**

assumptions.

(SET X 3)

has to do only with the first element of the

resultant sequence is of course based on purely infonnal and ultimately indefensible

4.

2-LISP:

A Rationalised Dialect

Procedural Reflection

371

There is, ill sum, as we said earlier in another context, no solace to be found in this f,uggestion (perhaps that is fortunate, given the potential complexity of computation it hints at). It should be admitted that for a certain class of sequence designators, however, some approximations to such an 'approacll can be defined. These arise from the notions of "lazy

evaluation" and message-based systems.2 For example, the primitive procedure

PREP

takes

two arguments: one designates the first element of a sequence, one the remaining clements. If all of the elements of a sequence were designated by first arguments in

it would be possible to extract those designators one by one.

PREP

applications,

For example, suppose we

**consider the expression:
**

(IF. (PREP (BLOCK (PRINT 'HI) ST) (PREP (BLOCK (PRINT 'THERE) 1) (PREP (BLOCK (PRINT 'HANDSOME) 2) (SCONS»»)

(S4-407)

Under our original defmition of

IF, tllis

would generate an error, since the

~.:OR

is not a

vector. Under IF z it would return 1, but only after printing out all three words. Our current suggestion is that it seems just vaguely possible, given that we know how PREP works, that we might arrange it to print out only

argument

proc~sing.

HI

and

THERE,

given

IF'S

regimen for

It is presumably clear that

~imply

**positing this one extra condition - that procedural would be inelegant in the
**

wittl

reductions fonned in terms of JJREP be treated specially LISP

extreme; we will not consider it seriously. However it does suggest a tack, far from the style of operation) that we V/ill not adopt, but i:hat might further investigation lead to a coherent calculus. The suggestion would be to require of all sequence-designating terms that they be able, in general, to yield nonnal-form designators for arbitrary elements (or, to take a more restricted

CHse,

**for their first element, although this would not solve
**

PREP

IF'S

problems: we would need to rlavc them handle the first three). Thus rails would do this by nonnalising only that element (they are easy); would (to it by normalising only its first argument, if the first clement was asked; otherwise it would pass the buck to its second argument, with the index reduced by one appropriately, and so forth. "fhe question, of course, is what general procedures would do with such a request (it

is easiest to think of tllis architecture under a messagc-pCllJsing metaphor). Many, such as

**the primitives for addition and so forth, could legitimately complain (cause an error), since
**

. '''',4

there is no reason they should be asked such a question. User-defined procedures would

4. 2-lISP: A Rationalised Dialect

Procedural Reflection

372

pass the query to their bodies, so the question would need to be decided only on the primitives. A crucial question is what

BLOCK BLOCK

should do. It is not that the answer is open -rather, the question is whether it makes sense.

there is indeed only one possible answer -

**would clearly have to process in standard fashion all but the last expression within its
**

54-406,

scope, and then ask the appropriate question of the final tenn. Thus in the example shown

above in

all L'lree

SETS

would happen, before the rail

[X Y Z]

would be asked for a

normal-fonn designator

of

its first (or Nth) argument

It is illuminating to examine the consequences of this suggestion on the examples we have raised, and also to look at another example that is isomorphic, which we used as if it

were well-defined in

54-267

above, as tile

ANO:

proverbi~

"astute reader" will have noticed.

That example had to do with

in section 4.b.iii we rather blithely assumed that a term

**of approximately the· following structure
**

(AND. (MAP EVEN [1 2 3 4 6]»

(54-408)

LISPS

**was well-defined. However under normal assumptions (i.e., in traditional
**

LISP)

and in

1-

**conjunction was defined to process only as many arguments as were necessary until a
**

AND,

false one vIas encountered. Under the obvious definition of

**given below, we would
**

54-408

NTH.

**encounter the problem we have been fighting with the conditional: an error because
**

(MAP EVEN [1 2 3 4 6])

would generate (Once again we

is an ill-formed argument for

**ignore type-checking for perspicuity.)
**

(DEFINE AND!

(54-409)

**(LAMBDA IMPR ARGS (AND- ARGS»)
**

(DEFINE ANO·

(S4-410)

(LAMBDA EXPR ARGS (COND [(EMPTY ARGS) $T] [(= 'SF (NORMALISE (FIRST ARGS») SF] [$T (AND- (REST A~GS»]»)

This definition would support the

follow~ng:

>

(AND J ( • t 1)

(54-411)

(BLOCK (PRINT 'HOlvDY) $F)

(BLOCK (PRINT 'STRANGER) $T)) HOWDY

> SF

but it would fail on 54-408. We could define an alternative follows

(AND-

ANO z,

by analogy with IF 2, that

**checked to see whether the arguments were a rail, and if not pre-nonnaliscd tltem, as
**

can remain unchanged):

**4. 2-LISP: A Rationalised Dialect
**

(DEFINE AND z (LAMBDA IMPR ARGS (AND· (IF (= (TYPE ARGS) 'RAIL)

ARGS

Procedul'al Reflection

373

(S4-412)

(NORMALISE ARGS»»)

**This would give us
**

(ANO z . (MAP EVEN [1 2 3 4 6]»

::;a..

SF

(54-413)

while preserving

>

(ANDl

(-

1 1)

(S4-414)

**(BLOCK (PRINT 'HOWDY) SF) (BLOCK (PRINT 'STRANGER) S1J) HOWDY
**

generate~

> SF

but it would also

> (AND2

• ~(TAIL

1

'[(BLOCK (PRINT 'NO) SF)

(S4-416)

(- 1 1)

> SF

(BLOCK (PRINT 'HOWDY) $F) (BLOCK (PRINT 'STRANGER) $T)])) HOWDY STRANGER

**With these general examples of the problem set forth, we can return to the suggestion that
**

PREP

**reductions be dissectable. The problems with this proposal, however,
**

.

**are rather far-reaching. Suppose, for example, that <x> was an expression that we believed
**

,.

designated a sequence, and from which we" wanted to extract a designator for the first

element

**Suppose in addition that this pre-processing of <x> effected a variety of side
**

tllC

effects on the resultant context. We may presutne that this altered context would be passed

back with

designator of the first element However another structure would have to be

**created as well, if the remaining elements of the sequence were ever to be detennined. For
**

example, if <x> were

(BLOCK

(SET X (+ XI» (SET Y (+ Y 1» (SET Z (+ Z 1»

(54-416)

(PREP

x (PREP

Y (PREP Z (SCONS»»)

**then it would be unacceptable, if a normal-fonn designator of the second element of the
**

resultant sequence were ever sought, for the three incremcntations to be repeated. This is

**true even if acceptable closure mechanisms and so forth could be introduced to keep the
**

contexts straight. For what this approach is driving towards is a company of generators, with conversations back and forth about pieces of their

rt~spcctive

domains.

The static

4.

2-LISP:

A Rationalised Dialect

Procedural Reflection

374

seoping protocols of

2-LISP

facilitate this kind of programming, as has often been noted.3

but to make clear sense of the partial nonnalisation of sequence designators would require substantial extension of the governing protocols over this underlying behaviour.

**Such extensions are not properly part of our current investigation, so we will pursue
**

them no further. What we are left with is a partial solution: we will adopt IF 2 as the primitive 2-lISP conditional, since it deals with half of the troubles with If 1 and, being a

pure extension of tllat conditional, it does not alter any behaviour obtainable with the simpler version. There is a question as to whether we should adopt ANDz as well, in place of the simpler AND 1• On first blush, this would seem consistent; on second blush we realise that AND is not a 2-lISP primitive, and therefore we don't have to decide: we can let the user choose whichever he or she prefers. But yet further consideration should make it evident

tllat AND cannot be adequately· defined as an

IMPR

in

2-lI5P

at all, for the reason we keep

mentioning regarding the use of free variables.

In particular, suppose we adopt either

definition of AND given in

S4-409

or

54-412.

Even as simple eXaInple as the following will

**generate an error, because x will be unbound:
**

{LET [[X 3]] (AND ST (= X 2»)

(54-417)

**The fannal parameter which, when given to section 4.d.iii). 111us
**

AND

ARGS

**in the definition of AND will be bound to the rail
**

AND

[$T (+ X 2)],

NORM/~LISE,

**requires for its successful treatment the environment that (as do all
**

IMPRS -

**was in effect at the point of normalisation of the call to
**

all

sfction

adequate intensional

AND!

AND

awaits

J-lISP

also. If we are to hAve an

in

2-LISP -

of either

or

AND z

variety - it would seem that it too will have to be as a macro. The following code,

primitive.

Fortunately, this is not the case: we can define procedurally-intensional conjunction in intensionality of the primitive macros.

IF,

t~nns

AND

**in particular, the details of which will be explained in section 4.d.v, will define a of
**

IF.

In other words, given the procedural

**we can "piggy-back" similar abilities off it wiUt the use of
**

AND z

**This definition is of the
**

A~D3

variety:

(S4-418)

(DE FINE

(LAMBDA MACRO ARGS (IF (= (TYPE ARGS) 'RAIL)

. ',....

(AND3~

ARGS)

4.

2-LISP:

A Rationalised Dialect

'~(AND3

Procedural Reflection

375

t,ARGS»»

(54-419)

(DEFINE ANDa• {LAMBDA EXPR [ARGS] (IF (EMPTY ARGS) '$T

'(IF ,(1ST ARGS) ,(ANDa* (REST ARGS»

SF»»

**For example, the following three expressions: {ANDa • (MAP EVEN [1 2
**

(AND3 )

(AND3 A B C)

a 4 6]»

(54-420)

**would expand into the following expressions:
**

~(AND3·

(IF A (IF B (IF C ST SF) SF) SF) t(MAP EVEN [1 2 3 4 6]»

staightforw~d;

(54-421)

$1

The1irst and last of these arc

the second w?uld first normalise to (we make

use of the fact that llormal-form reductions can simply be substituted into an expression in order to demonstrate a }Jartially processed term, as in the A-calculus):.

~(AND3

'[SF ST Sf $T SF])

(54-422)

**which in turn would normalise· to
**

~'(IF

SF (IF ST (IF SF (IF ST (IF SF

sr)

SF} SF} SF) $F)

(54-423)

**which, though ungainly, is semantically justified, and would utlimately yield the proper SF. The use
**

OF

macros will be explained

mor,,~

fully in section 4.d.v.

3-lISP'S

1F t AND,

It is striking,

**however, to notc in the present context that once we have
**

abilities, we will need no primitive reflective functions at all.

primitive reflective

LAMBDA

and even

will

be straightforward uscr.. definablc reflective procedures (IF can be defined witll respect to a

**primitive but non-procedurally intensional conditional). Once again our analysis has shown that
**

2-LISP

**is not on its own a calculus with natural boundaries. style) conditional, which we now give:
**

IF J )]

(S4-424)

**One task remains: to demonstrate the proper meta-theoretic characterisation of our revised
**

(I F2

~[Eo("

=

**[AE.AF.AC . C("(IMPR Eo [PRED A 8J (IF J PRED A B),
**

[A<5 1 • E1 , F1)

•

if [51 E RAILS]

**4. 2-lISP: A Rationalised Dialect
**

then

~(NTH(1.S1.Fl),El,Fl'

Procedural Reflection

316

E.F)]

A[Eo{"lFJ )]

.

**[A<Sz.Dz.Ez.F z) • ~(NTH{ [if D then 2 81 se1f -'02 then 3] ,51' F2 ). 2 Ez.Fz.[A<53.D3.E3,f3) . 03])]) else ~(Sl.El.Fl.[A<Sz.D2.E2.F2>.1f02 1 thon Oz2 else °2 3 ])]
**

(54-425)

= AS 1 ·AE 1 .AF 1 ·AC .

then

if [51 E RAILS]

~(NTH(l~Sl.Fl).E.F [A<Sz,D z.E z .f 2) •

**if [5 2 ="$1] then 81se1f [Sz="$F] then
**

r

~(NTH(2,Sl.F2).E2.F2'C) ~(NTH(3.S1.Fz),E2.F2'C)])

else }:(Sl.El.Fl. [A<Sz,Dz.Ez.F z>

l'

elseif [NTH(l.Sz.Fz)="$T] then

[NTH(l.S z .F z)="ST] then C(NT~~{2tS2.F2).E2.F2)

C(N1H(3.S2,F2),E2.f2)]~

A final comment, in passing. This example of interactions between de-referencing,

nonnalisation, and

IMPRS

illustrates rather vividly the hnportancc of working through a full

language design under a set of design mandates. It is straightforward to argue for a design principlt: like the normalisation mandate and full category alignment, but the ramifications of such a position

ar~

rarely evident on the surface. For CXElplc, the current difficulty has one about argument objectification,

that until this point had seemed compatibilc in execution

arisen over the interaction between two decisions and one about normalisation -

**and spirit. The moral is this: although working out the fine grained details of a dialect of
**

LISP

**might seem a distraction from more important theoretical purposes, particularly the and many arc in
**

3-LISP -

kind of aesthetic detail on which we are spending such time, this example more like it that we will encounter before we have delivered a satisfactory suspects that we have been seduced into unnecessary technicalities.

fact crucial to the overall enterprise. All this by way of encouragement to any reader who

4.

2-LISP:

A Rationalised Dialect

Procedural Reflection

317

**4.c. Methods of Composition and Abstraction
**

We said in chapter 2 that a IISP system is best understood as comprising three types

**of faciliCes: a set of primitive objects, and methods of composition and abstraction over
**

these primitives. The first of these aspects of 2-lISP has been presented: in section 4.a we introduced the primitive structural types, and in 4.b we defined those primitive procedures

**that are defined over those structural types. In the present section we tum to the second
**

and third kinds of capability; facilities for the construction of composite entities, and protocols enabling composite objects to be treated as unities. Under this general topic will fall discussions of LAMBDA and closures, naming and variable use, the defining of procedures, the use of environments and global variables, a discussicn of recursion, and so forth. The discussion iIi this section will focus on object lev ,1 matters words, that do not involve meta-structural machinery. .

LAMBDA

Oil

issues,

ill

other

**Thus, although we will discuss .
**

EXPRS;

**terms, we vliIl by and large restrict our attention to the creation of
**

~NiIt

although

we will examine code that uses closures, Yt'e will not consider programs that mention diem.

The general subject of meta-structural facilities of 2-LISP be considered separately, in

section 4.d

**4.c.£ Lambda Abstraction and Procedural Intension
**

Atoms, as we said in section 4.a, are used in 2-LISP as context dependent names. We also made clear, both in that section and in the discuss;on in chapter 3, that they are taken to designate the referent of the expression to

w~ich

they were bouud. Finally, we

have said that they will be statically scoped. It is appropriate to look at all of these issues

with a little more care.

The semantical equation governing atoms ·was given in section 4.a.iii; we repeat it

here:

\IE E ENVS, F E FIELDS, C E CONTS, A E ATOMS [l:(A,E,f,C) = C(E(A),4JEF(E(A»,E.F)] (54-430)

If we discharge

tilt: u"e of the

abbreviatory

cfl, this becomes: (S4-431)

**VE E ENVS, F E FIELDS, C E CONTS. i\ E ATOMS [l:(A,E,F,C) = C(E(A),
**

~(E(A),E.F,[A<S.O,El.Fl> .

0]),

4.

2-lISP:

A Rationalised Dhliect

Procedural Reflection

378

Because all billdings are in normal-form. the above equation can be proved equivalent to the following:

\IE € ENVS. F € FIELDS, C € CONTS, A E ATOllS [:E(A.E,f,C) • l:(E~A).E.F.C)]

(54-432)

**This is true because, if E( A) is normal. then it will not affect
**

it

ule E

and

F

**that are passed to
**

con~equcnce.

Nonetheless,

54-431

must stand as the definition;

54-432

as a

. What

W~

**did not explain, however. is how environments arc constructed.
**

tt'

The

auswer, of course, has first and foremost

do with A"binding.

A

fun account of the

significance of atonlS and variables. therefore. must rest on the account of the significance of A-terms. J.... A-tenn is, in brief, an expres:ion that dcsign&tes a function. Structurally, it

is aay reduction (pair) fanned in terms of a

(~esignator

**of the pr:mitivc lambria closur~
**

LAMBOA,

(':tld

th:-ee argume!

~.s:

a procedure type, a paralneler

!i~"

**and a body e:Apressiofl. The pririlitive
**

although

**lambda c)osu.e is the binding, in the h'litial environment, of the atom
**

e' -her

tha~ EXFR

**there is nothing inviolate about this association. The procedure type argument is typically
**

or

!Mf~~ ~

**we will discuss what these
**

occurc~::es

t~i01S

mean below. The parameter list is

**a pat .ern against which argunlcnts arc matched, and the body expression is an e:.prcssion
**

typicaUy, conta\ns

of the variables named in the parameter pattern. Thus

W~

**are assuming A-terms of the follCJwing fonn:
**

(LAL_.DA <PROCEDURE-TYPE> <PARAMETEI'S> <BOOY»

(54-433)

We have of course usrd >..-tenns throughout the dissertation, both in

LISP

and in our

meta-laliguagc. We must not, how\;vcr, be misled by this familiarity into thinking we either

**underswnd or have encoul1.tcrcd the full set of issues havin3 to do
**

For this reason we will assume in the follow:ng discussion that time introduced. In this spirit, we do wcr to start with

~omc

WitJl LAMDDA

abstract:Jn.

LAMBD."

is being for the first

'1xamptcs of the usc merely as

embedded

definitions,

tr

ternl~

(i.~.,

**without any of the complexities of global variables, top-level
**

in the A-calculus:

rcc~rsiont

or the like): 'fhcsc examples arc sinlilar in structure to the khld of

n. that can be

cXP1~'~scd

«LAMBDA EXPR [Xj (+ X

I,) 3)

4

(S4-434)

**4. 2-lISP: A Rationalised Dialect
**

«LAMBDA EXPR [F] (F (F 3 4) (F 6 6»)

+)

Procedural Reflection

379

(54-436) 18 (54-436)

({LAMBDA EXPR [G 1 Gzl (G 1 (- (NTH 1 '[$T]) (NTH 1 ['ST]»

IF

54-434

(G 2 '[10 20 30]»)

[30]

I-LISP

(G 2 [10 20 30])

(lANBOA EXPR [R] (TAIL 2 R»}

**is a standard example, of the sort
**

(+ X 1»

**would support: the expression
**

54-436

(LAMBDA

EXPR [X]

designates the increment function.

**illustrates the usc of a
**

2-LISP

**function designator as an argument, making evident the fact that Finally.
**

S4-436

**shows that procedurally intensional designators
**

EXPRS.

LAMBDA

(If)

is higher order. can be passed as

arguments as readily as

the

fa~t

**There is nothing distinguished or special abou( these that
**

lAMDUA

**cxprc&<:ions, other than
**

LISPS

**designates a primitive closure
**

lAMtlDA

Unlike standard

and tile original

A-calculus, in other words, the label

**is not treated as a syntactic mark to distinguish
**

LAMBDA terms in

2-LISP

O'le kind of expression froiTl general function applications.

are

reductions, like all pairs, in which the procedure to which LAMBDA is bound is reduced with a standard set of arguments.

**We, win S{'c below that
**

54-437

LAMBDA

is initially bound to an

intensional procedure. but, as example

dcmo!1stratcs, this fact docs not prevent that

**closure from itself being passed as an argument, or bound to a different atom:
**

«(LAMBPA EXPR [F] (F EXPR [V] (~ Y V»~)

LAMBDA) 6)

10

(54-437)

It happens that

EXfiR

**also nantes a function; thus we can cven have such expressions as:
**

(54-438)

**«(lAMBDA EXPR [FUNS] «NTH 2 FUNS) (NTH 1 FUNS) [V] (+ Y V»~) [EXPR LAMBDA])
**

6)

=0

10

Finally, as usual it is the nonnal-form closures, rather the.tn their names in the stand&rd

environment, that arc primitivrly recognised:

**> (DEFINE STANDARD eXPR) > EXPR
**

. "'At

> (DEFINE > BETA

BET~

LAMBDA)

(54-439)

**4. 2-LISP: A Rationali~ed Dialect
**

) ((BETA STANCARD [F] (F F)) TYPE) > 'FUJtlCTION

LAMBDA,

Procedural Reflection

380

**in other words, is a lunctiolJllt. a function whose range is the set of functions:
**

~ ~

(TYPE LAMBDA) (TYPE (lAMBDA fXPR (X] (+ XI»)

'FUNCTION

'FUNCTION

(54-440)

Similarly,

EXPR

is a function, although we will show how it can be used in function position

only later:

(TYPE EXPR)

=>

'FUNCTION

(54-441)

**Though the examples just given illustrate only a fraction of the behaviour of LAMBDA
**

that we will ultimately need to characterise, some of the most important features are clear.

First,

LAMBDA

**is first and forenlost a naming operator: the procedural import of LAt~BDA tenns
**

oth~r LISP

in this or any

arises not from

lAMJJDA,

but from general principles that permeate

structures of all sort, and from the type argument we have here made explicit as lAMBDA'S . . first argument We will explore the procedural significance t)f LAMBDA tenns at length, but

**it is important to enter into that discussion fully recognish.g that it is the body expression
**

that establishes that procedural import, not

LAMBDA

itselt:

Second_

LAMBDA

is

iL~lf

**an intensional procedure; neither the parameter pattern nor
**

LAMBDA

the body expression is processed when the

**reduction it itself processed. This is clC<1f
**

the atoms bound when the pattern is

LAMBDA

in all of the foregoing examples: the paranreters -

matched against the arguments, as discussed below - are unbound, but the

tcnn

is

**does not generate an error when processed. l'his is because neither neither the pattern nor
**

the body is treated as an extensional argument. (L,ess clear, although hinted by the fact that the Iype

argumen~

54-438,

to

LAMBDA

is processed at reduction time.)

Further evidence of this procedural intcnsio:iality with respect to the second and third argument position is provided in this example:

**> ((LAMCDA EXPR [FUN1
**

>3

(54-442)

---A-

(BLOCK (PRINT 'LAST) (FUN 1 2)) (BLOCK (PRINT 'SHOE) +)) SHOE LAST

**In other words processing of the argument occurcd be/ore processing of the body of the
**

designates is applied.

**tcnn. The body of a LAMBDA tenn, in other words, is processed each time the function it
**

This fundamental fact about these expressions will motivate the

. so that expressions of tile form (54-446) [<paramt> <argk>]] <body» .. 54-443 would vf course reduce to 4.. (argk» LET". similar to the I-LISP macro of the same name. III particular. is because the Y in the body of the lexically last A-tenn in the example (the second last line) receives its meaning from the context in which it was reduced (a context in which Y is bound to 1) not from the context in which tile function it designates is applied (a context in which Y is bound to 2). <paramk>] <body» <argt> <argz> . there is a sense in which the context of use of a LAMBDA red~ctioJl affects the behaviour of the resulta. The expression in LET 54-443 is undeniably difficult to read. (S4-446) Similarly. the atom is bound to a function that adds 1 to its argument. we have the following: «LAMBDA EXPR [FUN] «LAMBDA EXPR [V] «LAMBDA EXPR [V] (54-443) 2» (FUN V»~ 1» (l~A8DA EXPR [Xl (+ FUN x V»~) l~his In other words. however.4.nt procedure when it is lIsed. we will define a "sequential (LET· [[<paramt> <argl>] [<param2) ( ar 02>] called LET·. particular.vii). to abbreviate the usc of In embedded lAMBDA terms of this fonn (this LET will be defined in section 4. We will adopt a 2-lISP macro.. expressions of the (LET fo~ [[<paraml> <argl>] [<param2> <argz>] [<paramk> <argk>]] (54-444) <body» will expand into the corresponding expression ({ LAMBDA EXPR [<paraml) <param2> . 2-LISP: A Rationalised Dialect Procedural Reflection 381 semantical account In spite of LAMBDA'S intensionality.d. In a dynamically scopcd system.

one protocol is ta"catcd this It is not our policy to accept behavioural accounts - committed to being able to answer such questions as "Why do these scoping regilllenS behave the way thaI Ihey do?" and" Why lvas sIalic scoping defined?". ~ffcct. the other that. however. . can be recast (LET [[fUN (LET [[V 1]] (LAMBDA EXPR [X] (+ X V»~]] (LET [[V 2]] (FUN V»~) l'he behaviour evidenced in 54-443 (54-460) 3 and again in 54-450 is of course evidence of 4 what is caned sIalic or lexical seoping.a"islns and/or behaviour.XI)]] V»~ (S4-449) => 1 LETS Although some of the generality of LAMBDA is lost by using this abbreviation (all LET·S. Dynamic and static scoping.. The expression in using as follows: for example. The difference between these two is illustrated in: (LET [[I 1]] (LET [[X (+ XI)] [Y (. and for example. will employ LET and LET- forms rather widely in our examples. we said that LAMBDA was ill tensional.> may depend on the bindings of the pa. . but this example makes it clear that it is not hyper-intensiollal. 2-LISP: A Rationalised Dialect Procedural Reflection 382 will expand into the corresponding expression «LAMBDA EXPR <paraml) «LAMBDA EXPR <paramz) «LAMBDA EXPR <paramt) <body» (argt» ) (arOl) ) (54-447) (ark z» ) Thus each <aro. f"ortunately. if 54-443 reduced to the nunlcral we would say that dYllalnic or fluid scoping was in way.Y.4.ameters before it. 1)]] V»~ ~ (54-448) 0 (LET [(X 1]] (LET* [[X (+ XI)] [Y (. the way we have come to look at this issue brings into the open a much deeper characterisation of . are by we' are and large described in tenns of I1lec}. in other what is happening.purely as a structural or textual objcct It is not the case. LET arc assumed to be EXPR lambda's). we 54-443.~ In particular. in tile sense of treating its main argument the body expression .

what is bound to is neither the body as a textual entity. but we have ~fhcy not adequately answered the question "What do Ihey mean?". If we had an adequate theory of intcnsionality. we have no such theory (furthermore. such that no two pairs coincide in their first clement. that is clear. Rather. nor the result of processing the body. We know what application is: a function applied to an argument is the second clement of that ordered pair in the set whose first clclnt. • .· dynalnic scoping to a hyper-illtensiollal abstractioll operator.4. Sadly. However none of this elementary knowledge sugg~sts any relationship bctwccr. designate functions.nt is the argument. as a substitute for the word term 'ro treat it so would yield an answer of 4 FUN - the textual objcct "(+ x would imply dynamic seoping. we need to retreat a little from the rather behavioural view of LAMBDA that we have been presenting. designating the function that is signified by the A-abstraction of the given variables in the expression that is its "body" argument. what we will show is that LAMBDA. It is all very well to show how LAMBDA tcnns behave. is a coarser-grained LAMDDA. as we made clear cariicr. a somewhat more complex story has to be told: from textual objects ollio LA~'BDA is of course a function junctions. 2-LISP: A Rationalised Dialect FUN Procedural Reflection 383 words. in the third line of the example "FUN" consists in the replacing. It is an object closer to the intension of the body at the point of original reduction. a function and a function designator. furtllcrmore. But the crucial point to realise here is tllat a statically scoped which is what we have. it would be tempting to say that LAMBDA was a function from textual objects (the body expression and so forth) onto the ill/ension of those textual objects in the context in force at the time of reduction. Of whatever intermediate tenn was chosen as proper to usc for combining functions-in-intension with arguments) this intension with tile appropriate arguments. but rather something intermediate. that the application of the function bound to Y) It. The subsequent use of such a function would then "reduce" (or "apply". that functions arc sets of ordered pairs. In order to understand this claim in depth. and look more closely at what Aabstraction consis!8 in. intensional procedure than is a dynamically seoped Slatic seopillg corresponds to an ill/ensional abstraction operator. We do have a consensual intuition about A.that it is an operator over a Jist of variables and expressions. those functions preserve the intension of the textual argument). We know.

but on the referent of that designator. Predicates arise natural:y from a consideration of sent~nces containing blanks. just as a predi~ate term is a senlence with a hole in it It: for example. In general. and delete the first designating term. and A- abstraction in general. and thus crect the entire notion of function with which we are so familiar. 2-LISP: A Rationalised Dialect Procedural Reflection 384 However this intuition must arise independently. of coursc. of questions arise. we take the sentence "Mordecai was Esther's cousin". some of these constructed sentences will be true. in the blank with any of an infinite (pcrha~s) d~signatc in picking out a unique referent. a raft. the resultant composite noun phrase will another object. we say that the object so selected is in the range of the function. by filling in the blank with a variety of other designating tcnns. In those cases where the resultant phrase ~ucceeds COU/ltry ilnediale/y 10 the south 01__ ". the situation regarding designators .4. also. 'I'thus if we take a complex noun phrase such as "the :ountry ilnedia/e{v to the south of Ethiopia". The fundamental intuition underlying LAMBDA tenns. and therefore requires independent motivation and explanation. It is easy to imagine constnlcting an infinite set of other derivative sentences from this fraglnent.is entirely parallel. and some will be false. by filling. for example. is that we arc led to a function of more than one argument. Thus for exarnple we might construct "Aaron was l~'slher's cousin" and "the person who lives across the Bord was /J'sther's cousin" and so forth. the object designated by the phrase \ve put into the blank is in the donlain. and remove the final constituent noun phrase. What if the. the tnlth or falsity hinges not on the actual form of the designator. In the simplest case. if we construct llVO blanks? TIle answer. 'Inc fonnat paranlctcrs arc a Incthod of labelling the holes: if one parameter occurs in morc than one positiun \vithin the body of the lanlbda . Once the basic direction of this approach is admitted. we get the open phrase "the set of possible noun phrases. noun phrase we wish to delete occurs more than one'. Thus our example sentence is true (at least so far as we know) just in case the supplied designator refers tc Mordecai: any term codcsignativc with the proper name "Mordecai" would serve equally well. What happens.and tIle resultant functions . (as fi>r example the tenn "lchabod" in "The first persoll to like lchabod and lchabod's horse'1? "Ine pov:cr of tJlc A-calculus can be seen as a fonnal device to answer all of these various questions. can be traced back at least as far as Frege's study of predicates and sentences in natura11anguage. Once again. A A-term is in essence a designator with a hole in it. then we obtain the expression " __ was Esther's cousin".

If I excise tile noun "Bob'~ and construct the open l~ " __ is going to vote for the President's oldest daughter".~ sense of "stat~d" or "introduced" . it is natural to assume Lhat I refer to the President's oldest daughter. for exalnple. What docs this ~uggcst regarding IISP? Simply this: that the natural way to view lanlbda tenns is as expressions that designate functions. that while writing this paragraph I utter the sentence Bob is going to vote for tlte President's oldest da\'Jghter".4. 2-lISP: A Ra~onalised Dialect Procedural Reflection 385 expression. is the natural context of use of that open sentence? If it is being used to define a function. The ground intuition is unarguably extensional. Again staying with the II simplest scntenc~ cas~. It is instructive to review this history. then I have constructed the simplest a prcd\cate true of people who will vote for Maureen Reagan. to suggest that we take the whole designator itself intensionally. And so on and so fortIl . In addition.all of this is familiar. Thus we have achie /cd a stance from which it is natural to ask essentially syntactic questions about the fundamental intuition (indeed. suppose we want to define a function. This . then the only us~d conceivable answer is that it is to be understood in the context where it is to the define the function. where the function designated is dctclmincd with respect to the context of use where the lambda tcnn is used ("used" in the .not where the function it designates is applied). . and most straightforward reading. then tokens of the formal parameters stand in place of a single designator that had more than one occurrence. then more than a single noun phrase position has been made "blank".se how synlQc/ic a characterisation this is: \ve have talked almost completely about signs and expressions.1l" Dilly at that point. even though we realised that the semantical import of the resultant sentence depended (in the simple extensional case) only on the referent of the ingredient noun phrase we inserted into the blank.. if nonetheless coherent. we may ask. and functions were derivative 9 on the original syntactic mano('uvcring. The ~ll'\ctract notions of predicates. known by the name hMaureen Reagan". If there is more than one fannal parameter. Note for one thing how the function of LAMBDA as a pure naming operator becomes clear. for it leads us to a particular stance on some otherwise difficult questions. relationships. and do so by using some composite tenn in{o which we insert a blank. What. at least. "rhis. It is undeniably more complex. Supposc. so that when we Gsk whether the resulant predicate is true of some persoll lve will deten1Zille the referent of the phrase tIthe Preside. it is because we want the answers to syntactic questions that we are pursuing this line). For examplc. it is important to recogni. in some context.

In this regard it is instructive to look at reduction regimen adopted by Church in the A-calculus. However it remains the 0P~l unexamined what role is played by the flill computational significance of the tenn in "body" position - rtcsignator with demarcated blanks in it. In sum. not that function that to its Cli'gumcnl the referent of the sign "y" in the context of usc of the designating procedure. then. lbere is no reason to propose a substitutional procedural regimen. 2-lISP: A Rationalised Dialect Procedural Reflection variable~ 386 leads us to an adoption of statically scoped free but only because we can show It is no accident that Church how that mechanism correctly captures this intuition. We saw in chapter 2 how the s!atic reading leads rather naturally to a higher-order dialect. It would be crazy for us t<J propose a substitutionai reduction regime for a formalism with procedural side-effects - 2-LISP since. This was not a problem for Church because he of course had no side-effects.JA tenT•• we realise that the preceding discussion argues only that the extensioll of the LAMBDA term be dctcnnincd by the context at the point where the LAMBDA term was introduced. rather than whal his mechanism was for. we must be true to the understanding that his calculus embodies.n that chapter examine a subject we must now consider: the illlellS. in the . but of course no theory of functions-in-intension accompanies the A-calculus. to unifonn processing of the expression in "function position" in a redcx. As far as it goes. By the discussion just advanced. employed static scoping when he defined the A-calculus: slatic scop. as we have said. we will insist that the tenn (LET [[V 1]] (LAMBDA EXPR [X] (+ X V»~ (54-461) add~ designate the increment function. . it should depend on an intensional LAMBDA. to use our present tJ1C reconstruction. which.sm. every OCf:urence of a variable in a procedure would engender another versh n of the side-effects implied by the argument expression. Nor did 'He exanline explicitly lAMB. is a statically scopcd higher order fonnalism.4.lnd so forth.ng is the IlUesl formal reconstruction of the linguistic intuitions and practice upon which the no/ion a/A-abstraction is based In order to remain true to Church's insight. though we did not i.Gnal significance of a llJat this last question rClnains open is seen of use in for~c '~ihen th~ underlying scmantical motivation for this panicular choice. for this would mimic his 11lechan. this is simple. Nor is "A".

(AF . example. since this p-redur. and then a valid p-reduct1on. Second. there is that very important rule llaving to do with variable capture. so that it is not possible in general and unpredictable ways to capture an expression from one context and to slip it into the course of the reduction in some other place "behind the back of the reduction rules". the following is an incorrect series of p-rcductions: For (AF. The dictum a few pages back said that hyper-Intensional abstraction corresponds to dynamic seoping (and intensional abstraction to lexical seoping). called p~reduction a-reduction. The reduction regime. It is a constraint on - tile main redurtivc rule in the calculus - that terms may not be substituted into positions in such a way that a variable would be "captured" by an encompassing "A-abstraction.«(AG. A-terms in the A-calculus.ve presented in chapter 2 {the lexical item "A". and there is no way in which an appropriately intensional function c\)uld be defined within its boundaries. a function. is one of substitution. (54-452) Rather. This is an illegal derivation . in the lambda calculus.(Af. FF) ) F» . are substituted one within another during the reduction of a complex A-calculus telm. Actual textual expressions. 2-LISP: A Rationalised Dialect Procedurdl Reflection 387 A-calculus. as they were in the first version of I-LISP .{AF. since the A-calculus is strictly an extensional system.ti~n is incorrect. in fact. af\er all. which would superficially appear to be a hyperintensional kind of practice. How then can we defend our claim of intensional abstraction in a statically seoped formalism? The answer is that the A -calculus is llighly constrained in certain ways which enable hyper-intensional substitution protocols to mimic a more abstract intensional kind of behaviour.tation mechanism).(AH.FG» (AF.4.(AU. are demarcated on its own uninterprcted. there is no QUOTE primitive (and of course no corresponding disqu(.«AG. (54-463) .~ flO tat ionalIy.«~G. one Inust first rename the parameters involved in such a fashion that the capture is avoided. If sue11 a capture would arise. rfwc features contribute to this nbility. furthermore. so to sp~ak. like the It. one must Ufo': an instance of a-reduction to rename the inner F so tllat the substitution of the binding of G for G will not !nadVerLcntly lead that substitution to ubet:omc u an instance of the inner binding.HG» (AF.FG» (AF . is and right parentheses and the dot). F» F» Thus the following is corr'~ct: (AF.HF» This is a legal derivation first we do an a-reduction. First.

V. If one takes the intension of an expression to be the function from possible worlds onto extensions of U. is why the reduction in 54-462 is ruled out - why dynamic scoping is so carefully avoided. 2. cwis 5). does not preserve intension generally. Sure enough the Church-Rosser theorem wOl£ld not hold.. and is bOllnd to the rail (CARDINALITY PLANETS) Then might reduce to the numeral 9 if CARDINAlIT' was defined in tenns flf LENGTH. since p-reductions with no a-reductions is one way to view lISPS LISP 1.at express. "nine" necessarily designates On such an account the reduction of (CARDINALITY . the number nine in this language. It is the view of this author . according to a common sense notion of intension. that the atool PLANETS [MERCURY VENUS EARTH . terms must. but.-lISP: A Rationalised Dialect Procedural Reflection 388 The precise and only role of a-reduction in the A-calculus is to rc-arrange textual objects so as to avoid the dynamic scoping that would be implied if a-reduction did not exist The questiol1 we may ask. if there were a different number of planets.. The answer cannot be that the resulting system is incoherent. one can therefore simoly decide rather arbitrarily on one reduction order. More specifically. however. the most serious of which is that we don't have a theory of intension with respect to which to formulate it. variable capture alters intension We have. in a sense. designates the sun's planets." that this violates lay intuition - that a more adequate treatment of intcnsionality shoud be finer grained (perhaps of a sort suggested by l .4. for two reasons. ~an LAMBDA preserve the intension of the body expression. as have shown. it is difficult to know whether intension is preserved in a reduction. attributed by the intuitive understanding of the significance of the original A-term.6 and all its descendents. without specifying the intensions of the pritnitive nominals in a LISP system. then. Suppose) for example. the following result the reduction of thereby violating intention. This is difficult to say formally. Furthermore. This of course is a much stronger result the overarching mandate that it preserve designation in every case.ion. Thus (SQRT 4) and would be considered intensionally equivalent to SQRT 2 (providing of cou~e \¥c are in a context in which designates the square-root func' ~ In). It is argued that the phrases "the Ilunlber of ]J[allels': and "nine" are wher'~s intensionally distinct because "the Ilulnber of planets" might have designated some other number. But we now have an answer: it violates the claim that the fonnal apparatus retains the designation. on the other hand. PLUTO]. io eaell poss~ble world - the approach taken in possible world sCnlatltics and by such then it emerges (if one believes that arithmetic is not contingent) (+ 1 1) theorists as ~Aontague4 - that all designators of the same number are intensionally equivalent.

~'!~acter of the expression over which the L 4MBDA LAM8!JA term abstracts be preserved in the function dei.gnator to which the level this will be our guiding mandate. example that we v/ill make use· of later. All that we are bound to ensure i~ this: that the intensional c. The issue is best introduced with a. hut of course control and field effects are similar) take place . a procedure defir ·ri on.. Furthermore. if ali we ask of the reduction of LAMBDA tenns to Honnal fonn is that intension be preserved. but should be processed at another time. But making this preciee is not our present subject matter.[[X 'THERE] [Y (r~INT (54-466) X)11 V)~ > $1 (BLOCK (PRINT 'IN) THERE IN (54-467) > ST ) (L£T· [eX :THERE] [Y (LAMBDA EXPR [] (PRINT X))11 (BLOCK (PRINT 'IN) (Y»)) IN TJlERE illus~ratcs Whut this example is that the side-effects engendered by a term (the input/output behaviour is illustrated here. rather than simply using it. if an expression <x> should not be processed at a given time. It is a ·Nidely appreciated fact that. with respect to LAMBDA tenns we have a much more precise set of questions to answer. having to do with the :elationsilip between the intensional content of a IISP expression and its computational significance. in the second it happens aflerlJ > (LET [eX (PRINT 'THERE)1] (BLOCK (PRINT 'IN) X)) THERE ) $1 !! (54-464) > (LET [[X (LAMBDA EXPR [] (PRINT 'THERE»)]] (BLOCK (PRINT 'IN) (X»)) IN THERE ) ST (54-465) Because of 2-lISP s:tatic seoping (which corresponds to this intensional reading of LAMBDA). A simple example i. 2-LISP: A Rationalised Dialect to 9 Procedural Reflection 389 PLANETS) is not intension preserving. illustrated in the foll n ·lving two cases: in the first the (PRINT 'THERE) happens before the call to (PRINT' IN). a standard technique is to wrap it ill . this approach can be used even if variables are involved: ) (LET. we do not have to reify intensions at all . At the declarative However. term reduces. ..4.. aDd then to reduce it subsequently.we do not even have to take a position on whether intensions are things.

The QUOTE function in 2-lISP that we defined in 54-132.4. (Note that no suggcstior. since there are no side"effects at all. Thus in (+ 2 3). it is on our view not the case that and 6 are intensionally equivalent. which when applied to a syntactic designator of a sequence of two numbers. and handles in general. Both of these possibilities are rejccted by protocols we have long (< f> . 2-lISP: A Rationalised Dialect Procedural Reflection 390 only when the term is processed in an extensional position. neither (I>( X) is a function from expressions onto intensions. Similarly. since accepted. If x is a term (LAMBDA . It is for this reason that the "deferring" tcchnique works in the way that it does. ). to we said that the whole designated five because the atom "+" designated the extensionalised addition function. We have one more question to examine before we can characterise the full significance of LAMBDA. ~n nor 'l'{ X) is an intension. [2 3]). Such significance arises only when some other function or context requires an extensional reading. previously been forced to ask the question of what happens with respect to intensional operators. In other words if LAMBDA takes an intensional reading of the body expression. this constraint: intension"preserving term transfonnations do not engender the procedural consequences latent in an expression. Though (+ 2 3) (+ 2 3) reduces to co--exlensionsal 6. yielded their sum. are hYPer"intensional operators. it is not other words. <args» (54-468) «LAMBDA <type> <params> <body» . those consequences emerge only during the nonnalistion of a redex. it was clear in their situation that the significance of the mentioned ternt was not engendered by the reduction of the hyper"intensional operator over the tenn. nor is it the case that terms to intensions. ifl any expression . we have assumed that the <F) significance of the whole arises front the application of the function designated by which is in reality (+ . note that in any form the argunlcnls <A>. In particular.. is afforded by the A"calculus with respect to this concern. but the examples just adduced yield an answer: they too do not release the potential significance of the term. In spite of our claim that the case that LAMBDA LAMBDA rcdut::~ LAMBDA is an intensional operator. We have no~ however. when intension is not preserved. it does not thereby engender the full computational significance of that expressio:l.) We have concluded. <A». in other words..

but they arc presumably not syntactic. is It remains. "Ibis is all consistent with our requirement tllat variable (LAMBilA . This is as much as we will say regarding LAMBDA in its simple uses. however. the closure nonnnliscs to :<.4. must be co-designative. )]] (F • < arg s >)) F (S4-469) must also designate a function. against the parameter pattern. environment that was in force at the point when the closure was constl11ctcd. ) binding be designation preserving: Fan\. When a pair whose a non-primitive closure is encountered. and an environment arguments - If the closure is an CDR IMPU. As usual. as \vell as extensional.. In accord with LAMBDA our general approach. but augmented to include the bindings generated by the pattern Inatch of . as usual. terms primarily in terms of 'I' what they mean. that Hence (LAMBDA . structural entities.. however. to remark on hOlV they work. and '" has F s as its range.. The normalisation of LAMBDA terms. . We said earlier. no argument normalisation is performed. 2-lISP: A Rationalised Dialect (LAMBDA. They are that F no~ in other words...argunlcnts against variables. in a construct liKe (LET [[F (LAMBDA . followed EXPR. what \VC call reduce(J with the arguments. instead a handle designating the of the pair is Jnatchcd In either case the body of the closure (the body of the original reduction with LAMBDA) is processed in a context tllat.. cannot normalise to a designator of that function's intension. a closure CAR (see below) is constructed and returned as the result. from this we justified our account of how they behave. in other words. ) It follows. is Ulis: it is the as usual there is no structure to the usc of fields: a single field is merely passed along throughout the computation. finally. For we do not know what intensions are. If that closure is an CDR of the pair... ) f cannot designate the intension of the tenn. then this reductiun bcgins with the reduction of the by the binding of the variables in the parameter pattent against the resultant normal-fonn argument designator. The answer to the latter question is of course quickly stated:" when a LAMBDA reduction is itself processed.. (LAMBDA . we have attempted to characterise subservient to I).. preserve intcllsion as wen as extension. then.n Procedural Reflection 391 it follows that the tenn must designate a function Similarly. elements of S. consists of a field The field is the field that result'i from the processing of the The environment. that must be intensionally similar to the LAMBDJ\ Inust LAMBDA term - what this brings out is CO" must be co-intensional with the term.

Fo: we do not know what intensions arc. from this we justified our account of subservient to~. finally.. This is as much as we will say regarding LAMBDA in its simple uses. instead a handle designating the of the pair is matched In eitllcr case the body of the closure (the body of the is processed in a context that. The nonnalisation of LAMBDA terms. as usual. normaliscs to a non-primitive closure is encountered. We said earlier. then. .. cannot nonnalise to a designator of that function's intension. that Hence (LAMBDA . however.. in a construct {LET [[F (LAMBDA . consists of a field "fhe fieJd is the field that results from the processing of the The environment. con of the pair. but augmented to include the bindings generated by the pattern match of arguments against variables. against the parameter pattern. 'I' what they mean. (LAMBDA . is It remains. original reduction with and an environment. in other words.. This is all consistent with our requirement that variable F bindi. 2-lISP: A Rationalised Dialect (LAMBDA . When a pair whose arguments. 11lc answer to the latter LAMBDA question is of course quickly stated: when a reduction is itself processed. ) F cannot designate the intension of the term.. to remark on how the)1 work. a closure CAR (see below) is constructed and returned as the result. They arc that F no~ in other words. and 'I' has s as its range. ) and (LAMBDA . environment that was in force at the point when the closure was constructed. structural entities. Similarly. but they are presumably not syntactic. the closure is what we call reduced with the then this reduction begins with the reduction of the If the closure is an CDR IMPR. must preserve intension as well as extension.. that Iriust be intensionally similar to tile LAMBDA term - brings out is must be co-intensional with the LAMBDA term. If that closure is an EXPR. ) must be co-designative. ) Procedural Reflection 391 it follows that the tcnn like must designate a function. arguments LAMBDA) no argument normalisation is pcrfonned. )]] (F • <args») (S4-469) F must also designate a function.. we have attempted to characterise LAMBDA !zOlV terms primarily in terms of As usual. followed by the binding of the variables in the paralllcter pattern against the resultant nonnal-form argument designator.4. is this: it is the as usual there is no stnlcturc to the Use of fields: a single field is merely passed along throughout the computation... elements of F s..g be designation preserving: It follows. In accord with our general approach. what this however. they behave. as well as co-extensional.

lacking such a theory. and could avail ourselves of an intensional operator in the meta-language. armed with tIle mandate that it is the intensional properties of the resultant structures that are of primary concern. . we will instead look at from the point of view of designation and reduction. 2-LISP: A Rationalised Dialect Procedural Reflection 392 If we were equipped \vith a theory of functions in intension.4. But. called tCfiilS I NTENS ION-OF t that mapped and lists of fonnal parameters into intensions .we could LAMBDA specify the desired semantical import of LAMBDA in its tenns.whatever they might be .

then if we store those two things (or store infonnationally complete designators of litem) we are guaranteed to have preserved sufficient information to reconstruct the context and LAMBDA tenn originally employed. Secondly. Also. Closures: Nonnal-fonn Function Designators Two questions press for resolution.. We said in sectiol1 4. since we do not have the theory of intensionality called for in the previous section. which. but for the time being this . This is lvhy closures contain ellcodings of enVirOll1tlClltS.c. ) designate the function designated by the lAMDaA tenn. was some function of the context of use and tIle textual term in body position. One purpose of the discussion in the immediately preceding section. and.a.vii that we wOf ·" ~ use pairs as the structural category for such tenns. we said in section 3. was to convey as sense of what closures must do. tile answer is clear: if we know that the -intension is a function of these two things. we said that we would define as a closure any tenn that meets these various conditions. But. We wanted thcln to encode within themselves the identity of the intension of the funtion designated. among others.4. and (LAMBDA . if we know how to move in a single step from textual item plus context plus arguments to the full reduction. c. of LAMBDA'S First. 2-LISP: A Rationalised Dialect Procedural Reflection 393 4.i argued that normal-fonn function designators should be intensionally equivalent to the LAMBDA tenlS from which they arise. In other words. If we had a theory of intension we would not need to define them in this fashion.er: what is the fonn of normal-fonn function designators? OUf over-arching nonnatisation mandate requires of us that expressions of the fonn normalise to a term that meets the constraints on normal-formcdness. ii. "come back through again". Section 4. we need to formulate an alternative account semantics. we can be sure we have preserved the proper intensional properties if we can back up to an equivalent hyper-intensional fonn plus context..f:ii that we (~mploy would the Donnal fonn designator of the EXPR function as tlle structural item in functional position. so to speak. then if we have preserved the entire context when we wish to apply/reduce the intension we can pretend we are working in the standard extensional situation. examine just what 2-LISP We need to closures arc. we need to answer a question we have side-stepped numerous times in this chapt. Finally. though we don't know how to reify intensions. when put this way. as we pointed out.

<PATTERN> designates the parameter pattern. it should be admitted that the inclusion of structural environment designators within closures will prove extremely convenient when we discuss the question of changing a closure to designate a different function.) rfhc fonn of a closure. It is rather inelegant. 2-lISP: A Rationalised Dialect Procedural Reflection 394 approach must suffice. Thus even 3-LISP would be cleaner if a computable and finitely representable intensional object were forthcolning.4. should This is the case when f. (On the other hand. in accord with new definitions of constituent functions.iii bears repeating: environments have up until this point been objects in the SelllQIl/ical domain of the theoretical tneta-!anguage. then. being a tenn in a theory of enter the discussion as a word that is used at a meta-level. The notion ellVirOll1nent. What we said in section 3. as the reacier should be aware. LISP. not in either s or D. against all of our methodological principles. as they do here in LISP. 2- and as they properly ought not to do. <ENV-O> <BODY> is an environment designator. In other words. Thus this theory-relative encoding has its apparent advantages. However. will be this: «EXPR> <ENV-O> <PATTERN> <BODY» (S4-465) where <EXPR> is the EXPR closure. possible to argue at this time that a more adequate intensional encoding would not provide similar benefits. among others: environments. In 3-lISP this encoding of environments within closures is not quite as inelegant as the SllUdow of the SaIne in 2-lISP. as we have been at pains to say again and again. however.nvironments (along with continuations) are bound to variables by reflective procedures. It is not.f. designates the body. and For both consistency . because structurally encoded theoretical accounts of the processor playa major role. our lack of a theory of functions-in-intension forces us to have closures encode environments within them: this is the meaning of the underlined EXPR Eo tcoo that occurs as the first argument to 2-LISP in all of the closures presented throughout the earlier parts of this chapter. However environments also cnter into closures at the object level. arc theoretical posits with which we have made sense of behaviour: never before have environments entered into our actual domain of discourse. However even there there remains a slight inelegance - lack that plagues us here. the object-level structure of the language will be theory-relative (thus fundamentally challenging our operating assumption that a higher-order meta-structural dialect can be obtained in a theory-free fashion). for the LISP'S following reason.

in the initial environment. 2-LISP: A Rationalised Dialect Procedural Reflection <EXPR> 395 and elegance. we said I-LISP would be bound. in other words. top-level definitions.ii. EXPR: We first give an admittedly circular definition of . Thus we would expect: «EXPR> 7 '[N] '(+ N 1» (54-466) (LAMBDA EXPR [N] (+ N 1» The question regarding the stnlcturc of environment designators was answered in section 3. bindings. Thus th. Since the second and third arguments to nofmal~form <EXPR> designate structures. with each sub-rail consisting of two handles. when we take up global SET. l~he first will be answered only in section 4.vi. the first designating tile atom. to have as normal-fotID redexcs only those (EXPR> rcdexes whose arguments are themselves in nannal-form.c general environment designator will be of the form: [['(ATOM 1 > '(BINDING t >] ['(ATOM?> '(BINDING z>] (S4-467) ['(ATOM t > '<BINDING t >]] Two questions remain. we have chosen to have all the arguments to the closure ingredients. they will in the case necessarily be handles. lbus both of the "pseudo-c:omposite" structural types pairs and rails nonnal~fonn CDR will be in nonnal-form only if their "ingredients" are in normal form CAR (although there is an asymettry in the other direction: an)' rail whose elements are in is by definition itself in Donnal form. It enables us. to a closure of the structure following stlucture (this is the straightforward 2-LISP translation of the pictured in 53-200): (54-468) ~Iowcver we can fill this out no\y more explicitly. whereas not every pair whose and are normal is itself nonnal). environment designators are rails consisting entirely of two-element rails.4.c.fJi: since environments are sets of ordered pairs of atoms and ~indings. and there that the atom EXPR The second was sketched in section 3. and about the form of (EXPR). about what environments are actually in force. and the second designating the binding. furthermore.f. in thjs way <EXPR> designate can be itse~lf an EXPR.

to avoid tile explicit reduction of EXPR in the function position of the recursive (circular) call to EXPR. this more clearly suggests the normal-fonncdncss of this foml. implying that the closure would expressions must be considered as prior to.4.'lis fonn: EXPR => «EXPR> Eo (54-471) '[ENV PATTERN BODY] '(EXPR ENV PATTERN BODY» as illustrated in the following graphical notation: (54-472) ~PATTERN~ EXPR It is truer to the primitive nature uf this closure. 2-lISP: A Rationalised Dialect (DEFINE EXPR (LAMBDA EXPR [ENV PATTERN BODY] (EXPR ENV PATTERN BODY») Procedural Reflection 396 (54-469) There is however a difficulty primitively by the processor. a fact that is determined (LET [[X t(LAMBDA EXPR [N] (+ N 1»]] (= (NORMALISE X) (NORMALISE X») (54-470) => $1 which is not predicted by 54-469. for other purposes 54-469 Thus the self-normalising aspect of nonnal-form is adequate. or perhaps more accurately Thus we have: an incompleteness here. the definition just given. Closures are in normal-fonn. Thus we will assume the following primitive <EXPR> structtlre: EXPR ~ «EXPR>!~ (54-473) '[ENV PATTERN BODY] '«EXPR> ENV PATTERN BODY» again as illustrated in graphical notation: . and not captured in. however. Nonetheless. EXPR be of t. therefore they are self-nonnalising.

It is clear. we need to look again at LAMBDA. LISP There being no mechanisms for this.4. furthermore. that this argument position plays a potentially much larger role in determining the significance of a LAMBDA tenn. OUf approach. we will instead present a (circular) 3- definition in pseudo-3-lISP. 2-LISP: A Rationalised Dialect Procedural Reflection 397 (54-474) Given this characterisation of EXPR. they merely mediate between the" reflected level and the fact that the closure must itself be an object level expression): (DEFINE LAMBDA . In that dialect we wilt be able to define a function called (DEFINE INCREMENT (LAMBDA MACRO [Xl '(+ MACRO to support such definitions as: (54-476) . in particular. x V»~ (S4-477) . of this procedure is that it must do something without precedent: it must somehow reach into the workings of the processor and extract a true designator of the environment in force at the point of reduction. the following (the up and down arrows can be ignored for the present. We said earlier that LAMBDA. we have used "EXPR" or "IMPR" almost as if they were keywords selecting between simple extensional and intensional procedures. A striking example where this power is used is in the 3-LISP definition of MACRO.the difference is merely that in the mechanisms by which the result is obtained are mechanisms provided to the user. even circular. and facilitates the use of other functions in this position. 3-LISPish (LAMBDA REFLECT [[TYPE PATTERN BODY] ENV CONT] (CONT ~(~(NORMALISE TYr~ ENV ID) ENV PATTERN BODY») (54-476) This definition leads us to an examination of the role of the first argument to LAMBDA. ~ . however. The problem with presenting a definition. In every example we have used so far.x 1» with the consequence that the nOffilalisation of the fonn (INCREMENT (. We have. for the result is the same . though procedurally intensional. was nonetheless extensional with respect to its first argument. means tllat no keywords are needed..

although whereas EXPR was an EXPR. Finally. identical to the is also an EXPR closure.4. we should inquire about IMPRS. TIle inclusion of the environment within a . Strikingly. the IMPR closure is almost . and IMPR Inorc carefully. One final comment needs to be made before we turn to characterising the semantics of lAMBDA.t (LAMBDA EXPR [ENV PATTERN BODY] (IMPR ENV PATTERN BODY») and this structure to the primitive IMPR => IMPR closure: (54-481) «EXPR> Eo '[ENV PATTERN BODY] '«IMPR> ENV PATTERN BODY» as illustrated in graphical notation: (54-482) Note that since <IMPR> is an EXPR. In particular. we have this approximate definition: (54-480) (DEFINE IMP. will be examined in chapter 5. . IMPR is not an IMPR: IMPR EXPR. We will not pursue any uses of the type argument to definition of MACRO. 2-LISP: A Rationalised Dialect Procedural Reflection 398 will engender the subsequent normalisation of the explicitly constructed expression (+ (* X Y) 1) (S4-478) The definition in 54-476 shows how this will proceed. t11at closure will construct and normalise the appropriately instantiated version of the schematic expression given as the body in 54-476. EXPR. its job is clear: it must yield an intensional closure such that when reduced.x 1» MACRO (54-479) 1110ugh we do not have enough machinery to define a suitable yet. the and other extensions. The normalisation of INCREMENT will lead to the normalisation of (MACRO <ENV> '[Xl "(+ . the body of the IMPR closure is not an intensional rcdcx which would be declaratively wrong. LAMBIlA in this chapter.

It is for this reason arc exanlples) allow one to specify. tenn was reduced. example we have the following behaviour: (LET. but it is worth mentioning here.iv. it is defined as a reflective procedure that It can as well wreak side-effects on wreaks side-effects on environment designators.vi) a straightforward utility procedure that will facilitiate tile construction of closures that explicitly protect themselves frOID the effects of subsequent modifications to the variables used freely \vithill them. which is critical in .:ngth in section 4. The ability to modify the function designated by a closure (strictly. instead.[[X 3] [F (LAMBDA EXPR [V] (+ Y X»]] (BLOCK (SET X 4) (F 2») F (S4-483) => 6 was originally bound to SET. LAMBDA the however. ~ closure designating a function that adds three to its argument. those variables over which a tenn should be closed. in virtue of SET. thus altering what functions they designate. modifies the binding within the closure as well. We said carlier is not a primitive in 3-LISP. In particular. to change what function a closure designates by changing the closure itself that SET there is no meaning to the notion of actually changing a function) will prove useflJl in reflective work. It is at least arguable that this is not always the behaviour one desires. 2"lISP: A Rationalised Dialect Procedural Reflection 399 closure interacts with the ability of SET to modify environments in force. then the binding of x at the point of reduction of the that some dialects (INTERLISP and SEUS would hold independent of subsequent alterations to that environment.4.. in tenns of intension explains why: if we could map LAMBDA OUf analysis tenn terms onto more stable LAMBDA intension encodings. However in our own defense we should add that we will be able to define (in section 4. This topic will be pursued in greater lr. through some LAMBDA other mechanism. What our present analysis has shown us is how this vulnerability to the subsequent modification arises out of our lack of an adequate intension operator. since it affects the environment in which the tenn is closed. closures. suppose that some LAMBDA body uses variable x freely: then the binding of x will be that of LAMBDA the environment in force when the variable. in such a fashion that subsequent alterations to the binding of that variable do not affect tile closure itself. Subsequent changes to that Thus for may potentially modify the closed environment.c. "Ibis ability is inlportant to provide an example is the ability to redefine procedures used by closures.c.

2-LISP: A Rationalised Dialect Procedural Reflection 4CO debugging and program development cOllfused with the nonnal use of SET However we will argue that it should not be in tile object level of a program.4. .

but there are a variety of formal we could use to implement them. in any of the following ways: (LAMBDA EXPR Z (+ (1ST Z) (2ND Z» (LAMBDA EXPR A (LAMBDA EXPR B (LAMBDA (~ (54-486) A 8») (54-486) EXPR [A 8] (+ A B» (54-487) In the first we have reconstituted the template expression. one for each blank. a fact to whictl term nleans. For example. what a rail of two alOlllS in a parameter position of a . At first blush the third would seem to do so as welL since it conveys the impression that a procedure defined in this way would have to be called with exactly two argument expressions. mentioned earlier.v. to be filled by two occurences of the same designator.a hole. AX. As discussed in section 4. in this way we can retain the machinery that accepts a single argument In the second we use two separate abstractions. over both the "3" and positions. that we usc in our meta-language. the second approach fundmncntally conflicts with our objectification mandate.4.«fX)(GX» ]ltus.c.holes to be filled by different designators me~hanisms ~ arise in a natural way. Thus it would appear that the objectification mandate would force us to adopt the first of the three suggestions. We said above that multiple arguments . in spite of its fOlmal generality. A-abstraction uses a single formal parameter to mark the hole or holes in the composite designator. we could abstract this. if we consider addition. 2-lISP: A Rationalised Dialect Procedural Reflection 401 4. in other words. On the other hand the third candidate is manifestly the most convenient immediate intuition and standard LISP practice both attest. and the second abstracts the "4" position. In the third we apparently extend our syntactic mechanism to support two arguments in a seemingly obvious way. and tlle use as our source template "4 If term (+ 3 4). so that only a single hole remains (altllough there are two occurences of it).a. in the expression (54-484) a single x marks two occurenccs of the same hole . This is the "currying" approach. LAMDDA however. Thus the first abstracts the "3" position. It remains to he explained.iii Parameter Patterns and Variable Binding In the original intuition.

a mandate we will call the sc!lematic desiglUltor principle is this: The patter~ if used as a designator ill the envirOnnle/l1 resulting froln the binding of a procedure's [onnal para111eters. while making it semantically like the first.say. TIle general mandate governing the binding . no sense is to be made of binding a rail. to extend this to a multi-argument casc. if some function AX.an abstract mathematical ordered set of arguments instead..then we would expect the parameter x to be bound to the numeral Thus a subsequent use of tile term x would (+ 1 2) designate thc number three. Thus we will encounter such terms as: (LAMBDA EXPR ARGS .4. 1 2) -. In t110se cases where the natural conception is of a function applied to multipie arguments.. which is just what switch to 2-lISP) designates. In particular. the pattern as a whole detcnnines how the parameters are bound. the function will in fact be applied to a single sequence . will be LAMBDA allowed to be built up out of atoms and rails.iv.a. the atoms within it will be the parameters themselves. however... The parameter structure in a lAMBDA term.GX F was designated by tIle A-term (54-489) (+ and F was reduced with some other expression . should designate the full argument to which the function is applied This mandate is of course satisfied by the paradigmatic single argument case. 3. It is of course only the parameters tllat are bound. 2-LISP: A Rationalised Dialect Procedural Reflection 402 A little investigation will show us that we can adopt the third candidate syntactically. ) (LAMBDA EXPR [[X] Y [[Z W R]]] . ) (LAMBDA EXPR [A B C] . Nonetheless. We have already said that every 2-LISP (and 3-lISP) function/procedure is called witll a single argument - this was made clear as early as section 4. that we had instead the more complex function designator (we ... given a particular designated argument. ) (54-488) We will call the entire parameter strucnlre the paranzeter pattern or pattern. 1be approach emerges from the realisation tltat the binding of variables or formal parameters is an extremely simple case of pattern matching. Suppose.

The fact that it is the designated sequence that drives the destructuring. as (REST [10 20 30]» MAClISP (S4-493) Furthclmore. of course. is the overarching constraint. although. even mandat~d by the fact that F is an EXPR. A C) (. but we can still usc it to define the principal protocols. and this was used as follows: (F (+ 1 2) 4) (S4-491) then. Because of the intension-preserving aspects of the binding of parameters to normal-form argument expressions. 8 0») (54-494) (REST [10 20 30]) (REST [6 16 25]» 1050 . at least. "de-structure" sequences of arguments. this is in developments wilt be organised. It is of course both simple and elegant to enable this dc-structuring to rccurse: thus SODl. Thus the parameter pattern may. not the structure of the argull1ellt designators. around \vhicll other we could have: «LAMBDA EXPR [[A 0] [C D]] (+ (. . since 54-491 is a lexical abbreviation for (S4-492) (F .~. it adequately treats what in spreads").4. are called lEXPRS (INTERLISP "no- It should be clear just why this freedom arises: The relationship between argument structures and para1?leter structures in extensional procedures has only to do with designation. That bindings be to norma/- larln designators is discuss later. as we will 3-lISP REFLECTS) IMPRS (and receive their bindings in normal fonn. [(+ 1 2) 4]) F would be applied to a sequence of the two numbers (three and four). grants us just tile freedom we wanted to enable us to use non-rail for example in the expression (+ • CORS without colliding with the binding mechanism. The only nonnatY fonn bindings of x and such that 3 [X Y] would designate this sequence arc of course that tIle x be bound to the nUlneral and y bound to numeral 4.· no (annal relationships between the two are of allY consequence. 2-lISP: A Rationalised Dialect (LAMBDA EXPR [X Y] (G X (H V»~) Procedural Reflection 403 (S4-490) bound to F.e cases violated. TIlis. to use popular terminology.

This pattern matching binding protocol is of course not new in its surface fonn. We also n~ed to indicate the consequences of calling a procedure with a sequence that is longer than that potentially designated by the parameter pattern. should be possible to omit the explicit quotation implied in the rail/sequence distinction. the pattern should match if and only if the first and third argument of the sequence arc identical. we could then allow explicitly t~at Ignoring for a moment [A [)] in place of 54-496. On its own. no binding of x or y can render sequence of the first three natural numbers. ).s doesn't answer a number of crucial questions. the schematic designator mandate. it would have to be added the order of parameters should match the order of arguments.4. a "list of variables" would in our example. The latter suggestion is ruled out. There are a variety of questions that arise in any multiple argument scheme. Nor does it ~e explicitly . to take as But there is of course something odd about this. however. answers them in one sweep.. In this "list of ~nd variables" approach all of these complexities would require private explication LISP specification. In the former casc. th. as ['A '8] (54-496) tlll. however. this is a decision that . We have not explained the significance of multiple occurcnces of the same atom in the parameter pattern. or facilitate the use of a single atom parameter when it is desired to obtain a name designating entire argum~nt sequence. thus it is arguable that it 54-496. tile schematic designator mandate supplies answers. for example (in (lAMBDA EXPR [X Y xl . We have admitted that the "parameter pattern" argument position to LAMBDA is inherently intensional. couped with the fact that all 2- procedures are semantically called with a single argument. of which only two have been mentioned in the foregoing discussion. First.ldmit of recursion. as illustrated for example in «LAMBDA EXPR [X Y] (+ X V»~ 1 2 3) (54-496) 117 Again. but it is instructive to follow out just a little the consequences of the scmantical way we llavc tlcfincd it Note as well that we have in 2-lISP "[X Y]" a designator of the six structural types.:- view with the one we have 54-490 2-lISP be represented as.. We bind only atoms. 2-LISP: A Rationalised Dialect Procedural Reflection 404 It is sometimes thought that the fannal parameter section of a procedure consists merely of a "list of variables". for example). It is instructive to contrast adopted.

1 2) (== 1 2» (54-497) 'OK but is impossible in this case: «LAMBDA EXPR ['X Xl) 3 4) (54-498) because 'x designates tile atom x. however. and can in no environment designate the number three. for example. so that two occurenccs of a single variable could be treated in the obvious fashion. then such a facility would be of interest Such a calculus. as the rait examples have made clear.2 2) (+ 2 2» x v»~ 0 (S4-499) to bind x to 4 and y to 0. as would be required in order for this to be meaningful. While admitting the possible extension of our dialects in such a direction. however. For example. 1 2) (+ 1 2) (. should fail: (54-600) «LAMBDA EXPR [X Xl 'OK) 3 4) But this is a different language. ha~dles. with the choice based on tile possible matell between their parameter patterns and the argument structures. of which three (booleans. We might want. in the sense that they designate their referents independent of context Thus if one of them were to appear in a pattern. yielding as a result The following. 2-LISP: A Rationalised Dialect Procedural Reflection 405 W~5 long ago fixed in the dialect However it does not follow from that fact that only may occur in patterns. lbere are in particular four categories of ~tructural object to be considered. given the mandate just laid out. and numerals) are constants. . 11lus the three constant structural categories will for the present be ruled illegal in parameter patterns. so that at a given step in the course of a computation a variety of procedures could potentially be reduced. the governing mandate could apply only in case their referent was the very semantical entity in the designated argument. rfhe ability to usc constants in parameter patterns is probably not useful in a serial language. If 2-LISP were a pattern-matching formalism. the mandate could be satisfied in a reduction of the following form «LAMBDA EXPR [X 3 Y SF] 'OK) (.4. the reduction of «LAMBDA EXPR [X Y Xl (I (* 2 2) (. It is therefore worth atOJl·~:i exploring what would be implied by occurences of other structural forms in parameter patterns. might want additional facilities. we will not adopt these suggestions here.

thus in • This is not 2-lISP 6. This is not 2-lISP yet (54-504) (LET [[(CAR B) (+ 2 3)]] <BODY» The question.of reductions - in a pattern. should we decide to support it. The schematic designator mandate provides a strong guiding principle. is what sort of sense to make of this last proposal. First. In standard debate has arisen over complicating the binding protocols. examples in particular illustrate its force.4. Suppose first that we had a procedure F 'fwo defined as fGllows: (DEFINE F (LAMBDA EXPR (PREP X Y) <BODY») (S4-606) and we used it as follows: (F 10 20 30) (54-606) The principle requires this: that x and y be bound so that mathematical sequence <10. (PREP x Y) designate the fact that it No mention is made of other computational tllC thus we arc free to ignore (for the moment) . would look instead like: . it LISPS. One school has argued for destructuring similar to the rail proposal we have adopted: thus in such a proposed LISP. B) (CONS 3 4») <BODY» • This is not 2-LISP (54-601) would bind A to in SETF 3 and B to four. 2-LISP: A Rationalised Dialect Procedural Reflection 406 Of much more interest is tile use of pairs . is of course a consequence of the separation of pairs and rails that the question is open. (LET «(A. The opponents have suggested on the contrary that non- atomic structures in binding position be treated rather like the intensional functions we saw in chapter 2. even though we have admitted arbitrary de-structuring by rails. (LET «(CAR B) (+ 2 3») <BODY» (54-602) either the CAR of B would be bound to or else the CAR of B would be nlade 6 (implying a RPlACA) (we will consider these two possibilities in a moment) In 2-LISP we of course have approximately both options. 30). then. rIbe first (54-501) would result in: (S4-603) (LET [[[X Y] (SCONS 3 4)]] <BODY» whereas the second (54-502). significance of (PREP X Y). 20. illustrated by the following examples.

to ensure that x and yare bound to normal-form designators. Another example has to do with the level-crossing primitives We said above that a function designator (LAMBDA EXPR [X. as well. as required. tX. In other words we have a method (should we MAClISP be able to generalise it sufficiently so that it warrants adoption) whereby such fallout of the basic structure of the dialect. since ~'4 designates the number four. 'V] <BODY» F NAME and REFERENT. For example. and . Such facilities could be of use. we used instead (54-609) which is an abbreivation for (LAMBDA EXPR [X (NAME V)] <BODY» (54-610) then our governing mandate requires that the atom Y be bound to sOlne nonnat-fonn designator such that (NAME Y) designate the arguolcnt (F '3 '4) Thus if we used (54-611) and x were bound to the handle •3 and would be equivalent to [. as if . since ' Y can only designate Y. Y \vas bound to the numeral 4. if G were defined as <BODY» (54-612) (LAMBDA EXPR [X ~Y] and used in (G 3 4) (54-613) 3 tileD x would be bound to the numeral and y to the handle •4.X imply that x be bound to the ull-nonllalised argument structure (or bound to a designator of the un-normalised argument structure). Thus x should clearly be bound to the nUlneral 10 and expressions as (DEFUN F (X &REST Y) <BODY» • This is MAClISP (S4-607) y to the rail [20 30].j. without requiring the addition of keywords or other extraneous language elements. of the fann (54-608) would be ruled out.4. We are required. although a variety of cautions need to be kept in mind. 3 (NAME 4)]. none of ·x. Similarly. (LAMBDA EXPR [X tV] <BODY» If however. tllen [X (NAME Y)] t whicll would in turn be equivalent to [' 3 4]. 2-LISP: A Rationalised Dialect Procedural Reflection 407 would generate an otherwisc-inaccesible structure if processed.

is in essence a question of the "fit" or "match" between the parametcr structure and the argument structure.. IMPRS and (and in 3-LISP. we will reject the suggestions just presented. parameter binding in the general case. type"checking in typed languages involves a pseudoIt is our intent not to semantic. First. to match such a rait against a parameter structure. Similarly. It is likely that even a moderate step in this direction would unleash virtually all of the problems associated with unification protocols. for example. It is then a straightforward task. Nor is it in general computable how to assign the open parameters in an arbitrary expression <x> so as to ensure that <x> designate a given semantical entity. we specified in section 4. it might seem that by introducing even a very mild version of pattern matching into the binding of format parameters we have unleashed a raft of potential complications that could have been avoided had we used instead a more traditional "list of variables" approach. in line wittl our general approach. therefore. For present purposes. The second cornlnent is this: the discussion just given.4. Unification algorithms restricted so that only tcnns in one of the two expressions may be expanded could be used. Given the scrnantical type theorem. but there arc severe linlits on such an approach. However any binding protocol is in its own small way a pattern matcher.3 that rails were the normal. specifies binding behaviour. version of matching.form dcsignators of 2-LISP will obtain a rail. \YC particular. directed computation. rather than in tcnns of implemcntable In However it is clear that there is a very natural resonance between the normalisation of sequence designators and the use of rails in parameter patterns. we know that if we normalise any sequence designator successfully. given one proviso: that no single parameter occur more than once within the parameter structure.. Merely the question of whether the procedure has been called with the correct number of arguments. pattem. and 3-lISP 2-LISP parameter patterns will be constrained to consist only of arbitrary combinations of rails and atoms. sequences. but rather to capitalise on the concepts that underly semantically. reflective procedures) stilt need to be employed for such purposes. There are three final comments to be made about parameter binding. rather than purely structural. in tenns of conlputational complexity. and the like. 2-LISP: A Rationalised Dialect Procedural Reflection EXPRS 408 IMPRS a mechanism had been discovered so that intermediate procedures between could be defined. . ~rotocols introduce an otherwise absent notion.

It turns out that in using 2-LISP it is very often the case that.. one wants to bind parameters to designate its elements well). and ARG3 will designate (f CD). if it is not. we will adopt one extension that violates the schematic designator mandate endorsed earlier. . 2-LISP: A Rationalised Dialect Procedural Reflection 409 At any step. In other words. checking only that they are of the same length. the pattern must be a rail. is that "t ARG 1 to tIle handle •B. defined as follows (DEFINE TEST (LAMBDA IMPR [ARGI ARG2 ARG3] . we will adopt the following extension to parameter matching: a rail of sub-patterns in a pattern will match an argument expression if the parameters can be bound in such a way as to designate the referent of the argument expression. but since this kind of binding is nonetheless useful. tIlen this result \vould follow automatically. What we intend. only possible parameter pattern that could designate it is a single ATOM . if we could view rails simply as sequences of structures. consider the intensional redex (TEST A 8 (F CD» (54-614) This is of course an abbreviation of (TEST . and we recursively match each element of the rail against each elelnent of the argument rail. in a major concession to pragmatics. rather than more particular rails of structures. we have assumed throughout that we could asume. we simply need to check whether the paramatcr is an atom.witll would be bound to the handle •[A be bound to the handle tAt ARG2 B (F CD)]. However "schematic designator" mandate of course fails: the argument expression is the rail the result that ARGS [A 0 (F C D)]. but there are others as For example. given a rail (MACRO R. we bind the whole normal-form argument designator to that atom. ARGS . (54-616) » S4-514. [A B (F CD)]) (54-616) If TEST is an intensional procedure. and to the handle '( FeD). should the referent of the argument expressions be a rail. then we would be able to engage in tllis sort of practice without extending our matching protocols. ARG3 however. and IMPR procedures are typical cases. however. ARG2 that tile ARGl will the will designate B. on processing designate A. Since raits arc not sequences.. If rails were sequences. Third and finally.4. or to designate the sequence of clements of a rail. if it is.say.

rails of handles) with sequences - it: in other words. it is compatible in spirit with the use of operators on sequences NTH paradigmatically over rails as well. we will find it convenient to allow "'<X>. then. For example. Our new matching protocol. In addition. Thus one way to describe this extension is this: just for the purpose of matching. if <x> is a sequence ofdesignators. in other words. It was this original extension that led us to the definition of the semantic type vector in section 4. We will not pursue this suggestion here. adding practical force to the argument for it In particular. It would of course be possible to avoid this extension entirely.4. a (schematic) rail may be viewed as a designator of a vector of either type. and stilt support the desired behaviour. however. to designate a sequence of the clements designated.e.would be generated by the simpler mandate if a designator of a rail of struclures were equivalent to a rail of designators of structures.vii): . for example . as well as the other way around. if we identified rails of nonnal-fonn structure designators (i. which strictly they do not. essentially allows the "referent-of' and "element-of' operators to COln11lu Ie. we should enable rails of designators to be taken as designators of rails. and LENGTH - It does not allow one of them to be by-passed. 2-lISP: A Rationalised Dialect Procedural Reflection 410 Though this is undoubtedly a concession. The bindings that it allows . is effected by the following procedure (taken from the meta-circular processor in section 4.d. note that it does not violate semantic level. In order at least to be symmetric.this backwards commuting of the same two predicates also proves' extraordinarily useful. in the sense that the domain of the "reference" function is being slightly extended beyond s to include sequences of elements of s.those facilitating 54-614. Again this is a pure extension.b. The extension we are adopting. since it would change in a considerable measure the kinds of structural field modifications we would allow. we will allow an expression such as: "'['2 '3 '4] (54-617) to nOInlalise to tbis: [2 3 4] (54-618) Without the convention 54-611 would be semantically ill-formed. which would be considerably less acceptable. This extension . we accepted mathematical identity conditions on these (or indeed on all) rails.vi.

. it will be used in many of our reflective and pre-reflective examples. 2-lISP: A Rationalised Dialect Procedural Reflection 411 (DEFINE MATCH (LAMBDA EXPR [PATTERN ARGS] (COND [(ATOM PATTERN) [[PATTERN ARGS]]] [(HANDLE ARGS) (MATCH PATTERN (HAP NAME ~ARGS»] [(AND (EMPTY PATTERN) (EMPTY ARGS» (RCONS)] [(EMPTY PATTERN) (ERROR "Too many args supplied")] [(EMPTY ARGS) (ERROR "Too few args supplied")] [ST (JOIN (MATCH (1ST PATTERN) (1ST ARGS» (MATCH (REST PATTERN) (REST ARGS»)]») (54-619) Though we will not mention this extension widely.d and in chapter S.4. particularly in section 4.

and INPR EXPR.c. 7he Semantics a/LAMBDA.NTH(1.AC • (54-521) C{"(EoC"EXPR) ENV(E.EXTEND{El. ENVS 1 (54-622) if [A = 51 l than 52 else E(A) In fact we require a more complex EXTEND. EXPR. E.])])]] and the following internalised function: A[Eo(ttlAMBDA)] = AS.Af. We assume a function ENV in· the meta-language that returns a normal.S.iv. and IMPR. E2 • Fz) • }.ASt·AS z • AA E ATOMS s 1 . ~[Eo("LAMBDA)] = AE.> · 0. in the calculus)...F3).S1. . EXTEND would have the following sitnple definition: EXTEND : ~ CC ENVS X S x == AE. for example. fonn designator of an environment.S3).S.F) where EXTEND is a function that extends environments according to the parameter matching protocols.AC.f z • [A<S3.. because we support rail decomposition in the matching process.E z.AF .F3' E. [AS 1 • AE1 · AFl· [A<S2.F) NTH(2.. a correct version of EXTEND will be given below. they are better considered as questions about the use of If all LAMBDA abstraction. If parameters were constrained to be single atoms (as.(S2. the definition of LAMBDA would be straightforward. (54-620) C("(IMPR Eo [PARAM BODY] (LAMBDA PARAM BODY)).F 3 > · ~(NTH(2.AE.F3)..4. We tum in this section to a formal cllaracterisation of the semantics of LAMBDA.F) [A<~4. S J. It should be realised that we do this before we have considered recursion or definitions. as the subsequent discussion will make clear.S1. thus ENV is a function of type CC ENVS x FIELDS J .F) NTHC1.D3 . That we can do so is an important to recognise: the subtleties that come up with more complex naming interactions are to a certain extent external to the notion of LAMBDA abstraction itself. We would have the following full significance of the primitive LAMBDA: 2-LISP procedures were EXPRS.D4.E 3 .F»).E •• F. 2-LISP: A Rationalised Dialect Procedural Reflection 412 4.

F2) . then.Sl.E 3 .Fl' [~<S2. ~(NTH(l.AF.E 3 .F a )])])]) . 03])])]] (S4-526) E.Fl»).F2»])] and the following int~rna1ised function: (54-624) A[Eo{"LANBDA)] :: AS.S. [AS 1 • AEt · AFl.D3. we will adopt a The idea one we 'Yill different strategy from that exemplified in will be to have LAMBDA S4-620 54-621.F). take three arguments. I("(SI HANDLE(ENV(Et. ~(NTH(3.Fl).02. El.F. D El. D3.EXTENO(Ee.F) ~[Eo("EXPR)] = AS. Fl) l. [A<Sz. is the significance and intcrnalisation of .F t ).S.F2. El .AC (54-626) C("(Eo("EXPR) Eo '[ENV PARAM BODY] '(EXPR ENV PARAM BODY)).F.D2 .F z)])]) Thus the import of a term like (LAMBDA EXPR [X] its first argument ~[Eo(~EXPR)] (+ Xl» is carried by the significance of EXPR: Crucial.S.AC • ~(NTH(l. however.AF. definition: ~[Eo("LANBDA)] (54-623) = AE.Ft» HANDlE(NTH(2.St.F) I(NTH(I. [A<Sl.F t .F).AC • C("(IHPR Eo '[PARA'" BODY] '(LAMBDA PARAM BODY)).F 3 > • C("(Eo("EXPR) 51 S2 Sa).F l • [A<Sz.Sp. Fl) .AE.F z> · D2(E2.S2).NTH{2. tile first of which should Thus we will have the following simple designate a function that takes environments designators as well as parameter patterns and body expressions onto functions appropriately.F2).AF .F2).Fl' [A<SZ. Ft) ~(51.Dz.AS b • [A<St. F2> .S. 2-lISP: A Rationalised Dialect IMPRS Procedural Reflection 413 In order to support extend in 3-lISP - and MACROS as well as and EXPRS.Ez.NTH(3.El.[A<Sa. [A<St. I(Sb.AF.F2' [A<S3.Dz. • = AE .St.Fl» HANOLE(NTH(3.E2.F 3 > • C(Sz.S.Ot. E.4.F3> .E 1 .AE.E2.E.S.E z .E3.El. • ~(NTH(2. EI.Ez. [AEc·ASp.E. E2.AC .

and we assume the minimal circular solution. and that designates the designation of the body expression with respect to a context formed by the extension of the enclosing environment to include the binding of the parameter variables to the result of normalising the argument The significance of IMPR is of course similar.S.AE. is recursive: the of the closure returned as its result is itself.F z >• ~(NTII(3. On their own the three pairs of equations (54-623 through 54-628) are not cnougll to discharge our obligations rcg~rding closures: we need in addition to specify the internalised As we have characterised each primitive function signified by Ilon-prinlilive closures. and z are in normal form.01. f l. this is as we expected.S.4. Y Z) will normalise to x Y Z). but a meta-level cross has transpired: ~[Eo("INPR)] = AE. [AE c • ASp. D2. v.Ez. 02])]] (54-628) = AS. (EXPR 1r. a parameter stru~ture sp. and return an application of identical form.D2. Since a LAMBDA term designates the application of this function designated by Eo{" EXPR) to the environment in the context of use at the time of reduction in tcnns of LAMBDA. Fz ) .EXTEND(Ec. and to the parameter pattern and the body. D E3. ~(NTH(l.E2. as mentioned in the previolls section. . F3> • 3.F2> (S4-521) E. Note however that the parameter pattern is matched against the handle of the arguments: thus the bindings remain in Donnal form. [A<S3.AF. and a body Sb. Thus if x.HANDLE(Sl».Fl' [A<S2.F t > • ~{NTH(2. except that the arguments are not processed.Af.E 3 .F z • 51 52 Sa). ["<SI.F a )])]}]) of course. C("(Eo("EXPR) IMPR. EZ. is an EXPR.F) ~[Eo("IMPR)] . this was EXPR predicted at the end of chapter 3. lbis term designates a function of three arguments: an enclosing environment Ee.fl.F).Sp. The EXPR function then designates a standard type of function that nonnalises its arguments. Ft> ~(Sb.Fl). AS b • [A<Sl. It is the designation of Eo{" EXPR) that is important and revealing.El.F.AC . pictured in Note as well that reductions in terms of are extraordinarily sinlple: they (EXPR simply nonnalise each of the arguments. C("(EoC"EXPR) Eo '[ENV PARAM BODY] '(IMPR ENV PARAM BODY)).S. El.E.[h<S2. 2-LISP: A Rationalised Dialect 54-525 Procedural Reflection CAR 414 Note that 53-200.AC .

for any argument and context and continuation. E3. E E EtiVS [[ 5 e = ENV( E)] :J [~r" «IMPR> 58 tlANDlE(Sp) HANDLE(Sb»)1 = ~51·AE1·AFl·ACt [~(5btE·. In chapter 3 we gave a general what we need is a 2-lISP characterisation of A for non-primitive closures in of that equation.Sp.S b E S. 2-lISP: A Rationalised Dialect Procedural Reflection 415 procedure we have set out its internalised function.S p . solution will be even simpler than that shown in We have. E € ENVS So = ENV( E)] :J [~r"«EXPR} Se HANDlE(Sp) HANDlE(Sb»)1 = AS1·AEt·AFt·ACt (54-529) 1I [~(SltEl.F 2> • where 1:(Sb. The fact that the pattern in an IMPR are bound to designators of the argument expressions is reflected in the "HANDLE ($1)" in the last line.Fl. of is intended to apply only to those closures whose The internalised function signified by such a a non-prinlitil'e closure (54-629 internalisation is not otherwise specified). in particular. and body.[A(S3. closure will be the function that.S b E S.Fl' [A<Sz. pattern. An example will show how these equations entail that (LAMBDA EXPR [Xl (+ Y x V» will designate (the cxtcnsionalisation of) an incrcmentation function if is bound to the . the 53-137. version Given the fact that all following: 2-LISP procedures are called with a single argument.F2 . first nonnalises the argument and calls the continuation with the result of normalising the body in an environment which is the closure environment extended as appropriate by binding the parameters in the pattern to the normalised argument The internalisation of non-primitive IMPR closures is similar but simpler.Oz. Ea. as expected: (54-630) VSe. but of course in the general case the CAR IMPR of a redex will reduce not to a primitive closure but to one fanned in tenns of Expn.F 2 )])])]ll where E· is like E except extended by matching UANDlE(Sl) against Sp. E2.F2> · Ct (S2. plus the pattern matching extension adopted at the end of the last section. 53-137. Fa> • C1{S3.4. F3)])])] E· is like E except extended by matchIng 52 against Spa n The idea here is that Se' sp. D3.Ez.D2. and Sb are the environment. (or MACRO once we have introduced that). the '1S e .E·.E 2 . respectively.[A<S2.

F 1 }.F t • [A<Sz.E [A{Sl)]("[EXPR [X] (+ X Y)].Ez. By the general significance of pairs EXPR [Xl (+ x Y)). [ AS 1 . F2 > <52' • ~(NTH(l. [0 [PARAM BODY] (LAMBDA PARAH BODY)))] (S4-636) <"[EXPR [X] (+ X V)].Fi.york now on the internal reductions here: = ([A("(IMPR Et • Ft.Sl.[D 1 ("[EXPR [X] (+ X Y)l.F2>])] ("(IMPR Eo [PARAM BODY] (LAMBDA PARAM BODY)). Et • rA<Sz.E z .F l ) • ID(S2.f 2 > e Oz(E z.NTH(3. .F t ) • l. [A<Sz.[D 1("[EXPR [X] (+ 10. (S4-632) x Y)]).E 1 . .F l ). 2-LISP: A Rationalised Dialect in the environment of reduction.Fl)]~E2.5 2 . E2 .E 1 .E 1 . D t .02. E z> • D (E z .F 2 > <52.NTH(2. ([ASteAEteAF •• I{NTH(1. Eo [PARAM BODY] (LAMBDA PARAM BODY)))] (ftCEXPR [Xl (+ x V)]. [A(Sl)]("[EXPR [X] (+ X Y)].F t • [A<5 2 • Et.Fl) · and discharge the initial binding of by using 54-523 (54-633) • . we reduce 54-633: = ([~("(IMPR Ft . we look at: 416 numeral 1 ~("(LAMBDA (S4-631) where we assume that (S4-38) we have ~("(LAM8DA = 1 and E1 = Eo otherwise. F2 ) I(NTH{1.ID) = l:{" LAMBDA.F 1 • <S2. AE1 • AFl. 2• F2> • D2 ( E2 • NTUe 2.S t .D z .F 1 • [A<5 z .F l )])]) LAMBDA W~ can discard the unproductive that we just set forth: = ([A<St.5 2 • F2) .Dl'~l. when that is complete we will return and expand the internalised LAMBDA function.Sl."[EXPR [X] (+ X YJ].F 1]. (54-534) .F. [A(S2' El . First. therefore.F 2 »])] Z. fXPR [X] (+ X Y)). F2) )])] We will choosu to follow out the designationat consequences first. NTH{ 3.E1.ID) Ei ( "Y) Procedural Reflection In particular.F t ).Ei.E •• Ft» Ez • Fl )]» We can .E 2 .El.E •• F1.Ft. [A<5.E t .» °E 2.E 2 .St. Et • Fl ' [A<Sl.F 2 <"[EXPR [X] (+ X Y)].-.4.f 1 ).E1.

NTH(3.D3 .Ez. " [EXPR [X] (+ X YJ].F z»]). And again.F z>]» [A<S3.Et.F z)."[EXPR [X] (+ x Y)]. El • F1 > • :E(Sl.E z .F 2 )]» [A<S3.F a> • °a])])]] 3. "[EXPR [Xl (+ NTH(3. [AE c • ASp. :E(Sl.F z>]» x YJ].Ft.Dz.an be reduced: (54-638) = ([~("(IMPR Eo [PARAM BODY] (LAMBDA PARAM BODY)))] <"[EXPR [X] (+ X YJ].F2' x Y)].\(SI. 417 Extracting the rail element on ("[EXPR [Xl (+ Et • Fit Ft: = ([~("(IMPR Eo [PARAM BODY] (LAMBDA PARAM BODr)))] x (54-636) YJ].Fi).F z»] <"(Eo("EXPR) Eo [ENV PARAM BODY] (EXPR fNV PARAM BODY))."[EXPR [X] (+ Ez.F 2 > • NTH(3."[EXPR [X] (+ x Y)J.F 2 ). x Y)].F z> Ez.F t »).E z . E2 • F2 > <52. Fl ' [A(Sz. and applying 54-29 governing the general significance of atoms.Fz. [A<S2.F 2 > ."[EXPR [X] (+ X YJ].Ft.S2). <52.NTH(2. [A<S2."[EXPR [X] (+ ~( "fXPR t [A<Sz.F z> .E 3 .Sp.: .Dz .4. D (E z • 2 NTH{2. ([AEc. D E3. [A<SI. in conjunction with 54-626: = ([&("(IMPR Eo [PARAM BODY] (LAMBDA PARAM BODY)))] ("[EXPR [X] (+ X Y}]. 2-lISP: A Rationalised Dialect Procedural Reflection NTH(2. NTH(2.F 2 > • <52. Et. AS b [.F 2 > .Ez.Et. ~(Sb.EXTEND(Ec..F t » Ez.Sp. This significance of f o{ "EXPR) r.F 3 > • D ])])]] 3 <E 1 .AS b .Dz. ~(Sb.E z.S2).E 2 . (54-537) ([A<Sz. plus extracting the second and third rail elements out of F. 02(£2.D z .F z»]).F 2 ). · Et • Ft. E1 • F1 > • .EXTEND(fc.ASp. El. Fl t [A(Sz. El. NTH(3. [A(Sz."[EXPR [X] i+ x Y)].

~("(+ X Y}.Dz.4.E 1 .F t • [A<S2.F z)]» This is as far as the designation.F z• [A<S~. [A<Sz.E3. [A<Sl. 03])])]. " . E!. El. extended with x designating whatever it designates in the caUing context fl. Ft. Ez.EXTEND(Ei. 2-LISP: A Rationalised Dialect m Procedural Reflection 418 ([A("(INPR Eo [PARAN BODY] (LAHBDA PARAN BODY)))] ("[EXPR eXl (+ x Y)l. and then designates the referent of (+ x Y) in the environment EI ."[X]. will go: it is a function thot accepts an argument (SI) and a context (E 1 and Ft ) and nonnaliS\. Fz> • (54-639) <S.~ its argument. in which Y designates I.F3> .Sz).E t .D3..F 1 ) • I(Sl.Ez.F z) .

Ez. ~("(+ x Y).S.AF.E 3 .Sz). [A<Sz.Et.F).E 1 .f 1 • [A<S3."CEXPR [Xl (+ x Y}]. I("(+ X Y). Cl .Ez.4. Et. El. [A<St.EXTENO(Et.F 1 • [A<S2. [A<S3. E3. Ft) • I(Sl. Ez • Fz> • [A<St. I("(Sl HANDLE(ENV(Et. Fl. Et.S."cxl.fz.E2.fz>] <53' f 3 • F3) ) ] ) ] ) Once again the significance of Eo<" EXPR): = ([A<St.E 1 .Fl»}. D E3. I(NTH(l."[X].AC .Et.Sz).Da. .F2) Ez . (54-641) [A<Sl. F3> • a.E1.F 1 • [A<S.AE..Ft» <"[EXPR [X] (+ <SI. [A<St. El. D a . Fl) • I(Sl. ([).F t • [A<S3.F 1 > • (54-642) ~("(Sl HANDLE(ENV(El.Dz.F 3 > · 3])])]. El. F3»])] .Fl» HANDLE(NTH(2. F3> • 03])])]' Ez.F z • [A<S3.E 1 .F 3) • C(S3.EXTEND(Et.F z .E2.F t ) • Procedural Reflection 419 (54-640) I("(SI HANDlE(ENV(Et.F z) • <s!.D3 .E x Y).D1."CEXPR [X] (+ X Y)].E 3 . 03.Fl»).E 1 .Fl»). 2-LISP: A Rationalised Dialect We look then at the internalised LAMBDA function: • ([AS. ° ."[X].Fl» HANDlE(NTH(3.Ft.Ft. Fa)])])] X Y)J~Et.F a) · 03])])]' 3."(EXPR [X] (+ X Y)l.Ft» HANDlE(NTH(3. E2 • Fz> · <S2.Fl» HANDLE(NTH(3. 0 1."fEXPR (Xl (+ x YJ].E 3 .D2.ft» HANDLE(NTII(2.EXTEND(Et. Ea.S. and begin to reduce this (once again we do rail extractions immediately): • ~(·EXPR.(Sz. [A<Sz. [A<SI.Dz. Ol.f t ) • l:(Sl.F z>]» [A<s3.F a) • ([A<Sz. HANDLE(NTH(2.F.F t • [~<5z. Fz>] (53' f 3 .D3 . Fl) • .F~) ~("(+ Ez.sz).F z) .E.

[A<S3.F2.Ez. l-Iowcvcr we need to know what the primitive closure designates (we will call this for the time being).[Ot(F 12("((Eo("EXPR) Eo CENV PARAH BODY] <S3.F3> . D E F3> 3. F3> • ([A<Sz. 3.E t . El • Ft ) ([A{S1) ] <F 12("((Eo("EXPR) Eo [ENV PARAM BODY] (EXPR ENV PARAM BODY» V»~).EXTEND(Et. F3 »])] Ez.Fl' <53.:!! 'CX] '(+ x V») • (54-643) It [A<S3.D3.E z .S2). Fz) Z.f 2 ) ~("(+ • <Sz. ([A<Sz. Ea.4.F 1 • [A<S2.).E z . 03])])]] Et. Et.D3. D3.Et. ~(Sb.F t > • ~(SI.EXTEND(Et.:!! lbc primitive EXPR '[X] '(+ x (EXPR ENV PARAM BODY) Y»).F t • [A<5 1 . D Ez.nCX1. [A<Sl. From the general significance of pairs (54-38) we have: = ~("(Eo("EXPR) Eo [ENV PARAM BODY] (EXPR ENV PARAH BODY) (S4-644) Et.E 3. Et • Ft.AS b • [A<SI' E1 • Ft ) • :E(Sl. Fa»] Ez. Ft.E 1 . 03])])]' .Et. E3 .E z .[A<S3.F 1) • l:(Sl. [A<S2.F 2 )] X Y).E3. D3.Sz)."[X].E t .F 1 • [A(SZ. 'El '[X] '(+ X E1 . 2-LISP: A Rationalised Dialect <"(EO("EXPR) ~ Procedural Reflection 420 [ENV PARAM BODY] (EXPR ENV PARAN BODY)). El • Fl ) • ([A<S3.Ez.EXTEND(Ec. We also do some Ft field .F 1 )].Ot.Ft» When we reduce this we will construct the appropriate pair with handles and so forth: • I("((Eo("EXPR) Eo CENV PARAN BODY] (EXPR ENV PARAH BODY)) .fz.F 2 »])]) closure is in nonnal fonn and stable: thus we can simply abbreviate this D· expansion (otherwise it would cycle forever).F z> • <52.E 3 . .S~).F 3) · 03])])]' Now the first ittm here is of course the pair containing the primitive EXPR closure as its pair.Sp. [A<Sl.Dz.F z) · I("(+ X Y).D z .F2 > • <S2.F z• [A<Sa.F z)] [A<Sz. E3.F 3> . [AEc·ASp.

S."[~ 'CXl '(+ x YJ].Sz).Fl). [A<S2.Et. S.F z) • ~(NTH(3. (54-641) [A<Sz. 03. !(NTH(l.F z • [A<S3. F2 • • EXTENO(Et.646 ) [A<Sl. FI) • El • Ft. 3.F.fz).F2). F2) Z.Ez.Fz) • ~(NTH(3.E 1 .F). D ])])].."[X].Ez. • [). 'CX] 'l+ x Y)J.F 2 »])]) Next EXPR nonnaliscs its arguments. D E3.E 1 .DZ.) . ([~<S2.Ft. D Ea.Ft)].F z• [A<S•• D E.E z .Dl.S.E 1 .Ez.AC .Ez.Dz.(Sl.E( 51. C("(Eo("EXPR) St 51 S3}.Ez.F 1 • [A<SZ. Ea.F z> <S2' • • [A<Sl."[X].Dz. Fl.E•• F. 3 = l:{"'[X]. I("(+ JC V).F z) • {[A<S3.Et.Sz). F3> ([A<Sz.F t ) • :t(Sl.EXTEND(Ei. D El.E 2 . Ez. [A<Sz. [A<Sa.E t .[D·("([~ '[X] '(+ X YJ]). [A<St.Ez. Fa) . D Ea.FI' <"C~ Et. (54-646) [A<Sz.Fz> (SI.Dz.E.El.F. f 3) • 3.Ez.4.AE. D E2.F z>] <53' E3 • F3 »] <S2. ( S4. but since they are all handles this is a straightforward (if messy) three steps (another a-reduction for perspicuity): = 1: ('J 'E 1 • Et t Ft . EZ • Fz) • ([A<S3.F z> • .F)])])])] [A<Sz."[~ '[X] '(+ X Y)]. 4 ([A<Sz.F z> • ~("(+ X Y). • ~(NTH(2..F 1> • .f t . F3> • 03])])]' a.F 4) • •• ([A<Sz.F" [A<S•• D ."[~ '[X] '(+ X YJ].Ez. E1. [A<S3.Ez. D E3.F 1 . 2-LISP: A Rationalised Dialect Procedural Reflection 421 extractions: • ([AS. Fa) • a. Fl) l.F z) • ~(NTH(3.FI) • ~(NTII( 2.F 1 ).Ez.AF.

. . [A<Sz. F3) (52' (54-649) • ([A<Sz.4.Dz.E 1 .F z) • ~("(+ X Y).F. EI • Fa) • Procedural Reflection 422 <S•• [A<S.E 4 .. 2-LISP: ARationalised Dialect ([A<S3.E. = ([A<S3. Fa) • 0 3 ])])].D4 .Fa> • ([A<S2..F a• [A<S3.).F.) • I(S.EXTEND(E.Fa»)] <S2.~[Xl."[XJ. . Elf Ft > • 1:( St.Ez. Fl.F z) • .F. Et .Ea. E3.F z• [A<S3.Ez. [A<Sz.E 3 .Ez. . D3.F 3> • 03])])]. D E3.E t .F.E~. EZ."[X].Ez. D E3. Fz) • (54-660) <52' [A<Sl.F z) • a..Ez.Dz.. D EZ. Y).E 1 .Dz.F 1 ) • ~(SI.E. Fl.F4) • ([A<Sz. E3.F 2 »] '[X] '(+ X Y)}.. [A(S2. ([A<S3. ~("(+ X Y).) a.. F..F2> · I("(+ X Ez. D E a) • 3. [~<S2.Ez. Da.EXTEND(Et.F z>] <Sa. D a. ([A<Sz.f2' <"(Eo("EXPR) 'll '[X] '(+ X Y)]).F.F i )].F z) • <52' [A<SI.[D·(W(C~ [A<S3. = ([A<Sz.E • 03 ])])].E z .F3 ) .F z) • ([A<Sa.F z) • [A<Sl..»])]) We can now reduce this into the part of the signficance that is carrying the declarative import. D3.S.F ([A<Sz.Sz)..E.EXTEND(Et.S2).Ez. Fz) 2. E1.> • l:(SI. (54-648) [A<S4.

DZ.(+ X YJ])..of this expression is a pair.F 3> • 03])])]' .(+ x V)). D3. E F3) • 03])])] 3.Et.F 1)]. °tk)])] . 03])])]' We are then done (no morc p-rcductions apply). In order to know what this closure designates.E.AE .F z.F t » [D·(·(C~ Ez.Fl> " 1':(51. (54-662) ~(SI' E .. [A<Sz.D3.EXTEND(Et.Ft> • G(01 . 54-168 We recall from that the definition of the cxtensionatising function is as ronows: (54-664) EXT a AG • [AS.F. The resull . the CAR of which is the primitive EXPR closure. Fz) (54-661) <"(Eo("EXPR) Ez.E 1 . 'eXl .Sz).El. Ez. then of (LAMBDA is as expected.F 1 > • (54-663) ~(51' El' Fl' [A<Sz. The full significance.).~ 'CXl '(+ X Y)).E. El' Ft.F z. however we look at the second element of the sequence. E3. [A<St. Again: • ([A<St.F I ) • ~("(+ X Y).E z . [A<S2.E t .F z>] <53.F z• a. 'eX] .-CX].F z) . ("(Eo("EXPR) ft.EXTEND(Et.F z>] . [A<Sa' 03. .~ 'eXl ."[Xl..Sz).E 3.(+ x Y)). 2-LISP: A Rationalised Dialect ~(-(+ Procedural Reflection 423 x Y).AF • l:(S.F 1 > '~ .F t )) And again: = ("(EoC"EXPR) [A<SI.4.Sz). [A<S3. E3 • F3»)] ° . I{"(+ X Y).OI . I 2 [A<St. Et.Ez."[X]. D E3. t Fl.the local procedural consequence .F a) .D2 . [A<S3.. arguments: a designator of a stnlctural encoding of Eit and the parameter pattern and the body expression of the lambda form.Dl."[XJ.Dz. We sec that it designates the following fonn: [A<5 1 .EXTEND(Et.F z• [A<S3. reduced with three EXPR [X] Y) in E. F3) • 3])])].S. This is just the closure we predicted.Ez.Fa> • <Sa.EXTEND(Ei. ~("(+ X Y}.

to prove that th~s is in fact the incremcntation function. is very simply show the significance of «LAMBDA EXPR [Xl (+ X v»~ 3) (54-666) in an environment in which Y is bound to 1. .! <"[31.namely. What we will do. [A<Sz. (~<S3. [A(St)]("[3].Dt("[3].e.F t • (A<Sz.Ez.E z.F t . l:(St.[A<Sz. that maps that structure onto the designation of the expression (+ x Y) in a context c2 which is like c1 except that it is modified so that in it the variable x will be bound to the normalisation of its argument in Ct.E t .Fl).4.E 1 .f z> · <52' ~("[31. EXTEND .F z) · C(Sz.Dz. EXTEND(E t . The designation of (LAMBDA EXPR [X] (+ X Y» can therefore be seen in the following light: it is a function of a structure and a context ct (i. that Y is bound to the numeralt .Et.F t > . · 03])])] F2 >]> ) E2 • <"[3].E3."[Xl.E t .F z> • I("(+ Fz • x V). Ft> • l . [A<Sl.F t .E t . E2 . rIbis is also correct. therefore this reduces straight away to: = ([A("(EoC"EXPR) '!l '[X] '(+ <"[31. Et.Dz.D3.F t • x V»)] (54-667) [A<Sz.E t .Ez.Fz)])]) But of course we have just computed the first major part of this. ) could in tum be expanded. A quick application of 54-38 yields: I("((LAHBDA EXPR [X] (+ X V)) 3).. in conjunction with what know about Et .. we have merely shown how our characterisations do indeed carry the weight which we wanted them to.Ez. 2-LISP: A Rationalised Dialect Procedural Reflection 424 These are of course very similar in structure.F1' '[X] '(+ X V)~)] (S4-668) [A<Sz.Ez.El. D .Ft.F t . The term 1:(" (+ X Y).F z> . EzF z). We will not do so here. Fz) • <S2' ([A<5 1 .F3) Reducing first the inner application: = ([A("(Eo("EXPR) '!.E t .ID) (54-566) = ~("(LAMBDA fXPR [X] (+ X Y»). in conclusion.Et.sz).Et.F t ».

Dz."[3]).AFt. Ft.Ft. D Ea. x Y).r z) • ~("(+ X Y)..E Ez.F t . Again we can assume from prior bound to 3 examp~es that (+ x Y) i~ an environment in which x is and y to 1 (as EXTEND( ft. will designate the number 4: = ([A("(EoC"EXPR) '!! '[Xl '(+ ("[3].F z. 3.E z. 2-LISP: ARationalised Dialect 1:("(+ Procedural Reflection 425 EXTEND(ct. E· •Ft. [A<S3. E.E1.F.Dz.E z.F z) .[A<Sz. (54-662) [A<Sz. D E F3) 3.E t .E*.E z .D3 . w CJ1.F z> • (Sz.E z . • FI > [3] self- fl+ x V)~)] (54-669) <5. .Ft. EXTEND(E t . [A<S3.4.Ez.[A<Sz. Ct(S3.F a»]) .F z>] <S3. E3.E·.f 3 . Fz)]) ) Ft.E z.F z) • I("(+ X Y).Ez. ([A<Sz. EI • Fa>]» Fl' [A<Ss.ACt • [~(St.Ez. "[3]) will of course ensure). [A<Sz.F z. D 3 .Sz). 1:(" (+ X V)..) • 03])])' We will do the inner (declarative) semantics first.F3)])])]] a. in one step assuming that nonnalises and designates <3> without side-effects: • ([A("(Eo("EXPR) '!! '[Xl ("[31.4.[A<S3.F z> ."[X].E. ("[31.F z>] <5 3 . Fa»])] where E* is like E1 except extended by matchIng 5z against "[Xl [3]: (S4-663) Once again we omit the simple derivation of the significance of = 1:( If (+ x Y).E t .4. <Sz.<Sz. ([A<Sz. "eX].E z.F z>]» EXPR x Y)J)] (34-660) We are now ready to apply the intemalisation of general • ([AS 1 .F z) . Et • Ft.<Sz.E z. Fa> • 3. [A<S3.E3.4. closures set out in 54-629: (54-661) [A<5 z.F z>]» whers E* is like Et except extended by matching 52 against "[X] A simple reduction: • l:("[31.E t . D E3.4. F3> .AE t .F 3 > • 03])' 3.

.F z) · <S2. E-. 4 •Ez.F t »]) which tinally reduces to our answer: (54-666) In other words the field remains unchanged. . 2-LI5P: A Rationalised Dialect where E· is like Et except extended by Procedural Reflection matching "(3J against ·eX] 426 Note that we have updated our account of E·. Fz)] <". The original expression As expected.4. But again we assume that x is bound to E*.. E· is returned (but that is of no consequence since we would discard it abDve).Ez. 3 in thus we can again aSS\lme that = (+ x Y) will nonnalise to 4 and designate 4: (S4-664) ([A<Sz. and the modified environment thus designates four and returns the appropriate numeral.

4. it is also the kind of recursion we mean when we say 0 ~ that a semantic domain is recursively defined by an equation such as Cox J. 1bis approach was intentional. This is the sense in which support recursion and FORTRAN is said to 0 not. since for any function designator F we can construct the following designator F' that it recursive. v. of increasing semantic depth: as applying to signs. but it should be clear that none of the discussion in the preceding section explains how they might be made to work. Finally. The original and most accessible notion of recursion is as a predicate on function designators on signs. but that designates the same function: . What is of concern here is what the predicate "recursive" is being applied to. In recent years the notion of a recursive procedure has been increasingly contrasted with that of an iterative procedure. of a recursive set - decidable characteristic function. in other words: a IISP definitioll of a function is recursive just in case a tenn designating the whole function is used as an ingredient term within the definition. there a set with a are a variety of mathematical concepts: of a "recursive" function. As usual the first task is to make clear what we mean by the term. but it is of course necessary to face the question of recursive definitions. deriving from the notion of composition of a certain set of functional ingredients. Recursion We have discussed the use of A-terms as function designators without mentioning the subject of recursion. and to extensions. 2-LISP: A Rationalised Dialect Procedural Reflection 427 4. On the other hand there is a sense that any definition using its own name within it is recursiv~. for it is important to ground the notion of a A-term in the simpler case. on this syntactic account.they don't appear to have the fundamental properties (such as requiring memory in proportion to depth of call) characteristic of the "paradigmatic" recursive functions like factorial. There are in particular three ways in which we may use the tenn. and so forth. We have used DEFINE with recursive A-tenns in many prior examples. based on the intuition that certain functions that were traditionally considered recursive are in some deeper sense not really recursive at all .e. to intensions. However it is of course a consequence of tllis definition that nothing of interest can be said about the class of functions designated by recursive definitions.

a sub-procedure to the second. syntactic recursion. it is worth Dlentioning because it will matter in our characterisation of the meta-circular and reflective processors we will encounter in later sessions. 6 no matter how they are designated.is with the support of recursive definitions . The intuition is exemplified by the following two definitions of factorial: though both arc syntactically recursive. that we are concerned in this section. general as well as elementary. requires a finite but indefinite amount of memory. where we show how Church's Y operator enables any recursive definition on our account to be converted into a non- recursive definition. The non-semantic character of this use of the word will emerge strongly below. having more to do with compositionality: attllough the structure of the natural designators of such a processing function arc typically recursive in form thus it is not an unrelated notion). can Nonetheless. tenllS - architecture we have already adopted - recursive functions. definitions be rendered recursive by the technique illustrated in fix-point function. again - by which they are different The processing of the first.the 2is fully adequate to support arbitrary always be discharged. and although they are extensionally identical (they both designate the factorial function). is the most "hyper-intensional" use of the predicate. F(X) (54-610) tllOSC involvin~ Furthermore. there is no way mechanically to exclude such definitions - only gratuitous recursive uses of the function's name in the body of the definition . as Church and others have showed. recursive lambda LISP far more importantly. there is a point of view - an intensional point of view. The "iterative- recursive" distinction of computer science trades on this intensional use of the term. in virtue of the use of an explicit non (syntactically) recursive designator of the fixed-point function. it . Midway between the hypcr"intensional notion of a recursive definition and the extensional notion of a recursive jUnction is the notion of what we will call a recursive procedure - a use of the tenn "recursive" over functions ill intension. in a depth-first "recursive" control regiolc (that's of course yet a fourth notion of "recursive". not only can all non-recursive 54-670. in the technical sense.4. all recursive definitions can be rendered non-recursive in conjunction with the In ·sum.since it is not in general decidable whether a recursive use of that name plays an essential role.". Our formalism . In other words. requires a fixed . 2-lISP: A Rationalised Dialect ff Procedural Reflection 428 F' • AX • [1 • 0] then F'(X+l) . This. whereas processing the the tllird. then.

Syntactic rccursion.N 1»»» (al~~ough course the representation of the answer docs require storage that grows with the depth of (S4-671) (DEFINE FACTORIAL z (LAMBDA EXPR [N] (FACTORIALz-HELPER 0 1 N») (DEFINE FACTORIALz-HElPER (LAMBDA EXPR [COUNT ANSWER N] (IF (= COUNT N) ANSWER (FACTORIALz-HELPER (+ COUNT 1) (* ANSWER (+ COUNT 1» (54-672) (S4-673) N»» In tile ptocCssors we will define for 2-LISP and 3-lISP it will tum out that the essentially "iterative" (non-increasing storage) nature of FACTORIAL 2 -HElPER is embodied in its processing. The intensional distinction. The LAMBDA term is a sign. in other words. thus requiring no maintcnce of state on the part of its processor. not a mentioll of that name. independent of the magnitude of the argument the processfng): (DEfINE fACTORIAL t (LAMBDA EXPR [N] (IF (a NO) 1 (* N (FACTORIAL (. is not selfreference of the sort that win permeate our discussions of reflection in the next chapter. Furthcnnore. matters to us. that designates the factorial function.are "tail-recursive" in the sense of FACTORIAl zHELPER. Note that.4. 2-LISP: A Rationalised Dialect Procedural Reflection 429 of (and small) amount of storage. the kind of recursion we are concerned with here involves tile embedded use of a name for the procedure. in other words. since our (lefensc will involve a recognition of the fact that all embedded calls to the processor function the "recursion" mentioned above that characterise the basic LISP control regime . this fact will play a crucial role in our ability to claim that the entire state of processing of a 3-LISP procedure is contained at a given reflective level. since the "embedding" of the continuation structure (as was pointed out by Steele and Sussman) is engendered by the processing of arguments. consider again the recursive definition of FACTORIAL in 54-671 above. with some intcnsional content. and is adequately treated in our meta-theoretic accounts. But these are all matters for a later section. Our present concern is merely with what we will call syntactic recursion in LAMBDA terms. In order to sec this clearly. not by the reduction of procedures. in spite of an informal sense that syntactic recursion involves some sort of selfreference. The embedded usc of the name FACTORIAL is intended .

we knew that G designated the factorial function. Nor does any part of the factorial function qua abstract mathematical function contain any designators at all (both the domain and range of the function are numbers. There is a received understanding in the community that a proper or adequate implementation of recursive definitions requires in a deep sense some kind of circularity on the part of the implementing mechanism. to the extent there is anything "selr'-ish about it. (54-576) then if H were applied to the actual factorial function. then H(G) . but that it is not obviously true was shown by Church (as part of a proof of the universal power of the A-calculus) in his demonstration has COOle of the paradoxical combinator or Y operator. It: more particularly. We will ultimately show tllat this is true. since we are assuming numerical arguments and other primitive functions. involves a kind of self-use. It: for example.is that this FACT would designate the factorial function if were bound to the factorial function. the notion would seem at heart to have something to do with a syntactic or linguistic obj~t that either was (or was part of) its own designation. we had the expression: H E AFACT . Though it is by no means easy to make the concept of self-reference precise. not the pure A-calculus. not signs). No amount of circularity or recursion trades on any such mentioning of a designator by that designator. «AX. FACTORIAL " Suppose we had the following incomplete definition of FACT incomplete because the the tenn is unbound (this is expressed in our eclectic meta-language. 2-lISP: A Rationalised Dialect Procedural Reflection 430 also to designate that function. nor the fACTORIAL tenn.4. [1f [N = 0] then 1 else [N • FACT(N-I)]]] . However neither the LAMBDA term. nor any of the other constituents. then the value would be that factorial function. Syntactic recursion. in other words. F( X( X) ) ) ) (54-614) This would be used as follows. than true selfreference. [AN. F{X{X») (AX . designate the LAMBDA term or the FACTORIAL tenn or any of the other constituents. The pure A-calculus form of the Y operator is as follows: AF . rather. but the idea is clear): AN . [if [N = 0] then 1 els9 [N • FACT(N-I)]] (54-676) Then the insight - the fundamental content of the notion of a fixed point . an apparently non-circular and non-recursive (in the syntactic sense) term that designates what to be known as the fixed point /unction.

2-lISP: A Rationalised Dialect Procedural Reflection 431 would designate it as well. By and DEFINE large definitions are allowed only at the so-called "top-lever' (one cannot use function cells. It would be awk\vard if one could both LAMBDA bind and SET variables in general... X . This is all elementary. when the procedure is used. We cannot accept this protocol for a variety of reasons: 1. we should admit straight away that the techniques by which recursive definitions are supported in standard LISPS must be rejected. for example). since it involves some unavoidable conceptual ineffeciencies. Before setting out on this project. top-level definitions of recursive procedures. in special are dynamically scopcd. but only SET could be used to bind . Useful in general. the bindings that result are established globally. this kind of practice is particularly natural in a statically-scoped dialect 2. »). We will not ultimately employ the procedure that results. 54-676 contains everj"thing necessary to It is then standard theory to show that the Y operator correctly embodies this intuition.4. and there is only a single space of procedure definitions. We want to be able to embed definitions. and so forth. but we will base the (non-primitive) procedure we do finally select on our translation of Church's function. Since these standard LISPS embedded within a program). We have reviewed it because we can. This is particularly useful because we will be able to define a declaratively and behaviourally adequate procedure tllat will enable us to handle all kinds of recursion" (single and mutual recursion.. "Ihe resuit is that y( H) designates the factoriai function. and so forth) - all without requiring us to define any new primitive mechanisms to extend those we have already adopted. We do not store "functional" properties differently from standard "values": the binding of procedure names must therefore use the same mechanisms as those used to support general binding.. if we wish. since tile binding will have been constructed at an earlier period of time. To this intuition is added the realisation that specify the factorial function. particularly within the scope of bindings (in forms such as (LET [[X 1]] (DEFINE F (LAMBDA . any recursive use of the name of a procedure within that procedure's body will of necessity find the binding already established. one would show that «Y(H» 6) (S4-577) designated the number 720. absorb this behaviour almost directly into 2-LISP. To continue with our mixed meta-language.

6 a separate primitive called LABEL was provided for this case. »). in spite of its static seoping (SCHEME has LABELS. that a close look at the fixed point function will bring into eXi>licit focus. names to recursive definitions. but even that dialect does not support embedded definitions. no trouble will arise in using such a function in our dialect.. As well as defining bindings in a closure from the impact of subsequent OEF INES. In sum. It is a straightforward function: ii is of course of indefintte order. but so be it) - syntactic transformation into 2-LISP of 54-674: (54-678) (DEFINE YI (LAMBDA EXPR [rUN] «LAMBDA EXPR [X] (rUN (X X») (LAMBDA EXPR [Xl (FUN (X X»»» This can be more perspicuollsly written as follows (although the Y operator has never been the most pedagogically accessible of functions): (DEFINE Vi (lAMBDA EXPR [rUN] (lET [[X {l~MBDA EXPR [X] (FUN (X X»)]] (FUN (X X»») (54-679) . we. but docs not support (LET «A 1» (DEfINE . pedagogical style should be admitted: we arc using DE FINE version (a certain circularity in our DEFINE to define filnctions that we will this is merely a does. since it applies to functions. but since example. will be able to provide such facilities as protecting all without resorting to special purpose mechanisms. LABEL and DEFI~E as simple non-primitive functions. the acceptance of the standard tcchniques overlooks some distinctions of considerable importance.tlen to Church's Yoperator.. 2-LISP: A Rationalised Dialect Procedural Reflection 432 3. Some of our complaints are of course handled by Sussman and Steele's SCHEME.4. we define the following initial ultimately use in order to explain what 2-LISP 2-LISP is an untyped higher-order Suppose. something we should attempt to r~pair. for fonnalisDl. We tum . The success of the recursive nature of the definition arises rather accidentally out of global properties of the syste~ which is ineleganl Funhennore. 4. procedure definition ha3 to date received rather ad hoc treatment. It is not possible to use the traditional mechanism to implement mutuallyrecursive sub-procedures visible only within a specific context In LISP 1. as the analysis of the next pages demonstrates. There is no defensible reason to need an extra primitive.

(S4-681) and so forth. Y1 would work properly in a normal-order system.4. but Rot actual. It would engender an infinite computation before it ever returned a procedur~ to reduce with a numeric argument. In section 4. enabling arguments: Yz to be used for procedures of any number of . for procedural reasons. so :i.elf until the arguments have been given to the recursive procedure. In the A-calculus. which is what y1 does. This is all very well declaratively. to be LISP. Thus Y2 alternately reduces one argulnent set. then onc self-application.N (fACT (. 2-LISP: ARationalised Dialect Procedural Reflection 433 The idea would be that if we defined a version of factorial as follows: (DEFINE H (S4-680) (LAMBDA EXPR [FACT] (LAMBDA EXPR [N] (IF (:II N 0) 1 (. Note the use of a single atom ARGS for a pattern. and so on. however. back and forth. as we have noted before in conjunction with the conditional~ the reduction protocols are nonnal order. behaviour. we wilt require an adequate applicative order variant This problem.i we discussed the fact that wrapping a designating expression in a LAMBDA tcnn and then reducing a corresponding rooex at a different time is a standard way of deferring the processing of intensions. but it is less acceptable procedurally. This trouble is apparent from a brief exami:1ation of how y1 works. since we do not wish actually to generate this infmite tree of procedure expressions. Using this technique. then onc argument set. rather than applicative order. since that is really what the recursive use of the name means.N 1»»») then we should have: «VI H) 1) «VI H) 6) 1 720 This is desired. iL is straightforward to define a modified version of VII to be called Yz• that defers processing of each embedded application of itc. however. is easily repaired. but a' copy of the application of the y operator to H. any usc of it will fail. v1 gives to the function that H a procedure that embeds not ~l1ly another copy of H. Although VI is declaratively correct. The problem is that although (Y 1 H) cau be shown to designate the factorial function. thereby engenders an infinite embedded tree of procedure definitions. the processing of (Y I H) would never return.c.

to have the Darrte in the environment and the name within the procedure definition be the same. In the example we used the name "G" - different from the name FACT used internally. although this cannot be done. ARGS»») Of. It is of course nonnal. one can imagine replacing all recursive instances of . 2-LISP: A Rationalised Dialect (DEFINE Va (LAMBDA EXPR [FUN] «LAMBDA EXPR [X] (FUN (X X») {LAMBDA EXPR [Xl (LAMBDA EXPR ARGS «FUN (X X» . both declaratively and procedurally. that they are EXPRS (we will discuss recursive Y2 IMPR definitions presently). with a better theory of intension we might escape having to retain the internal name at all (for example. in any particular context. because of decidability considerations. We have. Procedural Reflection 434 (S4-582) once again to use LET: (DEFINE Y z (LAMBD~ (54-683) • ARGS»)]] EXPR [FUN] (LET [[X (LAMBDA EXPR [X] (LAMBDA EXPR ARGS « FUN (X X» (LAMBDA EXPR [X] (FUN (X X»»» is acceptable. and simple. by which a procedure is known is a matter of that whereas the name used within a recursive LAMBDA LANBDA cOlltexl. for single recursive procedures of any number of arguments.N 1»»»» > (G ) 1 ) G 0) ) (G 6) ) 720 ) (G (G 4» ) 620448401733239439360000 This illustration brings up a point we will consider at considerable length below: what it is to give to a surrounding context a name for a recursive procedure. the follow!ng actual Y2 2-LISP behaviour (we avoid DEFINE here merely to illustrate how perfonn any sort of magic): ) (SET G frees us from any need to have DEFINE (54-684) (Y z (LAMBDA EXPR [FACT] (LAMBDA EXPR (N] (IF (:I N 0) 1 (* N (FACT (. As we have said before. providing. The name. tenn to refer to itself is a matter of 'he intension.4. but our approach has shown how these arc at heart two different issues. for example. of course.

the latter concern can be treated adequately and independently of the former.ar within the scope of each definition. however. EVAl Though there are familiar cases of mutually recursive definitions (the and APPLY of I-LISP are a fatniliar pair). as given it is unclear how we might support mutually recursive definitions. First.4. and we have adapted to 2-LISP'S circumstances. Before turning to those issues. which arise in connection with a suitable definition for DEFINE. they tend to be rather complex. respectively: (DEFINE Gl (LAMBDA EXPR [A 8] «G2 A 8) (+ A B) A») (54-686) (DEFINE G2 (LAMBDA EXPR [A 0] (IF (EVEN (. we will therefore consider the following two rather curious mutually-defined functions: it can be seen on inspection that (Gl A 8) designates either A or 8. if we are going to base subsequent definitions of other variants on its ext~mal behaviour. for example: (Gt 3 4) (Gt 4 3) (61 6 7) 4 (S4-686) 3 6 It is clear that any fixed-point abstraction over mutually recursive defintions will have to bind formal parameters to all of the elements of the mutually recursive we will have to treat the following two fixed point expressions: HI se~ since applications in terms of any of them may appr. depending on whether the product of A and B is odd or even. but it is convenient nonetheless to generalise the definition of Y to encompass more than one definition. there are a variety of concerns with Yz that we should attend to. As Church has shown. TIluS in our discussion of environments. Thus = (LAMBDA EXPR [61[AG2] (LAMBDA EXPR OJ «G2 A B) (+ A B) A») (54-687) . Algorithmic procedures do exist whereby two or more mutually recursive definitions can be "unwound" into a single recursive one. A 8}) Gl») Thus we have. 2-lISP: A Rationalised Dialect Procedural Reflection 435 the name replaced with actual references to the resultant closure). It is convenient to have an example. we must not be led into confusion about the recursive aspects of the LAMBDA term.

It therefore follows that the normalisation of (S4-692) .4. A B» (54-688) GI») An appropriate 2·function variant on vz. ARGS»)] . called YY z• is defined in 54-690. ARGS»)]] This indeed supports the behaviour indicated in 54-689. Yz• will accept an arbitrary number of mutual1y recursive definitions. below. ARGS») . both declaratively and procedurally. It is of course necessary to generalise once more. and will designate a sequence of the functions they designate. 2-LISP: A Rationalised Dialect E Procedural Reflection 436 H2 (LAMBDA EXPR [Gl G2] (LAMBDA EXPR [A B] (IF (EVEN (. The term (YY 2 HI H2) designates a two element sequence of the two functions in question. ARGS»»» Once again we present a LET version for those who find this clearer: (S4-691) (DEFINE YY z (LAMBDA EXPR [FU~1 FUN2] (LET [[Xl (LAMBDA EXPR [Xl X2] (LAMBDA EXPR ARGS «FUN1 (Xt Xl X2) (X2 Xl X2» [X2 (LAMBDA EXPR [Xl X2] (LAMBDA EXPR ARGS «FUN2 (X1 XI X2) (X2 Xl X2» (LAMBDA EXPR [Xl X2] [(fUNt (Xl Xl X2) (X2 Xl X2» (FUN2 (Xl Xl X2) (X2 Xl X2»]»» . thus we would expect the following behaviour: «NTH 1 (YY z HI H2» «NTH 1 (YY z HI H2» {(NTH 1 (YY z HI H2» 3 4) 4 3) 6 7) 4 3 (54-689) 5 The definition of YY 2 is this: (DEfINE YYz (LAMBDA EXPR [FUNI FUN2] «LAMBDA EXPR [Xl X2] [(FUNI (Xl Xl X2) (X2 Xl (FUN2 (Xl Xl X2) (X2 Xl (LAMBDA EXPR [Xl X2] (LAMBDA EXPR ARGS «FUNI (Xl Xl X2) (X2 (LAMBDA EXPR [Xl X2] (LAMBDA EXPR ARGS «FUN2 (Xl Xl X2) (X2 (54-690) X2» X2»]) Xl X2» Xl X2» .

that LABELS is a macro that z expands expressions of the form: (LABELS [[<ll> (LAMBDA [<lz) (LAMBDA <E t ) )] (54-696) <E z> )] <BODY» [<It> (LAMBDA . can be used with an arbitrary number of mutu31ly recursive definitions. Y2* may be defined as follows: (54-693) (DEFINE VI· (LAMBDA EXPR FUNS «LAMBDA EXPR [RECS] (MAP {LAMBDA EXPR [FUN] (FUN . Assume.. (MAP (LAMBDA EXPR [REC] (REC . (MAP (LAMBDA EXPR [REC] (REe ... )]] into expressions as follows: .4. facilitating the fact that y. of course. RECS» RECS» . <E t > . RECS» RECS» • ARGS»» FUNS)]] (MAP (LAMBDA EXPR [FUN] (rUN. though of theoretical interest.eflection 437 will return a nonnal-fonn rail of the appropriately defined closures of the functions in question. RECS») FUNS»» Note the substantial use of non-rail argument forms. (MAP (LAMBDA EXPR [REC] (REe .. in particular. 2-LISP: A Rationalised Dialect Procedural R. What is striking is that we can define the standard LISP notion of LABELS directly in terms of Y *. would in a practical setting never be used explicitly. ARGS»» FUNS»» Again a LET version: (DEFINE Y • (54-594) z (LAMBDA EXPR FUNS (LET [[AECS (MAP (LAMBDA EXPR [fUN] (LAMBDA EXPR RECS (LAMBDA EXPR ARGS «FUN. (MAP (LAMBDA EXPR [REe] (REe . RECS» RECS») FUNS» (MAP (LAMBDA EXPR [FUN] (LAMBDA EXPR RECS (LAMBDA EXPR ARGS «FUN. Such a definition. RECS».

sumc the entire set of DEFINE. We would {LABELS [[Gl {LAMBDA EXPR [X Y] «G2 x Y) (+ X Y) X»] [G2 (LAMBDA EXPR [X Y] (IF (EVEN (..)] (LAMBDA .. for example: 1.. to facilitate mutually recursive "top-level" definitions. <LABEL k )] (Y2· <PROCEDURE 1 > (PROCEDURE 2 > . it is straightforward to assume equivalently that expressions of the fonn ... <PROCEDURE k ») (54-601) Since DEFINE- is a p\lre extension of DEFINE - i. it is straightforward to define a first version of DEFINE in its terms.. 2-LISP: A Rationalised Dialect Procedural Reflection 438 (LET [[[<L t ) <L z) . but not necessary. <It)] (Y z• (LAMBDA EXPR [<L t ) <L z) .Gl»]] (c (Gl 2 3) (Gl 3 6») => (54-697) Sf Note as well that the definition of the LABELS macro makes explicit what we mentioned earlier: it is standard....4. One issue this agreement raises is this: we have assumed throughout that LAMBDA DEFINE tenns. to have the name within the intensional expression and external to the intensional expression be the same. (DEFINE. <Lt..<LABEll> <PROCEDURE t > <LABEl 2 > <PROCEDURE z) (54-600) arc abbreviations for (MAP SET [<lABEl l > <LABEl 2 > ..6-style LABELS.e.. »)]] LISP This is then the standard have.. since DEFINE- and DEFINE are equivalent in effect when given a single argument behaviours under the single name need not be used with explicit we might just as well a~. we can assume that expressions of the form: (54-698) (DEFINE <LABEL> <PROCEDURE» are macro abbreviations of (SET <LABEL) (Y2 (LAMBDA EXPR [<LABEL>] <PROCEDURE»» (54-699) In addition. we have assumed we could use ..> . X V»~ . defined as a user function. In particular.. In particular. <Lit>] (LAMBDA (LAMBDA EXPR [<It) <L z) ••• <L t ) ] (LAMBDA <E 2 > (E t ) (54-698) » » <BODY» (LAMBDA EXPR [<L t > <lz) . <EIr. Given this definition of Y.

The reason is simple: Y2 in 54-604 causes the atom EQ to be bound to the fixed point defined over =. but observable. Thus even if our new definition of DEFINE did not support However it is reassuring to recognise that assumed in 54-699. suppose we wish to give to the atom EQ the approximate meaning it has in I-LISP. under tlle expansion to (the multiple argument Yz* makes this immaterially more complex): ~») (SET EO (Y z (LAMBDA EXPR [EQ] (54-604) which is equivalent. has no discernible effect. however (where the second argument uses the term being set). the atom = nonnalises to the primitive X V»~ (54-606) However we also have: (Y z (LAMBDA EXPR [EO] =» «EXPR> Eo I[X Y] '(= x V»~ (54-606) The explict use of Yz. from our present analysis. 54-602 fails on our new definition. The· closure was closed in Eo long before the reduction of Yz took place. however. If following code would have no visible effect: (SET EQ EQ) EQ was already defined. the extended environment is thrown away (normal-forms are environment-independent). 54-602 would simplify. For example. that the following would be equivalent in effect: (SET EQ :a) (S4-603) 54-602. thus when it is nOffilaliscd in this extended environment. even though it employs complexity unnecessary to the circumstance. which in 2-lISP we have initially bound to the atom ":".4. no power would be lost (it: in other words. the (54-607) In this onc case. difference in their behaviours. such as simply to give to one name the significance of another. equality closure: «EXPR> Eo '[X Y] '(= In particular. in other words. and thus in one sense correct. But = is bound to a nonnal-fonn closure. :it should be admitted. and this is how we wilt proceed. the following is different in consequence: . 'The following would suffice: :I) (DEFINE EQ (S4-602) Now it follows. for that there is one minor. 2-lISP: A Rationalised Dialect Procedural Reflection 439 it for simpler purposes. we could always simply use 54-603). in other words. comptet~ness. There would seem no disadvantage in using DEFINE in all cases.

We said earlier that we would discuss at a later point the issue of how the names of recursively-defined procedures could be made available to a wider context. in particular. We llave. Furthennore.4. definitions being thought in some way to be remarkable a view we are trying to dismantle. thus embedding a potentially more complex context within the intension of the function defined. however.c. the present suggestions show how that question has reduced to one of making any structure or binding public. 54-608 will derme a viciously circular procedure. In particular. 2-LISP: A Rationalised Dialect Procedural Reflection. What we intend to do in this particular section is to explore to its lim\ts the question of constructing fUllction designators. We have demonstrated. There are. although it of course is hardly a seriously limitation (furthermore the explicit use of the simpler SET is always possible). independent of the binding of A in that argument's context For example: (LET [[A 3]] (INCREMENT A» 4 (54-611) Such an ability. since it expands to (SET EQ (Y z (LAMBDA EXPR [EO] EQ») (54=609) which is content-free. perhaps surprisingly. equivalent in effect to 54-610 is the following: (DEFINE INCREMENT (lET [[A 1]] (lAMBDA EXPR [N] (+ N A»» (54-612) . Thus we should employ DEFINE with this one proviso. 440 (DEFINE EQ EQ) (54=608) In particular. it is clearly possible to use DEFINE at other than the top level. consequences of our approach to naming that emerge from our analysis of names. the issue of providing generally available names is separate. is not available in any standard LISPS or in SCIIEME.a subject on its own which we will take up explicitly in section 4.vi. how to reduce questions of definitions and recursion (both single ~d multiple) to questions of setting variables . for example: (84-610) (LET [[A 1]] (DEFINE INCREMENT (LAMBDA EXPR [N] (+ N A»» where the resultant INCREMENT procedure will add the number 1 to its argument.

because of the conceptual inefficiency of Y2' it is useful to have shown the kind of behaviour it engenders. 2-LISP: A Rationalised Dialect INCREMENT Procedural Reflection something like an OWN 441 This gives the procedure variable (this is because the N- binding of A does not occur within the schematic scope of the LAMBDA. . but one instance of N per instance of INCREMENT). In other words. as there is for or to put it another way.R (LET [[COUNT 0]] (LAMBDA EXPR [] (BLOCK (SET COUNT (INCREMENT (PRINT COUNT»») yielding the following behaviour: (54-613) COU~T» > (COUNTER) ! > ST > (IF (COUNTER) (COUNTER) (COUNTER)) ! ! > ST (54-614) We have still some distance to go: we have not yet. But before turning to that. for example. as illustrated in the last few examples. hence there is an instance of A for the procedure as a whole. We could for example define a procedure that printed out how often it had been called: (DEFINE COUNTf. discussed procedures (sadly. 'Iltey provide an indication of the effect that any candidate treatment of recursion should honour. not a schematic instance. Yz will not work for recursive IMPRS). there is one A for all instances of INCREMENT. we should make a comment: although we will not ultimately adopt the definition of DEFINE inten~ional given in 54-699.4. Yz will be a behavioural guide as we search for nlore effective variants on Y.

in other words. type-equivalent and token-equivalent (i. especially in light of the intuition that recursive definitions have in some way to do with circularity.ii. In the A·calculus. efficiency is not an issue. But intuition does in fact stand. since the extension - the functions designated by the A-tenns - are of prime importance. 2-lISP: A Rationalised Dialect Procedural Reflection 442 The problems with Y2 have in part to do with efficiency - not implementational efficiency. What is true about these structures is that they are type-equivalent. apparently. but a deeper kind of conceptual inefficiency. since there is no intensionality or side-effects.4.b. each time the recursive self-name is used). more carefully. equal) structures are immaterially different It is of no consequence in the A-calculus. which reduced with other definitions that were pure trees. that we can eliminate syntactic recursion. This is best revealed by looking in more depth at how both work. as the example in chapter 2 illustrated). intuition not withstanding. itself: The full (infinite) normalisation of YI reduced with arguments. whether a structure is typc-circular or token-circular (or. if one knows lvhere 10 perfann the surgery.) applied (strictly. The Y operator does construct circular structure. . includes within it an infinite number of type-equivalent copies of We will say. that a closure returned by (VI F) is type-circular. introducing any structural circularity to do so (it is trivial to remove it using structural circularity. according to our definition of section 4. without. and at each application redoing this copying at infinitum.. without either Y or its arguments involving any circular or recursive use of selfnames. in other words. albeit of a particular sort. an examination of the definition of y1 reveal that the v operator works by constructing essentially indistinguishable copies of itself applied to the function in question. therefore. On the face of it we apparently y1 Y2 and constructed a successful fixed point function defined as a pure tree.e. it would be of no consequence: in fact token-circular structures cannot be constructed)t since no behaviour hinges on the token identity of any given expression. Yz differs from y1 in that the closures it yields defer the production of this infinite type-circular structure so that one more embedded level of it is produced each time the closure is . Similarly. More specifically. Thus it might seem that recursive definitions do not require circular structures. in other words. We have shown. The closures produced by applying y 2' therefore t we will call type-circular-deferred. in such a way that the required recursive procedures emerged.

First. that we will explore in turn. but misleading. as follows.4. in other words. This notation will handle both shared tails and genuinely circular structures. it is natural to ask whether it is not possible to define an extensionally equivalent variant of the Y operator that traffics in token-circular closures: closures x such that [X E ACCESSIBLE*(X)]. any occurrence of that label immediately preceded by a colon will stand in place of an occurrence of the pair following the place the label was defined. the definition of y use identity in place of type-equivalence. we will use italics for the former. To show this. This understanding leads to a variety of suggestions. 3 4) : J) (54-620) would be notated graphically as: (54-621) 11lis would be simply. However since they will not be complex. We will ignore seoping issues entirely (our examples will remain simple). We will assume that any atom x followed immediately (no spaces intervening) by a colon. will define what we will call a notational ltzlJel for that pair. TIluS the structure notated in this extended notation as follows: (+ J: (.making. we of course encounter a pedagogical difficulty: the resultant structures cannot be lexically notated. Similarly. N (:F (- N 1»») which has the following graphical notation: . To keep these notational labels separate from structural atoms. printed out in lhe regular notation as: (+ ($ 3 4) (. we wilt adopt a simple extension of the standard notation. followed by a pair or rail. it is instructive to imagine modifying the definition of y itself: so that the type- equivalellt structures within its definition are in fact identical . 3 4» (54-622) More interesting is the following structurally (token) circular definition of factorial: F: (LAMBDA EXPR [N] (IF (= N 0) 1 (54-623) (. 2-LISP: A Rationalised Dialect Procedural Reflection 443 Given this analysis.

.N 0) 1 (. We similarly had this definition of Y2: (DEFINE Yz (S4-628) (LAMBDA EXPR [FUN] «LAMBDA EXPR [Xl (FUN (X X») (LAMBDA EXPR [X] (LAMBDA EXPR ARGS «FUN (X X» .4.N1»»» (.N 0) (54-626) 1 (. ) terms are different.. but observe that there is no need for the first of these to be different. ) The first intuition. it would lead to the following infinite lexical item: (LAMBDA EXPR [N] (IF (. since this remains as non-tenninating as ever. then. 2-lISP: A Rationalised Dialect Procedural Reflection 444 (54-824) If we printed this out in the regular notation. N «LAMBDA EXPR [N] (IF (=. however. We start with (DEFINE VI (LAMBDA EXPR [rUN] «LAMBDA EXPR [Xl (rUN (X X)}) (LAMBDA EXPR [Xl (rUN (X X»»» Y1. because of the processing deferral. thus the following is .N1»» . ARGS»») The two main (LAMBDA EXPR [Xl . N «LAMBDA EXPR [N] (. The original definition was this: (S4-626) Collapsing the largest type-equivalent stnJctures yields: (DEFINE VI (S4-621) (LAMBDA EXPR [FUN] (K: (LAMBDA EXPR [Xl (FUN (X X») :K») No particular mileage is obtained.. is to make the type-equivalent parts of the definition of the various Y operators in fact identical..

since it is the application of G to G that we are concerned with: (DEFINE Y2d (54=632) (LAMBDA EXPR [FUN] (K: (LAMBDA EXPR ARGS «fUN :K) • ARGS»») Furthermore. 2-lISP: A Rationalised Dialect Procedural Reflection 445 essentially similar: (DEFINE Y2a (54=029) (LAMBDA EXPR [FUN] «LAMBDA EXPR [X] (LAMBDA EXPR ARGS «FUN (X X» • ARGS») (LAMBDA EXPR [Xl (LAMBDA EXPR ARGS «FUN (X X» . ARGS»») We can now collapse this: (DEFINE Y2b (S4a:630j (LAMBDA EXPR [FUN] (G: (LAMBDA EXPR [X] (LAMBDA EXPR ARGS «FUN (X X» . since it is counts as a distinct version: (DEFINE Y3 (54-633) (LAMBDA EXPR [FUN] K: (FUN (LAMBDA EXPR ARGS (:K • ARGS»») . We will call this Y3 for discussion. and the reduction of G with itself happens directly. where possible. (DEFINE Y2c Thus we get: (54=631) (LAMBDA EXPR [FUN] (G: (LAMBDA EXPR [Xl (LAMBDA EXPR ARGS «FUN (:6 :6» . In particular. In other words we are attempting to minimise the structure in Y2: collapsing type-equivalent structure does part of that task. we can go back to the original style whereby the first application does not wait for arguments.4. ARGS») :G» But this whole thing can collapse. applying p-rcductions in non-appllcative order. ARGS») :G» But now it becomes natural to begin to collapse the reductions - to do the implied fl- reductions. x will be bound to the structure labelled G. helps as well.

. and it wiil return 720. Y3' in contrast. both declaratively and procedurally for any singlyrecursive extt:nsional procedure~ ( (Y3 Ii) 6) can be shown to designate 720.-de[erred. (Y3 Ii) Y3' H as our example. Furthennore. Yz. we have shown that the Y opera~or is ilself. because it shows us how type-identity has covered for a lack of primitive circularity in circular behaviour f-Qffi d tree-stnlctured formalism. But there is something still a little odd. and will look first at We begin willi: (54"636) Y3 Substituting the normal-form closure of «<EXPR) Eo H) from EXPR S4-634: AnGS (:K J • '[FUN] 'K J : (FUN (l.AMODA ARGS»» (54-637) .LAMBDA EXPR ARGS (:K • ARGS»» (54-634) This closure has the following graphical notation: (54-636) ARGS is again an adequate Y operator. it would be more powerful if we can define still another version of the: =>perator y4 that generated luken-circular closures. to an examinatioll of the intensional form of the procedures that each version of Y returns. We will initially use our latest version. 111is result is useful. 2-lISP: A Rationalised Dialect Procedural Reflection 446 The normal form version of y3 is thus: «EXPR) ~ '[FUN] 'K:(FUN . therefore. is token circu/o.rcula. We needn't care how Y itself is structured: 'He ought to be more interested in the structure of the procedures Y returns. and Y3 generate type-circular closures. in the deepest sense. by collapsing type-identities onto individual identities.. circular. it is evident that if a function is in a deep sense circular. VI.4. In other words we have seen that the definitions of VI and Y2 are themselves type-c. it may be able to engender essentially a non-circular argument But it would be more to the point if we could show another version of this same thing: how all of these Y operators. We will turn. Additionally. The inherent circularity in the Y V3 t operator has been brought out.

Rather than use a particular we have results to use a generic single-argument function of fonn: (54-642) (LAMBDA EXPR [<LABEL>] <FORM» .»] ..N 1»»» (LAMBDA EXPR ARGS (K J : (FUN (LAMBDA EXPR ARGS) (:K J • ARGS» . and normalise the body of the closure being reduced yielding our answer. because we interpret through the pair that we have notated with K. Eo] (54=641) 'ARGS '(K J : (FUN (LAMBDA EXPR ARGS) (:K J ..4. 2-lISP: A Rationalised Dialect H. Eo] ARGS» • ARGS») 'ARGS '( KJ : (FUN (LAMBDA EXPR ARGS) (: ' •. ARGS)] • ARGS» . we can bind this to FACT. we get the following (this is slightly subtle.N 0) 1 (* N (FACT (. Procedural Reflection 447 EXPR: Similarly we can expand the binding of since we arc about to reduce an «<EXPR) Eo '[FUN] • XJ : (FUN (LAMBDA EXPR ARGS (:K 1 • ARGS»» C<EXPR> Eo '[FACT] '(LAMbDA EXPR [N] (IF (. as indicated): «<EXPR) Eo '[FACT] EXPR [N] (IF (= N 0) 1 C* N (FACT (. (54-639) Once again.J Finally. nonetheless the internal use of it retains the full pair. noting that the reduction is of an we can nonnalise the single argument Eo This nonnalisation happens in an environment which is like is bound to the closure to which H expanded:: . so we illustrate the expanded environment: «EXPR> [['FACT «EXPR) [['FUN '«EXPR) Eo '[FACT] '(LAMBDA EXPR [N] :K..N 1»»») (54-639) Binding FUN to the second EXPR closure. N (FACT (. In this case the crucial thing is the binding of FACT.. ARGS») '(LAMBDA EXPR.. Eo] '[N]- 'K 3 : (IF (= N 0) 1 (..N 1»») rfhough we need not go through them in detail. and substituting that into lite body. N (FACT (.N 1»»» • «EXPR> [['FUN :Kz] . We cnd up with the results H summarised in the following illustrations. (K2 :«EXPR> Eo '[FACT] '(LAMBDA EXPR [N] except extended so that fUN (54-640) (IF (= N 0) 1 (. expansions for the other three varieties of y can be worked generalised <H> thc~e E Ollt in the same fashion.

A few steps through the reduction shows immediately the structure of the infinite descent... Although (Y t H) would never return. Expanding the H yields ( y 1 H) => K. since it is not in nonnal fonn. : ( <EXPR> <ENV> '[ < EL> ] '( FORM> ) : K) lAD <LABEL> (S4-660) If we do one more reduction by han<L we bind Assuming the structures of 54-643 to I( and nonnalised <FORM).) First we look at VI. apparently yields: . (54-647) But the argument to H here is type-equivalent to will generate more and more of: (!! (!! (!! ( .. we would have: K: (!! :K) (54-649) But this cannot be posited as the appropriate infinite closure.l!l.4. (VI H) We start with (54-644) which is equivalent to «LAMBDA EXPR [fUN] «LAMBDA EXPR [X] (FUN (X X») (LAMDRA EXPR [X] (rUN (X X»») H) (S4-646) Binding FUN to H and reducing yields (underlining is used to indicate inverse nonnalisation): (54-646) «LAMBDA EXPR [X] (ll (X X») (LAMBDA EXPR [X] (tl (X X»» Another reduction: (~ «LAMBDA EXPR [X] (~ (X X») (LAMBDA EXPR [Xl Ctl (X x»» 54-646. 2-lISP: A Rationalised Dialect Procedural Reflection 448 where for the time being we assume <FORM) a (LAMBDA EXPR <PATTERN) <BODY») (84-643) (fbis is limiting. hence it is apparent that (Y I H) (54-648) If we were to collapse type-equivalences into token identities.. and thereby terminate this infinite process. »» /. i!!. and we will generalise it presently.. it is easy enough to work out what it would return if we waited until the end of time.

Eo] . whatever.. Eo] '[Xl '(LAMBDA EXPR ARGS K :«FUN (X X» . after looking at A simple view of the result of normalising Y2 and va.. leads to the following notation..sed Dialect => «EXPR) [[' <LABEL> Procedural Reflection 449 (Y1 H) (S4-661) 'K:({<EXPR> <ENV> '[<LABEL>] '(FORM» . Eo] '[Xl '(LAMBDA EXPR ARGS «fUN (X X» .. (Y z H) => (<EXPR> (54-663) [['(LABEL) '«EXPR) [['X '«EXPR) [['FUN '«EXPR) Eo '[<LABEL>] '(FORM»] . :1(2)] .. ARGS»)] 2 :1(1 .. ARGS»] '(PATTERN) '<BODY» If we explicitly identify all shared structure we have: (Y z H) ~ «EXPR) (S4-664) [['<LABEL) '«EXPR> [['X '«EXPR> [KJ:['FUN '«EXPR> Eo '[<LABEL>] '(FORM»] . We will take it up belo\v.. (Y 2 H) more easily first understood without using our extended notation to indicate shared structure. Note that this is a finite structure because only one generation of the production of the infinite type-equivalent tree has been executed (this· is the essence of Yz generating deferred circular closures). 2-LISP: A RatioD&. the problem is that it is the result of an infinite computation..4. Eo] 'ARGS '«FUN (X X» ...1 was that we decided thus this should really be: (V t H) (Y J H) returned. <ENV>] '(PATTERN) '(BODY» :K)] But the point of K was to label the result... Eo] 'ARGS .. ARGS»)] ['FUN '{(EXPR> Eo '[<LABEL>] '(FORM»] .. => K: «EXPR> [[ '<LABEL> :K] . <ENV)] (54-662) '<PATTERN> '(BODY» This is in a sense ideal. however. Eo] ...

Eo] (54-668) '<PATTERN> '<BODY» . The behaviour we aim for.... the binding of FACT in the closed environment would be the overall closure.. If we were to achieve token circularity in the resultant closure. re-written in terms of abstract (PATTERN) and => «EXPR> [[' <LABEL) (54-666) '«EXPR) [['FUN '«EXPR> !! '[<LABEL>] '<FORM»] .. not - like in 54-657 - a closure that would engender a type-equivalent closure. 2-lISP: A Rationalised Dialect '(PATTERN) '(BODY» Procedural Reflection 450 Finally. in other words.4. is that produced after an infinite amount of processing by y1- The question is whether it is possible to define a version of Y called y4 that would be procedurally finite but ccmputationally equivalent in result: (Y 4 <H» => K: «EXPR> [[. <LABEL> : K] .. Eo] '(PATTERN) '(BODY» • ARGS») In graphical fonn: (54-667) ARGS From this last it becomes plain how both (Y2 H) and (Y3 H) fail to be what we want. Eo] 'ARGS '(KJ : (FUN (LAMBDA EXPR ARGS (:K J . ARGS)] . the result obtained above in <BODY>: (Y3 H) 54-641.

.: ~ere ar~ many reasons. the following: (FORM) • (LAMBDA EXPR <PATTERN) <BODY» VI. a single-function version is (54-663) tClOSUR~) (LAMBDA EXPR [FUN] (LET [[CLOSURE t(FUN '1)]] (BLOCK (RPLACN 2 (1ST t(IST (CDR CLOSURE}» ~CLOSURE»» . 2-LISP: A Rationalised Dialect Procedural Reflection 451 In graphical fonn would be this: (54-669) This is particularly mandated because Vt (and hence by assumption Y4) works correctly with intensional procedures.. but there is no help in this.:/. The problem is that both Yz and V3 yield processing-deferred closures. ~""~~' . (54-662) then an adequate. It would be possible to complicate the definition so that ( Yz (LAMBDA H) would retur