DynBindModelExamples: Difference between revisions

From EiffelStudio: an EiffelSoftware project
Jump to navigation Jump to search
Konradm (talk | contribs)
Konradm (talk | contribs)
Line 118: Line 118:


===Calculating <math>\beta_{S_2}</math>===
===Calculating <math>\beta_{S_2}</math>===
Lets calculate the easy part first:
<math>
  \beta_{S_2}\left( C_1 \mapsto C_1 \right) =
  \beta_{S_1}\left( C_1 \mapsto C_1 \right) =  \left\{ f_1 \mapsto f_1, g_1 \mapsto g_1\right\}
</math>
<math>
  \beta_{S_2}\left( C_2 \mapsto C_1 \right) = \emptyset
</math>
The next least difficult thing we can calculate is:
<math>
  \beta_{S_2}\left( C_2 \mapsto C_2 \right)
      =
  \mbox{id} \left( \mbox{dom} \left( \tau_2 \right) \right)
      \, \cup \,
  \mbox {UNION} \ b \, \cdot \, \left(b \in \alpha_2
      \ |\
  \beta_{ S_{1} } \left( b \mapsto b \right) \ll \eta_{2, b}\right)
</math>
For this we give a reminder on the union and override operator.
<math>\mbox{UNION} \ x \cdot \left(x \in S \ |\ T \right)</math>
is equivalent to:
<math>\exists x \cdot \left(x \in S \ \land\ E \in T \right)</math>
As an example:
<math>\mbox{UNION} \ x \cdot \left(x \in \left\{ 1, 2, 3\right\} \ |\ \left\{ x, x \times x \right\} \right)</math>
is equivalent to:
<math>\left\{ 1, 2, 3, 4, 9\right\}</math>

Revision as of 22:14, 6 October 2006

This page shows

Example 1

The system

In this example we are studying a symple system with three classes that contains both renaming and selects:

class
   C1
feature
   f1 do ... end
   g1 do ... end
end
class
   C2
inherit
   B
      rename f1 as f2, g1 as g2 
      redefine f2, g2 end
feature
   f2 do ... end
   g2 do ... end
end
class
   C3
inherit
   C2
      select f1 end
   C1 
      redefine f1, g1 
      select g1 end
feature
   f1 do ... end
   g1 do ... end
end

This system is defined by:

  • S={C1,C2,C3}
  • S1={C1},S2={C1,C2},S3={C1,C2,C3}
  • τ={C1↦{f1↦C1.f1_,g1↦C1.g1_},C2↦{f2↦C2.f2_,g2↦C2.g2_},C3↦{f1↦C3.f1_,g1↦C3.g1_}}
  • η={C2↦{C1↦{f1↦f2,g1↦g2}}}
  • α={C2↦{C1},C3↦{C2,C1}}
  • σ={C3↦{C2↦{f1},C2↦{g1}}}

The naming function

We proceed by calculating the naming function. According to its definition we have to do that incrementaly. Meaning that we first calculate βS1 then βS2 and finally βS3.

Calculating βS1

Since βS1 contains only one class it is sufficient to define βS1(C1↦C1). According to the definition:

βS1(C1↦C1)=id(dom(τ1))∪UNION b⋅(b∈α1 | βS0(b↦b)≪η1,b)

We can forget about the right part of the union since C1 has no base classes. So we need to calculate: id(dom(τ1)). To do so we give a little reminder on the identity and domain operators:

id({e1,…,en}) ={e1↦e1,…,en↦en}

dom({l1↦r1,…,ln↦rn})={l1,…,ln}

This done we calculate:

  1. τ1=τ(C1)={f1↦C1.f1_,g1↦C1.g1_}
  2. dom(τ1)={f1,g1}
  3. id(dom(τ1))={f1↦f1,g1↦g1}

So we get:

βS1(C1↦C1)={f1↦f1,g1↦g1}

Calculating βS2

Lets calculate the easy part first:

βS2(C1↦C1)=βS1(C1↦C1)={f1↦f1,g1↦g1}

βS2(C2↦C1)=∅

The next least difficult thing we can calculate is:

βS2(C2↦C2)=id(dom(τ2))∪UNION b⋅(b∈α2 | βS1(b↦b)≪η2,b)

For this we give a reminder on the union and override operator.

UNION x⋅(x∈S | T) is equivalent to: ∃x⋅(x∈S ∧ E∈T)

As an example:

UNION x⋅(x∈{1,2,3} | {x,x×x}) is equivalent to: {1,2,3,4,9}