200 likes | 438 Views
Dynamically creating objects and sequencing operations. Cliff Jones University of Newcastle 2005-06-06. On the expectation of a WG2.3 topic. in the tradition of 2.3, this is something I’m trying to sort out for myself but …
E N D
Dynamically creating objects and sequencing operations Cliff Jones University of Newcastle 2005-06-06 WG2.3 Niagara 2005-06-06
On the expectation of a WG2.3 topic • in the tradition of 2.3, this is something I’m trying to sort out for myself • but … • apparently it is now expected to work up from the (legacy) code WG2.3 Niagara 2005-06-06
class stack var … method push(i: item) … method pop() : item … body %% initialize do %% forever if … then answer(push) else answer(pop, push) fi od POOL example WG2.3 Niagara 2005-06-06
OO-like structuring in specifications • I’d like to look at two issues • how to sequence “operations” • how to “create objects” • first some background WG2.3 Niagara 2005-06-06
A dichotomy • state based specification techniques • VDM, Z, B, agent-B • good for big systems; understand from data • one can “see” (or design) a system from Σ • process algebras • CSP, CCS, -calculus • states as process indices (but another notion below) • good for intricate sequencing (e.g. deadlocks) WG2.3 Niagara 2005-06-06
My interest:(specification and) development • can be done in, say, CSP • CCS etc goes more for bi-simulation • but it has always felt more natural to • get an abstract state-based spec • reify data • decompose operations • and next: “splitting atoms” • cf. CBJ’s Prato talk WG2.3 Niagara 2005-06-06
Modularising state based specs • VDM • initially none • “operation quotation” • VVSL (as in CDIS) • VDM++ (as in VDM ToolSet) • Z • everything is a schema • no pre-conditions! • B • machines/operations WG2.3 Niagara 2005-06-06
Sequencing operations • VDM • all, always available • pre-conditions are to be respected • one proves this! • but there is a procedural language as well! • B • originally “operations” (pre P then S end) • “action systems”/ Event-B • “when conditions” define firing WG2.3 Niagara 2005-06-06
OO is a GoodThing (in design) • sometimes as essence of system • come back to how modelled? • sometimes as an implementation idea • CBJ used several times as “reification” • modularisation (better than many specification languages) • control of interference • local instance variables • unique references create “islands” of computation • shared references when interference necessary • option to control sequencing WG2.3 Niagara 2005-06-06
Look at combining processes/states • done in Ada • by Abrial!! • POOL • • dropped (after MIW’s observation) WG2.3 Niagara 2005-06-06
So, two ways of sequencing • process descriptions • in the style of POOL • guards • “when” in Event-B • possible to “hack” at this level – abstract PC • I’d like to view them as refinements • in either direction • would combinations be useful? • … but I want to achieve even more … WG2.3 Niagara 2005-06-06
obl • language itself • typed references • recognise “unique” references • no inheritance (yet) • see as design notation (cf. VDM sequential) • use with implemented OOLs (e.g. Eiffel) • semantics (as basis of “meta” proofs) • SOS • map to -calculus WG2.3 Niagara 2005-06-06
obl Sortclass vars v: nat nil; l: unique ref(Sort) nil insert(x: nat) method return; if is-nil(v) then (v x; l new Sort) elif v x then l.insert(x) else (l.insert(v); v x) fi test(x: nat) method: Bool if is-nil(l) x v then return false elif x = v then return true else delegate l.test(x) fi . . . endSort WG2.3 Niagara 2005-06-06
Mapping (i) [[Q]] = !IQ IQ = qu.BQ thus [[new Q]] = q(u). … WG2.3 Niagara 2005-06-06
Mapping (ii) IQ = \New{\widetilde{s}\widetilde{a}} (v\sb{nil} | l\sb{nil} | \outp{q}{u}. B\sb{Q}) WG2.3 Niagara 2005-06-06
We have • a nice mapping to -calculus • new C maps to a reference to replication • strictly, a communication with a name inside a replicator which cause a new instance to exist • we can therefore have dynamic creation of objects/machines/… WG2.3 Niagara 2005-06-06
Contrast … • Michael Butler’s paper • tokens Cust {0..sx} in the “specification” • a strange (twin) SOS • cbj’s SOS of COOL • map Oid to ObjInfo • is a semantic object • the SOS rules create this mapping • so my semantics of POOL • would look rather different from Michael’s • might have a “program counter” into process expression!! WG2.3 Niagara 2005-06-06
Technical issue(s) • failure(s) • in two senses • internal choice (vs. external) • divergence(s) WG2.3 Niagara 2005-06-06
Implementation questions • CSP handshake is non-trivial • Event-B’s “when” clause looks less efficient than CARH’s “monitors” • assuming … WG2.3 Niagara 2005-06-06
So, sequencing operationsVDM + OO + -calculus(held together by reification) WG2.3 Niagara 2005-06-06