2003:27 - Karlstads universitet
2003:27 - Karlstads universitet
2003:27 - Karlstads universitet
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
B.2 Dharas definition av en subtyp<br />
Dharas definition [3]:<br />
Definition of Pre-Behavioral Subtyping (PBS): S is a pre-behavioral subtype of T with<br />
respect to a binary relation ≤ on types if an only if the following properties are satisfied:<br />
hold:<br />
Syntactic: For every method m in T there exists a method m in S such that the following<br />
Contravariance of arguments: If the types of the additional arguments of m in S and T are<br />
U and V respectively, then U V ∧ ( ∀ i V ≤ U )<br />
= . .<br />
Covariance of result: If the result types of m in S and T are U r and V r respectively, then<br />
U r ≤ V r .<br />
Exception rule: For each exception e: E S of m in S, m in T has an exception e: E T , and<br />
ES ≤ E T .<br />
Semantic: There exists a family of simulation functions, c X → Y : X ≤ Y , such that the<br />
following hold:<br />
Invariant rule: For all values S<br />
v of S, ( v ) I ( c ( v ) )<br />
36<br />
i<br />
I S S T S → T<br />
Method’s rule: For all common methods m, if the types of the additional arguments types<br />
of m in S and T are U and V respectively, and the result types of m in S and T are U r and<br />
V r respectively, then for all objects self: S, y :V , and result: U r<br />
- Precondition rule.<br />
pre<br />
m<br />
T<br />
- Postcondition rule.<br />
m<br />
( cS<br />
→ T ( self ^) , y^)<br />
preS<br />
self ^,<br />
c ( y^)<br />
( )<br />
i<br />
V →U<br />
m ( preS<br />
( self ^ , y^)<br />
m<br />
post S ( self ^,<br />
self ',<br />
y^<br />
, y',<br />
result'<br />
)<br />
( m<br />
T ( cS<br />
→T<br />
( self ^) , y^)<br />
m<br />
postT<br />
( cS<br />
→T<br />
( self ^)<br />
, cS<br />
→T<br />
( self ')<br />
, y^<br />
, y',<br />
cU<br />
→V<br />
( result')<br />
)<br />
pre r r<br />
S