






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







Proc. of the IJCAI’95 Workshop on Reflection and Metalevel Architectures and their Applications in AI. pp. 29–38. August 1995
D´epartement d’informatique et de recherche op´erationnelle Universit´e de Montr´eal, Montr´eal, Qu´ebec, CANADA
Abstract
Reflection is a wide-ranging concept that has been studied independently in many different areas of science in general, and computer science in particular. Even in the sub-area of programming languages, it has been applied to differ- ent paradigms, especially the logic, functional and object- oriented ones. Partly because of different past influences, but also because researchers in these communities scarcely talk to each others, concepts have evolved separately, sometimes to the point where it is hard for people in one community to recognize similarities in the work of others, not to speak about cross-fertilization among them. In this paper, we pro- pose a synthesis covering mainly the application of computa- tion reflection to programming languages. We compare the different approaches and try to identify similar concepts hid- den behind different names or constructs. We also point out the different emphasis that has been given to different con- cepts in each of them. We do not claim neither completeness nor closeness in our treatment. We rather aim at building bridges between programming languages communities, and address other aspects when they appear relevant.
1 Introduction
Reflection has long been studied in philosophy and formal- ized to some extent in logic [Fef62]. It arised naturally in arti- ficial intelligence, where it is intimately linked to the end goal itself: reflection is viewed as the emergent property respon- sible, at least in part, for what is considered an “intelligent behavior”. Perhaps surprisingly, it has been also applied in the area of programming languages under the name of com- putational reflection. Computational reflection dates from Brian Smith’s seminal work in the early 80s [Smi82, Smi84]. In his way to formalize the concept of reflection, he devel- oped two languages: 2-Lisp and 3-Lisp. Although Smith gave much more attention to the representation relation he called φ that a computational process bears to its subject domain, his work quickly became famous in the functional community for the ability 3-Lisp was giving to a program to reflect about its own computation using reflective towers.
This approach inspired much work in the functional pro- gramming community until the late 80s, probably because reflection was growing in a fertile ground. Thanks to its quote construct, Lisp is famous for its metalinguistic power. It allowed from its very beginning the manipulation and exe- cution of program fragments, which are a primitive manifes-
∗ (^) Authors’ current address : C.P. 6128, Succursale Centre-ville, Montr´eal, Qu´ebec, Canada H3C 3J7, phone : (514) 343-7479, fax : (514) 343-5834, e-mail : {demers,malenfan}@iro.umontreal.ca This research has been supported by FCAR-Qu´ebec and NSERC-Canada.
tation of reflective concepts. Lisp metacircular interpreters were also widely explored and debated. The Lisp commu- nity therefore had a long experience with the kind of things reflection wanted to enable. By the beginning of the 90s, it was becoming quite clear that in order to master the inherent complexity of a fully re- flective programming language, structuring mechanisms were badly needed. The object-oriented paradigm imposed itself to take up the challenge. This trend was not completely innocent. A whole subset of the object-oriented commu- nity has been profoundly influenced by Lisp, especially the one revolving around Smalltalk and naturally, around object- oriented extensions of Lisp itself (the quintessence of which being the Common Lisp Object System, CLOS). In fact, some of the proeminent persons in the OO community are the same that were very influential in the Lisp one a decade before. But, the implementation of the original concepts in this new paradigm prove to be different enough to make it difficult to relate them to the functional ones. Unsurpris- ingly, Smalltalk is one of the most reflective language, with its “object-to-the-bottom” principle, unfortunately mostly ignoring itself as such. The Metaobject Protocol of CLOS is the most achieved reflective programming language and system to date. Quite independently, the logic programming community become interested in concepts near to the reflective ones, es- pecially metaprogramming. As Lisp, Prolog included from its very first implementations mechanisms for the manipu- lation of programs at run-time, therefore enabling metapro- gramming: metavariables are used to transform a term into a goal and thus play the role of apply, clauses are accessi- ble through the system predicate clause/2 (not to speak about the debated assert/1 and retract/1), which re- turns them in the form of terms, themselves inspectable through the system predicates =../2, arg/3 and functor/3. Metaprogramming quickly became so common in Prolog that any self-respecting textbook includes the so-called vanilla meta-interpreter for Prolog written in three clauses (see, for example, [SS86]). A series of conferences devoted exclu- sively to metaprogramming in logic has also been organized [AR89, Bru90, Pet92, MET94]. Finally, the new language G¨odel [HL94] has been designed with the aim of making metaprogramming more declarative, by implementing prim- itively the manipulation of terms in a ground representation (see §3.2.1). The development of reflection independently in three dif- ferent programming paradigms makes it difficult to under- stand the relationship between similar concepts expressed in different ways from community to community, and even from language to language. The goal of the present paper is to compare and contrast some of the reflective languages and
more generally results coming from the three communities. We do not claim to address all aspects of such a compari- son in this short paper, but rather to build bridges between communities by sharing our experience of being involved in the three for almost eight years. We don’t concentrate on computational reflection in programming languages either, but we rather address some other work relevant to our goal.
The rest of the paper is organized as follows. The next section introduces the terminology and concepts of compu- tational reflection. The Section 3 presents the design of sev- eral reflective languages in the three paradigms of logic, func- tional and object-oriented programming. The Section 4 dis- cusses some formal notions associated to computational re- flection, such as the notion of reflection coming from logic as well as some attempts to give a formal semantics of reflective programming languages. We then draw some conclusions.
2 Terminology and basic concepts
For a long time, terminology and basic concepts have been the Achille’s heel of computational reflection. As noted ear- lier, the actual implementation of reflection in programming languages uses a lot of techniques and mechanisms that ex- isted a long time before reflection: the ability to manipulate programs as run-time data, the ability to inspect data struc- tures at run-time (such as terms in Prolog), first-class enti- ties, metaprogramming, etc. In the past years, we have seen a tendency to mix reflection and the use of these techniques. In a sense, the tools were taken for the concept. A link cer- tainly exists between first-class entites, higher-order func- tions, metaprogramming and reflection, but no one stands for the other.
Reflection has been defined in a fairly general way by Brian Smith during the ECOOP/OOPSLA’90 workshop on reflec- tion [WRM90]:
“An entity’s integral ability to represent, operate on, and otherwise deal with its self in the same way that it represents, operates on and deals with its primary subject matter.”
In programming languages, the incarnation of this defini- tion appears as follows [BGW93]:
“Reflection is the ability of a program to manipulate as data something representing the state of the program during its own execution. There are two aspects of such manipulation : introspection and intercession. Intro- spection is the ability for a program to observe and there- fore reason about its own state. Intercession is the abil- ity for a program to modify its own execution state or alter its own interpretation or meaning. Both aspects re- quire a mechanism for encoding execution state as data; providing such an encoding is called reification.”
Reification must be distinguished from first-class entities. When an entity is first-class in a language, it means that this entity can be created at run-time, passed as actual pa- rameters to procedures, returned as result of a function and stored in a variable. All what is needed is to provide pro- grams with values of a suitable abstract data type defined by the language. In functional languages, functions are first- class for example. It means that functions (actually closures) are values that can be manipulated as any other values in the language. Reification goes well beyond by imposing that we have complete control over this value in the language itself. In particular, we should be able to modify its representation using the language itself. We should also be able to inspect it
at run-time. Making an entity first-class is strictly included in its reification, but not the opposite. Coming back to reflection, Pattie Maes gave in her thesis [Mae87] the following definitions that summarize pretty well the notion of reflection in computational systems:
Although meta-interpreters have been used intensively in the implementation of reflective systems, metaprogramming is not reflection. But note that, in reflection, accessing the metalevel representation is done on purpose, to perform some task. The metaprogramming approach gives the program- mer access to this representation because he has his hand on the meta-interpreter, which he can change to perform the task he was originally intending to do. Reflection goes the other way around. An implementation pre-exist to which we have no access, except from the program itself, by reflection. Metaprogramming played an important role in the imple- mentation of reflective languages because, in practice, it is difficult to access the metalevel information in an existing language, where typically the implementation is completely sealed. A meta-interpreter is interesting because it is much easier to make its data available to the programs it runs than modifying the language’s implementation. Maes said [Mae87]: “The main difference between a meta- level architecture and a reflective architecture is that a meta- level architecture only provides static access to the represen- tation of the computational system, while a reflective archi- tecture also provides a dynamic access to this representa- tion.” The kind of change we can do in the metaprogram- ming approach is to modify the meta-interpreter prior the execution of the program. Reflection on the other hand al- lows the program to change its behavior while running, de- pending upon its current execution (such as the inputs and intermediate results). In computational reflection, a distinction is traditionally made between structural and behavioral reflection. The two concepts are defined as follows:
terpreter is spawn with the given initial state and the state of the one currently executing is pushed into the metacon- tinuation. When the interpreter below invokes a reflective procedure, a thunk is built from the reflective procedures and is passed to the metacontinuation to be run one level higher in the tower. On the other hand, if the interpreter below returns, the first continuation in the metacontinua- tion is restored so that the intepreter above is restarted at the point it stopped when the lower one was spawned.
The Brown experience gave the whole reflection commu- nity much insights into computational reflection, but it actu- ally failed to reach its goal to give a denotational account of reflection in a way we will explain in Section 4. After Fried- man and Wand, Danvy and Malmkjaer pursued the work and proposed the language Blond [DM88]. Blond is similar to Brown except in some specific aspects. Brown turned out to be flawed in the treatment of environments, a problem solved in Blond. Also, Blond made a distinction between what it calls pushy and jumpy continuations in the man- agement of metacontinuations. Three other languages con- tributed to this school of reflection: Stepper [Baw88], and more recently IR [JF92] and Black [AMY93].
3.2 Logic programming
All the different issues mentionned earlier (esp. in 3.1) have also been studied in logic programming but under different names. We look at them (and also new one) in the following.
In logic programming, structural reflection has been the first one to be introduced. The main concern at that time was to facilitate the problem of managing system’s database of clauses. The predicates clause/1, assert/1, retract/ and call/1 are good examples of procedures used in Prolog for structural reflection because with them, goals and clauses are treated as first-class objects represented by terms. Com- putational reflection has been studied to respect the con- ceptual basis of logic programming that is logic programs are theories and execution is deduction. The need is for an ability to explicitly refer to theories (leading to struc- tural reflection) and to “discuss” derivability from their the- ories (leading to computational reflection). The main ap- proach was then to construct a system which amalgamates an object-level logic system L with a metalanguage M suit- able for formalizing the derivability relation of the original object language system. The resulting system is more ex- pressive and problem-solving power than the original object language system alone. As said in [Bow82] (and similarly in [Wey80]), the amalgamation of languages L and M consists of L and M together with
T h ⊢M Demo(A′, B′) A ⊢L B
and
T h ⊢M Demo(A′, B′)
A reflective system which respects these particularities is said to be an amalgamating language [Bow82] [Dem94].
Some reflective systems have been created in a way that they could be called amalgamating systems: metaProlog [Bow85], Reflective Prolog [CL89] and the different 3-Prolog languages [Dem94]^2. These systems are concerned mainly with the representation of the predicate Demo presented earlier. However all these amalgamating systems are relatively in- efficient (because of the meta-programming techniques they use). For this reason, some people have tried to create non-amalgamating ones. Although the latters are all much less powerful than the preceding ones because the pred- icate Demo is not entirely explicitly represented (by T h), they integrate reflective mechanisms useful for certains log- ical applications. Examples of the non-amalgamating sys- tems are FOL [Wey80], R-Prolog* [Sug90], CPU [LMN91] and ALPES-IProlog [BCL+^ 88]. Most of these systems have tried especially to resolve practically and theoritically prob- lems related to the logical representation of goals, clauses and variables.
3.2.1 Quote mechanism
As we said earlier, in reflective systems a quote mechanism is essential. But this naming relation has been implemented in different ways and with different power. The most nat- ural implementation is to represent all reflective objects as logical terms in the language. This technique is used in most Prolog implementation, and it expects object-level variables that are represented by meta-level variables. This repre- sentation is said to be non-ground. In the language G¨odel [HL94], a ground representation (object-level variables are represented by ground logical terms) is preferred to make the quote mechanism completely uniform (all meta-objects are terms) and most powerful. This quote mechanism is used in the reflective systems metaProlog of Bowen (and a simi- lar language GCP [Chr90] which is not said to be reflective even if it has some reflective features) and in some of the set of 3-Prolog languages. However the ground representa- tion is not efficient (not until now maybe in a near future [HL94] by using efficient concurrency and partial evaluation [Gal93]) because in the Demo definition, all the substitution procedure must be simulated, a process which is very co- suming in time and space. For this reason, most reflective languages uses a quote mechanism less powerful but much more efficient (for example by using non-ground representa- tion). This is the case of the systems R-Prolog* (it uses lists as meta-level representation for reflective objects), Reflective Prolog, CPU, ALPES-IProlog and some simple 3-Prolog lan- guages. In some languages, the quote mechanism is also used to create an explicit distinction (as two types) between object- level terms and meta-level terms. This is the case for the lan- guages R-Prolog*, metaProlog and some 3-Prolog languages. In metaProlog, the distinction is made in a similar way than in G¨odel (where all terms are statically typed) by consider- ing the term used for representing object-level variables as special and unique.
3.2.2 Reflective mechanism
It has to be noted that all but one reflective languages use explicit reflective mechanism with reflective pro- cedures. These procedures (called reflective predicates (^2) In this paper, we have written several different reflective languages with different degrees of reification: 3-PrologP reifies the object- level program clauses (and possibly Demo), 3-PrologU reifies the sub- stitutions made by unification, 3-PrologR reifies the resolvent and 3-Prolog* reifies all the different previous structures and implements an infinite reflective tower as in 3-Lisp.
in R-Prolog* and 3-Prolog) could be specified explicitly in the program (by goals). Or some predicates are said to be reflective because they contain in their definition some explicit use of upward and downward reflection which are specific predicates creating causal connection and access to reflective structures. This is the case of the languages CPU and ALPES-IProlog. Only one language (Reflective Prolog [CL89]) uses an implicit reflective mechanism which is made by defining reflective operations as metalevel defini- tions and taking care of reflective calls by an extended reso- lution procedure.
3.2.3 Reification and reflection
The last issue most important for reflective languages is causal connection. In logic programming, this mechanism is implemented in two different ways: by using special predi- cates or by using specific parameters to reflective predicates. The former creates an indirect causal connection and the latter, a direct one. An indirect causal connection is a transfert in two directions (usually up and down) of reflective information made at different time of execution. A direct one is rather about at the same moment. In most logical reflec- tive languages, indirect causal connection is used because it is easier to implement. For example, in CPU [LMN91], the reflection mechanism triggers the computation from the object-level to the meta-level domain by upward reflec- tion (a predicate reflect up) and vice versa downward reflection (a predicate reflect down). These two mecha- nisms are not executed at the same time as they should be done virtually: upward reflection is made first (to “read” reflective structures) and later in the execution, downward reflection is made (to “write” them back). Comparable in- direct causal connection mechanisms are used in metaPro- log, ALPES-IProlog and Reflective Prolog. In one way in- direct causal connection could be compared with reflection and reification mechanisms used in functional programming.
The direct causal connection is used in R-Prolog* and the different languages 3-Prolog. It works as follows: reflective predicates receive additional parameters containing the dif- ferent reflective information (down) and other additional pa- rameters (up) which represent reflective information after modification (by reflective predicates execution).
3.3 Object-oriented programming
Two major trends single out in the history of object-oriented programming. The first, examplified by Simula-67, C++, Eiffel and Beta, is shaped by software engineering and mod- ularity principles. It led to typed languages and is charac- terized by a relatively rigid object model alien to reflective concepts. The second trend, born in the world of untyped and already partly structurally reflective languages. It led to much more flexible languages where classes are typically treated as first-class entities. This trend is examplified by Smalltalk as well as object-oriented extensions of Lisp: Fla- vors, Loops, Ceyx, and CLOS. This second trend is playing a major role in reflection.
3.3.1 Structural reflection in OOP
The evolution of flexible object-oriented languages has been first marked by a quest for the right metaclass/class/instance model that led to a full notion of structural reflection in what concerns the object model of the language. In summary, the history stands as follows. Smalltalk-72 already included the idea that everything should be an object, even a class. The
class introduces structural reflection in the sense that it de- scribes the structure of an object. Smalltalk-72 made classes first-class entities, but yet they were considered as instances of themselves. Besides including inheritance, Smalltalk- introduced metaclasses, classes of classes. Note that in OOP, each object has a class, which is called its instantiation class. As an object, the Smalltalk-76 class has its own instantiation class called its metaclass. Smalltalk-80 pursued this idea, but imposed some important limits on metaclasses [Coi87]:
3.3.2 Towards full reflection
Unsurprisingly, Smalltalk is one of the most reflective lan- guage to date, unfortunately mostly ignoring itself as such. With its “object-to-the-bottom” principle, Smalltalk pio- nnered a design principle basic to reflection, which is that ev- erything should be expressed in the terms of the language it- self. On the other hand, Smalltalk was not designed with the aim of making this organization so manifest in the language to incite people to use and modify it, a goal pursued by re- flection. For reflection practionners, it became obvious that a static description of the language in terms of classes and objects, although necessary to properly organize things, was not enough to enable a full fledged reflective programming paradigm. We need a manifest description of the protocols activating the different objects in order to execute the pro- gram. The Metaobject Protocol of CLOS [KRB91, GWB91] tries to achieve exactly that. It does not only describe the objects involved in the representation of the computational process, it also exhibits the protocols responsible for the ac- tual execution of the program.
3.3.3 Behavioral reflection in OOP
As we have seen, a behavioral reflection model must allow programs to intervene in the current execution in order to execute some reflective code that will analyse or modify the course of events. In functional programming, 3-Lisp invented reflective procedures for that. The vantage points where a program can reflect in 3-Lisp is at procedure invocation. In OOP, procedure invocation is traded for message passing. Hence, it is natural to use message passing as vantage points where to reflect, and to use methods to represent the re- flective code. The execution of a message is divided in two
work on it, mainly for efficiency reasons.^4
Admittedly, making the language processor fully accessible is a formidable challenge to our current implementation tech- nology. An interesting approach recently explored is to pro- vide the users with an open compiler through they could in- troduce modifications to the language’s semantics [LKRR92]. This approach has similar properties as the metaprogram- ming approach using metainterpreters: modifications can be done once before the program execution, so they cannot de- pend upon the current inputs or intermediate results. In Smalltalk, the compiler is part of the program run-time sys- tem, so it is theoretically possible to recompile part of the program at run-time, thus obviating the previous remark. Several languages have been proposed with a less powerful model of behavioral reflection, yet giving the programs access to the processor’s run-time data. In functional programming, 3-Lisp have popularized the reification of the standard func- tional processor’s registers containing the current expression (actually the argument structure), environment and contin- uation. A reflective procedure is passed these informations upon invocation. Reflective procedures are a weaker means to modify the language processors since their semantics can be viewed as actually inserting new lines of code into the processor itself. The same kind of approach has been tried successfully in the logic programming paradigm.
Moreover, two alternatives have been tried as far as the pair of opposite operations reification-reflection is concerned. Automatic pairing consists to have reflective procedure re- ceiving the run-time data as parameters and to reinstall them automatically when the reflective procedure returns control to the interpreter. The other alternative, the manual one, consists to provide two primitives, one that reads the data and returns it in a reified form, and the second that takes a reified representation of the data and reinstalls it into the processor’s internal data structure. A last point concerning the comparison between logic, functional and object-oriented behavioral reflection concerns the presence or absence of reflective towers. Pionnered by 3- Lisp, it was not obvious that reflective towers were involved in other forms of behavioral reflection, such as the one imple- mented in OOP languages. Interestingly, des Rivi`eres [dR90] has shown that the CLOS MOP includes in fact a reflective tower hidden within its reification of the generic function in- vocation protocol. A little later, Malenfant et al. [MDC94] have shown a similar result for languages using a more tradi- tional lookup◦apply reflective protocol also give rise to reflec- tive towers. Hence, reflective towers seem to be intimately linked to the current model of behavioral reflection, no mat- ter what is the underlying programming paradigm.
3.4.3 Methodology of reflective computation
Ideally, a reflective language should support a methodology of reflective computation giving its users as much flexibility as possible. It should be possible to modify the behavior of some construct for the whole execution of a program, or for short period of (execution) time. It should also be possible to modify the behavior of some construct for all the program only for some of its subparts. None of the language currently proposed achieves this level of flexibility.
In functional programming and logic programming, the main efforts revolved around reflective procedure that are called at some point during the computation. Upon the end
(^4) Some people still work on making the language G¨odel (which rei- fies the full derivability relation [HL94]) as efficient as Prolog by using partial evaluation and parallel implementation techniques. Unfortu- nately this is not achieved yet.
of this reflective computation, the base level is restarted per- haps in a new state resulting from the reflective computation itself. All the meta-interpreters in the towers are the same and stay unchanged during the whole execution. As a re- sult, the kind of reflective computation of these models have been restricted to punctual intervention during the execu- tion. 3-Prolog [Dem94] is a notable exception to this since it allows the program to specify that some reflective predi- cates must be called repeatedly, without having to explicitly insert calls to them within the program code. A repeated reflective predicate will be called between each reduction of the 3-Prolog metalevel solver. No other language based on reflective procedures considered this kind of behavior. In OOP, the main efforts revolved around local reflection. In the lookup◦apply approach, lookup methods are redefined locally for some objects only while apply methods are rede- fined locally for some methods only. Similarly, in the reified generic function approach, the invocation protocol is changed locally, in a per generic function way. As a result, the kind of reflective computation you can do is also restricted; it is awkward to change one aspect of the implementation for all the objects. An open research problem is to decide what is the scope of a change in the lookup and apply methods and reflective computation in general [Fer89]. Should they be attached to individual objects, to classes (and apply to all their instances), to metaclasses (and apply to the instances of all its class instances) to individual messages (and apply only to one call)? As noted previously, the ideal complete reification of lan- guage’s processor has stayed out of reach mainly for effi- ciency reasons. Consequently, modifications spawning over the whole program execution are difficult to implement. With the reified compiler approach, it becomes possible to modify the semantics of the language in a per construct ba- sis. However, very few such experiences have been reported yet.
4 Formal notions for Reflection
We discuss here of formal notions used to characterize re- flection in programming languages of the three different paradigm, preceded by a historical discussion of reflection in logic freely inspired by [Per85, Per88], [Wey80], [Bow82], [Fef62] and [Cos90].
4.1 Historical discussion
Gottlieb Frege developed the first formal quantificational logic over a period of more than two decades culminating in 1903. The idea was to have a universal language for logic. For Frege, an object c and the properties P it may have were all objects to be reasoned about in the same way, i.e., with the same basic rules and notations. Frege had certain comprehension axioms that specifically created object-notations “P ” for P , and stated that sentences us- ing properties as predicates could be equivalently rephrased using properties as objects. These axioms in effect state a relationship between a name and what it names [Per85]: Has(c, “P ”) ↔ P (c) or equivalently, but closer to Frege’s notation: c ∈ {x|P (x)} ↔ P (c). In the same year Bertrand Russell showed that Frege’s sys- tem was inconsistent. Russell then proposed that objects be arranged in a hierarchy with different notations and rules, thus avoiding the possibility of self-reference that led to the inconsistency in Frege’s system. The resulting “typed” (anal- ogy could be made with the notion of reflective tower which is also a way to avoid inconsistency in programming languages)
has as its first level of notations precisely that of Frege, but without the damaging axioms that created objects out of properties at the first level. For Russell, properties of first- level objects are to be viewed as second-level objects. For this reason we refer to first-order logic and higher-order log- ics. However as we know many significant concepts cannot be expressed at all with levels. The original simplicity and plausibility of Frege’s approach has then continued to attract interest, and much of modern logic has been motivated by efforts to revise it to preserve its desirable features while re- moving inconsistency. But what seems to be needed is an avoidance of separated levels altogether, so that all concepts are treated at the same (first) level. In fact it appears rea- sonable to allow a certain number of levels to be collapsed into first-order logic, and leave the rest out. It would not be desirable to collapse all levels into first-order logic because it is just what causes Russell’s paradox. The main problem was thus addressed in logic as the need to find a way to col- lapse all levels into one without contradiction, i.e. the need to have a self-referential or universal language. In [Per85], it has been said that quotation seems necessarily involved at some point if we are to have a self-describing language and to treat logical terms as some sort of first-class entities.
In a same way, other reflective notions (other than the ones going back to famous G¨odel incompleteness theorems in mathematical logic) have been introduced related to sym- bolic logic in the sixties. The main idea was concerned with the “reflection principles” mentioned earlier. The concept of reflection principle was introduced by Feferman [Fef62] where it was intended as “the description of a procedure for adding to any set of axioms A certain new axioms whose validity follows from the validity of the axioms A and which formally express, in the language of A, evident consequences of the assumption that all the theorems of A are valid”. Later in [Kre68], different reflection principles are discussed for es- tablishing the complexity of different axiomatic systems. In particular, Kreisel says:
“Turning now to uses of reflection principles we recall two from the literature. First given a system S that has been recognized to be sound, reflection principles provide a systematic method for constructing stronger systems [... ]. Second, they provide a method for comparing the strength of formal systems. Thus, if S ⊆ U (where U is another system) and if the reflection principle RS 5 can be proved in U then U has more theorems than S. What makes reflection principles useful is that they have a clear intuitive meaning, and so, if such a principle is provable in U , we have a good chance of finding a proof.”
4.2 Logic for computation
A more pragmatic form of reflection principles, based on a different naming mechanism, was proposed by Weyhrauch [Wey80] and then in [Bow82]. We have already discussed the reflective principles presented in the latter. In practice, this approach leads to explicit reflection, that is, explicit calls to Demo must appear in clauses to specify that a goal should be attempted at the metalevel. These results remind clearly the need of meta-programming facilities to amalgamate object- level with some meta-level languages.
In Perlis [Per85], a theory of “quotation” and “unquota- tion” is presented to refer to certain statements as true and false. The author concentrates on the importance of the roles of truth and self-reference in commonsense reasoning. In his following article [Per88], he has showed that modal logics
(^5) A suitable one that is called local reflection principle for S by the author.
are on no firmer ground than first-order ones when equally endowed with substitutive self-reference. Thus his work has tried to understand the relationship between self-reference and modal logic.
4.2.1 Declarative semantics in the logical style
The next attempts to formalize of reflection are very close to the classical Horn-clause language semantics [Llo87]. In [Cos90], the declarative and procedural semantics of the Re- flective Prolog [CL89], which, on the basis of a naming mech- anism (that allows the representation of terms and atomic formulas), makes a different use of amagamating languages’ reflection, both procedurally and semantically. Declarative semantics is defined in a model-theoretic fashion, providing a least model semantics based on the definition of a con- cept of Reflective Herbrand Model of a theory. The least reflective Herbrand model is then characterized as the least fixpoint of a suitable mapping, in order to provide a link between the declarative and procedural semantics of a pro- gram. Derivation by resolution is extended to include forms of implicit reflection to shift between levels. Extended reso- lution is proved sound and complete with respect to the least reflective Herbrand model of a program. In [Sug90], a declarative semantics of R-Prolog* is dis- cussed. Because computational reflection is a sort of proce- dural notion, the usual declarative semantics given as logical consequence of programs cannot be adopted. In order to in- corporate a procedural aspect of reflective computation, the notion of interpretations and models is extended based on the equivalence classes of syntactic objects. They prove sound- ness and completeness of their R-refutation mechanism with respect to the declarative semantics defined. However, that reflective operations in R-Prolog* could lead to somewhat dangerous situations which are not studied semantically. In [Chr90], a declarative semantics of a meta-programming language (called GCP ) concerned with metagoals is pro- posed. Although this language does not say offering com- putational reflection, it has a good structural reflection by using a kind of ground representation and also it is explic- itly compared with metaProlog [Bow85]. The development of the semantics presented is quite traditional [Llo87] ex- cept that the Herbrand interpretations defined are said to be concerned with metagoals instead of with goals. It seems however that it is similar to the analysis of meta-programs made in [HL89] and [HL94].
4.3 Semantics in the functional style
In Section 3.1, we have presented the work of Friedman and Wand with the development of the different versions of Brown in response to 3-Lisp. In fact, as mentioned earlier, Wand and Friedman tried to settle a denotational account of reflective towers [FW84], which culminated with [WF88]. Smith has defended for a long time that the denotational framework was not the right tool to approach the problem. Although he essentially argued that denotational semantics was forcing the distinction in levels of designation to disap- pear, and thus evacuating the essence of reflection, the final word came from the observation that the compositionality principle of denotational semantics is irremediably impaired by reflection [DM88]. Hence, the denotational semantics ap- proach, even though it has been helpful to understand the nature of reflection, cannot fully express its semantics. New approaches must be sought to reach the goal.
[Bow85] K. A. Bowen. Meta-Level Programming and Knowl- edge Representation. New Generation Computing, 3:359–383, 1985. [Bru90] M. Bruynooghe, editor. Proceedings of the Second Workshop on Meta-programming in Logic. K.U. Leu- ven, Department of Comp. Sc., April 1990. [CF94] R. Cartwright and M. Felleisen. Extensible denota- tional language sepecifications. In Proc. of TACS’94, vol. 789. Springer-Verlag, LNSC, April 1994. [Chr90] H. Christiansen. Declarative Semantics of a Metapro- gramming Language. In [Bru90], pages 159–168, April 1990. [CL89] S. Costantini and G. A. Lanzarone. A metalogic pro- gramming language. In Proc. of the 6th Int. Confer- ence in Logic Prog. Workshop, 1989. [Coi87] P. Cointe. Metaclasses are First Class: the ObjVLisp Model. Proc. of OOPSLA’87, ACM Sigplan Not., 22(12):156–167, Dec. 1987. [Cos90] S. Costantini. Semantics of a metalogic programming language. Int. Journal on Foundations of Computer Science, 1(3), 1990. [Dem94] F.-N. Demers. R´eflexion de comportement et ´evaluation partielle en Prolog. Master’s thesis, U. de Montr´eal, DIRO, Avril 1994. Tech. report no. 956. [DM88] O. Danvy and K. Malmkjaer. Intensions and Ex- tensions in a Reflective Tower. In Proc. of ACM L&FP’88, pages 327–341, 1988. [dR90] J. des Rivieres. The Secret Tower of CLOS. In [WRM90]. [dRS84] J. des Rivieres and B. C. Smith. The implementation of procedurally reflective languages. In Proc. of ACM L&FP’84, pages 331–347, 1984. [Fef62] S. Feferman. Transfinite Recursive Progressions of Axiomatic Theories. Journal of Symbolic Logic, 27:259–316, 1962. [Fer89] J. Ferber. Computational Reflection in Class Based Object-Oriented Languages. Proc. of OOPSLA’89, ACM Sigplan Not., 24(10):317–326, Oct. 1989. [Fil94] A. Filinski. Representing monads. In Proc. of ACM POPL’94, pages 446–457, 1994. [FW84] D.P. Friedman and M. Wand. Reification: Reflection without Metaphysics. In Proc. of ACM L&FP’84, pages 348–355, 1984. [Gal93] J. Gallagher. Tutorial on specialisation of logic pro- grams. In Proc. of PEPM’93, pages 88–98, June 1993.
[GWB91] R.P. Gabriel, J.L. White, and D.G. Bobrow. CLOS: Integrating Object-Oriented and Functional Pro- gramming. Comm. of the ACM, 34(9):29–38, 1991.
[HD94] J. Hatcliff and O. Danvy. A generic account of continuation-passing styles. In Proc. of ACM POPL’94, pages 458–471, 1994. [HL89] P. M. Hill and J. W. Lloyd. Analysis of meta- programs. In [AR89]. [HL94] P. M. Hill and J. W. Lloyd. The G¨odel Programming Language. MIT Press, 1994. [JF92] S. Jefferson and D.P. Friedman. A Simple Reflective Interpreter. In [YS92], pages 48–58, 1992. [KRB91] G. Kiczales, J. Des Rivi`eres, and D. Bobrow. The Art of the Metaobject Protocol. MIT Press, 1991. [Kre68] G. Kreisel. Reflection principles and their use for es- tablishing the complexity of axiomatic systems. In Zeitschrift Fur Mathematische Logik und Grundla- gen der Mathematik, vol. 14, pages 97–142. 1968. [LKRR92] J. Lamping, G. Kiczales, L. Rodriguez, and E. Ruf. An Architecture for an Open Compiler. In [YS92], pages 95–106, 1992.
[Llo87] J. W. Lloyd. Foundations of Logic Programming: 2nd Edition. Springer-Verlag, 1987. [LMN91] E. Lamma, P. Mello, and A. Natali. Reflection mech- anisms for combining prolog databases. In Software Practice and Experience, 21(6), pages 603–624, 1991. [Mae87] P. Maes. Computational Reflection. PhD thesis, Vrije Universiteit Brussel, 1987. [MDC94] J. Malenfant, C. Dony, and P. Cointe. A Semantics of Introspection in a Reflective Prototype-Based Lan- guage. to appear in Lisp and Symbolic Computation. [MET94] Proc. of the fourth Workshop on Meta-programming in Logic. Springer-Verlag, LNCS 883, 1994. [MF93] A. Mendhekar and D.P. Friedman. Towards a Theory of Reflective Programming Languages. In [WRM93]. [MLV89] J. Malenfant, G. Lapalme, and J. Vaucher. ObjVPro- log: Metaclasses in Logic. In Proc. of ECOOP’89, pages 257–269. Cambridge U. Press, July 1989. [MLV90] J. Malenfant, G. Lapalme, and J. Vaucher. Meta- classes for Metaprogramming in Logic. In [Bru90], pages 257–271, April 1990. [MN88] P. Maes and D. Nardi, editors. Meta-Level Architec- tures and Reflection. North-Holland, 1988. [Mog91] E. Moggi. Notions of Computation and Monads. In- formation and Computation, 93(1), 1991. [Mog89] E. Moggi. Computational lambda-calculus and mon- ads. In Proc. of LICS’89. [Mul92] R. Muller. M-LISP: A Representation Independent Dialect of LISP with Reduction Semantics. ACM TOPLAS, 14(4):589–615, Oct. 1992. [Per85] D. Perlis. Languages with self-reference I: Foun- dations (or: We can have everything in first-order logic!). Artificial Intelligence, 25:301–322, 1985. [Per88] D. Perlis. Languages with self-reference II: Knowl- edge, Belief, and Modality. Artificial Intelligence, 34:179–212, 1988. [Pet92] A. Pettorossi, editor. Proceedings of the Third Workshop on Meta-programming in Logic. Springer- Verlag, LNCS 649, April 1992. [Smi82] B.C. Smith. Reflection and Semantics in a Procedural Language. Tech. Report 272, MIT, 1982. [Smi84] B.C. Smith. Reflection and Semantics in Lisp. In Proc. of ACM POPL’84, pages 23–35, 1984. [SS86] L. Sterling and E. Shapiro. The Art of Prolog. MIT Press, 1986. [Sug90] H. Sugano. Meta and reflective computation in logic programs and its semantics. In [Bru90]. [Wad90] P. L. Wadler. Comprehending monads. In Proc. of ACM L&FP’90, pages 61–78, 1990. [Wad92] P. L. Wadler. The essence of functional programming. In Proc. of ACM POPL’92, pages 1–14, 1992. [Wey80] R.W. Weyhrauch. Prolegomena to a Theory of Mech- anized Formal Reasoning. Artificial Intelligence, 13(1,2), 1980. [WF86] M. Wand and D. P. Friedman. The mystery of the tower revealed: a non-reflective description of the re- flective tower. In Proc. of ACM L&FP’86, 1986. [WF88] M. Wand and D. P. Friedman. The Mystery of the Tower Revealed: A Nonreflective Description of the Reflective Tower. Lisp and Symbolic Computation, 1(1):11–37, 1988. [WRM90] Proc. of the First Workshop on Reflection and Metalevel Architectures in Object-Oriented Program- ming, OOPSLA/ECOOP’90, Oct. 1990. [WRM91] Proc. of the Second Workshop on Reflection and Metalevel Architectures in Object-Oriented Program- ming, OOPSLA’91, Oct. 1991.
[WRM93] Proc. of the Third Workshop on Reflection and Metalevel Architectures in Object-Oriented Program- ming, OOPSLA’93, Oct. 1993. [YS92] A. Yonezawa and B. Smith, editors. Proc. of the In- ternational Workshop on New Models for Software Architecture ’92, Reflection and Meta-Level Archi- tecture, Nov. 1992.