| | Analysis | Requirements & Principles |
architecture: Paradigms |
substance: Abstractions |
structure: Domains | building blocks: Features |
surface: Syntactics | Defining PLs |
Language List | |||||
| foundational | safety |
flexibilized
| ||||||||||||
Checking rules are described in different styles:
A. Natural language.
B. Extensions of context-free grammars.
C. Inference rules, deductive systems (Post systems).
«Grammars are examples of formal systems. They are useful in
describing certain aspects of programming languages.
... Deductive systems are useful in various capacities in reasoning
about programming languages.
Deductive systems are rarely presented as grammars; they are more
often given as Post systems, named after Emil Post, who first used them.»
[Stansifer, 62]
--> General definition of Post systems as a formal, symbol-manipulating system.
(bcprules.sty -- a LaTeX style for type setting inference rules
by Benjamin Pierce)
Deductive systems infer the static type of a program term e
in the context of the types of the free identifiers in e.
The formal structure relating free identifiers with types
has variously described:
«Grammars are convenient enough for syntax that they are used by all communities: programmers, implementers, designers.
| proper subterms of e [for while: + fixed point operator] | subterms of e [for while: + recursion] | any constructed term [for while: "unfolding" using e's subterms]
eg. in denotational semantics
| eg. in big-step semantics
| eg. in small-step semantics, rewrite systems
| |
There are different styles of formal definition, using deduction rules for each syntactic construct which collectively define the semantics of program terms M, N etc, especially function definitions (lambda abstractions) fun(a)L (N'), in a data state s. As an example of comparison we use the rules defining function application (call) with call-by-value parameter passing.
For those semantics based on a deduction system (c.f. Post systems above), there are basically two dimensions of classification:
| Rel structure | term semantics [[M]] | [[M]] = | |
| rewrite steps | Term --> Term | { N | M --> ... --> N and N irreducible } | |
| complete rewrite | Term --> Ground | { N | M --> N } | |
| rewrite/valuation | (Term mix BaseVal) --> BaseVal | { X | M --> X } | |
| valuation | (Term mix Value) --> Generic | { v | M --> v } | |
| with state | |||
| rewrite steps | Term × State --> Term × State | { (s, (N, s')) | (M,s) --> ... --> (N, s') and (N, s') irreducible } | |
| complete rewrite | Term × State --> Ground × State | (Ground × State) | { (s, (N,s')) | (M,s) --> (N,s') } |
| rewrite/valuation | Term × State --> (Generic | ((Generic | { (s, (X,s')) | (M,s) --> (X,s') } |
| valuation | Term × State --> Value × State | { (s, (v,s')) | (M,s) --> (v,s') } | |
(M(N), s) --> (M'(N), s') | (fun(x)L (N), s) --> (fun(x)L (N'), s') |
|
(M, s) --> (fun(a)L, s');
(N, s') --> (x, s'');
(L, s''[x/a]) --> (y, s''')
|
|
(M, s) --> (f, s');
(N, s') --> (x, s'');
f(x) = y
|
``In comparing the denotational semantics with the operational semantics,
the denotational semantics does not seem to be much simpler.
It may even be argued that it is a great deal more complex,
because it requires an understanding of fixed points.
The primary advantage of the denotational semantics
is the intuitive explanation it provides [for OO inheritance].
It suggests that inheritance may be useful for other kinds
of recursive structures, like types and functions in addition to classes.
It reveals that inheritance, while a natural extension of existing mechanisms,,
does provide expressive power not found in conventional languages
by allowing more flexible use of the fixed point function.''
[William Cook, Jens Palsberg: A Denotational Semantics of Inheritance and its Correctness;
329-350 in: Information and Computing 114; 1994]
Normally, evaluation can be defined by rewriting the redex
(the basic term at the point-of-control).
Special, eg., exit in C:
E[exit v] --> v.
Or call/cc in Scheme:
E[call/cc F] --> F(
A state model for an OOPL has to relate
Some Techniques of Defining Computational Semantics
Evaluation context were used
first in M Felleisen, D Friedman, E Kohlbecker, B Duba:
Reasoning with continuations (131-141: Proc First Symposium on Logic in Computer Science; IEEE 1986)
and A syntactic theory of sequential control (205-237: Theoretical Computer Science 52(2); 1987)
val-from-F.abort(E[val-from-F]))
where
E[abort E] --> E.
OOPL State Models
[CfS] John Boyland, James Noble, William Retert: Capabilities for Sharing: A Generalisation of Uniqueness and Read-Only; ECOOP'01.
[PolyTOIL] Kim B Bruce, Adrian Fiech, Angela Schuett, Robert van Gent: PolyTOIL: A type-safe polymorphic object-oriented language; ACM Transactions on Programming Languages and Systems 2002.
[Joe] David Clarke, Sophia Drossopoulou: Ownership, Encapsulation and the Disjointness of Type and Effect; OOPSLA'02.
[OOC] David Clarke: Object Ownership & Containment; PhD thesis, Univ. of New South Wales 2001.
[OT] David G Clarke, John M Potter, James Nobel: Ownership Types for Flexible Alias Protection; OOPSLA'98.
[JTS] Sophia Drossopoulou, Susan Eisenbach: Java is Type Safe --- Probably; ECOOP'97.
[Univ] Peter Müuller, Arnd Poetzsch-Heffter: Universes: A Type System for Alias and Dependency Control; Informatik Berichte 279, Fernuniversitäat Hagen 2001.
[J/Isa] David von Oheimb: Analyzing Java in Isabelle/HOL: Formalization, Type Safety and Hoare Logic; Dissertation, Technische Universit&aauml'at Müunchen (Germany) 2001.
[JavaS] D Syme: Proving JavaS Type Soundness; Tech Report, Comp Lab, Univ of Camb 1997.
[Moby] Fisher, Reppy: Foundations for MOBY classes; Dec 1998.
A some OOPL state models and their terminology:
| instance variables, aka object fields | ||||||||
|---|---|---|---|---|---|---|---|---|
| OID -> Id -> TermVal
called (Object) Store [OT, Joe, CfS, Univ, Moby], or Store of Globals [J/Isa] | OID -> Id -> ValLoc + ValLoc -> TermVal | |||||||
| l o c a l s |
Id -> TermVal called |
|
|
| |||||
Rewriting logic [LTCO] is a logic for deducing how to rewrite terms based on a set of rewrite rules from a rewrite theory (see above) with the first four following deduction rules. Equational logic is obtained from rewriting logic by adding the symmetry rule.
| 1. Reflexivity: | M --> M |
2. Congurence [c.f. eager evaluation]: |
f(M1, ... Mn) --> f(N1, ... Nn)
| if M1 --> N1 through Mn --> Nn
|
3. Replacement for each rewrite rule f(x1, ... xn) --> g(x1, ... xn):
|
f[M1/x1, ... Mn/xn]
--> g[N1/x1, ... Nn/xn]
| if M1 --> N1 through Mn --> Nn
|
4. Transitivity: | M --> N | if M --> L and L --> N
|
5. Symmetry: | M --> N | if N --> M
| | |||
For a comprehensive overview over all the formal models
developed for reasoning about object-oriented language semantics
you must read:
Tom Mens: A survey on formal models for OO, 1994.
| | Analysis | Requirements & Principles | Paradigms | Abstractions | Domains | Features | foundational | safety | flexible typing | Syntactics | Defining PLs | Language List |