OBJ languagedormant
Family of algebraic specification languages on order-sorted equational logic: programs are equational theories, computation is rewriting. OBJ pioneered parameterized programming and influenced Ada, ML and C++ modules; Maude and CafeOBJ continue the line.
Overview
OBJ is a family of algebraic specification languages built on order-sorted equational logic, designed by Joseph Goguen at UCSD from 1976. An OBJ program is an equational theory and every computation is a proof, which makes the language executable and amenable to mechanised verification.
Code
obj NAT is
sort Nat .
op 0 : -> Nat .
op s_ : Nat -> Nat .
op _+_ : Nat Nat -> Nat [assoc comm] .
vars M N : Nat .
eq M + 0 = M .
eq M + s N = s(M + N) .
endo
red (s s 0) + (s 0) . ***> s s s 0
obj LIST[E :: TRIV] is
sorts List NeList .
subsort NeList < List .
op nil : -> List .
op cons : Elt List -> NeList .
op car_ : NeList -> Elt .
op cdr_ : NeList -> List .
var E : Elt .
var L : List .
eq car cons(E,L) = E .
eq cdr cons(E,L) = L .
endo
view NAT-TRIV from TRIV to NAT is
sort Elt to Nat .
endv
obj NATLIST is pr LIST[NAT-TRIV] .
op one : -> NeList .
eq one = cons(s 0, nil) .
endo
red car one . ***> s 0
red cdr one . ***> nil
openr NAT .
ops a b c : -> Nat .
eq a = s s 0 .
eq b = s s s 0 .
eq c = s s s s s 0 .
red a + b == c . ***> true
close
obj … endo declares sorts, mixfix operators and equations; a view discharges
a parameter theory, so LIST[NAT-TRIV] is instantiation by proof obligation;
red and openr turn those same equations into a rewriting engine. There is no
control flow anywhere: computation is equational deduction.Distinctive traits
- Order-sorted subsorting is a partial order on sorts, so multiple inheritance, overloading and coercions need no special rules.
- Equations are the only control structure: a reduction is a proof, so theorem proving and execution are the same act.
- Parameterized programming debuted here: modules take theories as parameters, views discharge them; Ada, Standard ML and C++ module systems followed.
- User-definable mixfix syntax
makes
if_then_else_fiand_+_ordinary operators with declared precedence. - Rewriting modulo associativity, commutativity and identity is built in, so sets and lists need no hand-written normalisation.
Status
OBJ3 is the canonical implementation: it runs under Common Lisp and was re-released as 2.06 (2000) under a BSD-like licence by KindSoftware, and is no longer under active development. Maude and CafeOBJ continue the design.
History
The first implementation of initial algebra semantics by term rewriting appeared in OBJ in the mid-1970s; the characteristic syntax appeared in Goguen's 1977 paper. OBJ2 (1985) added Clear-style parameterized modules, and OBJ3 (1988) rebuilt the operational semantics on order-sorted rewriting. BOBJ, CafeOBJ and Maude followed, enriching the logic.
Sources & references
- Official sitecseweb.ucsd.edu
- Introducing OBJ — official OBJ3 manual (Goguen, Winkler, Meseguer, Futatsugi, Jouannaud)cseweb.ucsd.edu
- An Introduction to OBJ 3 (Goguen, Kirchner, Kirchner, Mégrelis, Meseguer, Winkler, 1988)link.springer.com
- Proving a Property of Map in OBJ3 — parameterized module and view examplescseweb.ucsd.edu
- Algebraic semantics of a simple imperative language in OBJ3 — reduction proofscseweb.ucsd.edu
- OBJ3 FAQ (KindSoftware, archived 2007)web.archive.org