Towards a semantic theory for equational programming languages

model for (~, _~). ~1) A t is final in the category of all reachable (23, £)-algebras m which separable terms have distinct meanings. (2) A e is initial in the category of all algebras a~qigued by semantically abstract models of (~, _~) to £. The morphisms in both categories are of course approximable maps which are D-homomorphimns. II The category in (1) could be called the category of all 'reasonable implementations' of £. Finality may thus be a more useful characterization of uniquenem in this case than initiality. Invariance of senumtic equivalence and homomorphism acrcas program extensions are properties of full abstraction. Theca-em I: In the fully abstract model for (~t, -<), for each ~ we have: (i) I . ~ . o! e q . ~ . l e . : et It, l = t t 1~I imp"es eslt, l = es l~I for ~n S _~ ~. (2) Local homomorphism: :Rlt, I = e,~it,! impl~ :,~lc[q "tall = ~'t l¢l f 4"ball for all contexts (¢, q, £). (~) F. =e.ae~ homo. ,o,phi. , et It, I = t~ l~ l impU~ e, [c[q'tall -£slc[q-~11 for all context4 (c,f, $) E Cjz. Prod. (1) is immediate from the fact that £ ~ tz =ol, t~ implie~ 5 ~ tz =or t~ for all $ >'_ £. (2) follows similarly from the observation that any computation of c[q~-t] in conte~ (d,r, $ ) is also a computation d t in the context (d[r *--c],r .q, $ ). (3) is immediate from (1) and (2). | It is straightforward to show that full abstraction implies semantic abstraction, subject to the following simple constraint. Deflzflt|on: We shall say that the I/mguage (~, _~) is attic. dated iff whenever there are two terms tz, t2 such that tz-~--'® but not t~, or dee verse, there is a nonempty context z E C~ which separates tz and t~. | An articulated language is simply one that is sufficiently fleshed out to allow the definition of a function to re~:ognize ® in any program, aa all real languages obviomdy do. Theor~n 2: If (R, -<) iz articulated then the fully abstr~t model for (~, ~) is semantically abstract. Pro~. Given (3) in Theorem i, all we need to show is that if £s[cJq *" t z ] ] = £sJe[q . -t~]| for all nonempty (c,q,S)E Ct then £ ~ tz =op t~. Since £s is produced by the fully abstract model, the only contexts involved in operational equivalence left out by the antecedent are the empty ones, which are incapable of providing new infommtion in an articulated language. | 8. Construction of a Pulfy Abstract Model The value domain we construct for a program £ must contain exactly the values accessible to £ and its extensions. Of course, only finite values are actually accessible to any program, the infinite values are semantically useful fiction. Information systems recognize this, and ask us to specify only the behavior of finite values and computations. Our task is to identify the values relevant to £. Fortunately, the material we need is already at hand the set T of ground terms in their role as data structures. The abstract approximant (t)R will do fine ~s a unique representation of the information in the fie nite data structure t. It is of course possible that (tt)t--(t2)R for distinct terms tx and t~, so we are indirectly carrying out a quotient construction, but the congruence involved is quite different from the congruences used in initial and final algebra constructions. Our congruence will reflect the pamive role of terms only, whereas the others reflect the active role by embodying the results of all possible rewriting sequences. Formally, the information system for the domain of £ is defined by: Debltlom: I t = (T, Coajt, F'e), where U E Cent i f fU C;