DynBindModelExamples: Difference between revisions

From EiffelStudio: an EiffelSoftware project
Jump to navigation Jump to search
Manus (talk | contribs)
No edit summary
Patrickr (talk | contribs)
Line 2: Line 2:
Author: Matthias Konrad
Author: Matthias Konrad
==The system==
==The system==
In this example we are studying a symple system with three classes that contains both renaming and selects:
In this example we are studying a simple system with three classes that contains both renaming and selects:


{|border="0" cellpadding="2" cellspacing="0" align="center"
{|border="0" cellpadding="2" cellspacing="0" align="center"

Revision as of 00:53, 27 October 2006

Author: Matthias Konrad

The system

In this example we are studying a simple 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 f2 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↦{f2},C1↦{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 | id(ran(β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:

  1. id(dom(τ1))
    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}

And hence:

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

Calculating βS2

We show the calculation of the different (four) parts of the function in separate sections:

Calculate βS2(C1↦C1)

According to the definition: βS2(C1↦C1)=βS1(C1↦C1)={f1↦f1,g1↦g1}

Calculate βS2(C2↦C1)

According to the definition: βS2(C2↦C1)=∅

Calculate βS2(C2↦C2)

According to the definition: βS2(C2↦C2)=id(dom(τ2))∪UNION b⋅(b∈α2 | id(ran(βS1(b↦b)≪η2,b)))

Lets calculate the left part first:

  1. τ2=τ(C2)={f2↦C2.f2_,g2↦C2.g2_}
  2. id(dom(τ2))={f2↦f2,g2↦g2}

And now the right part:

  1. UNION b⋅(b∈{C1} | id(ran(βS1(b↦b)≪η2,b)))=id(ran(βS1(C1↦C1)≪η2,C1))
  2. βS1(C1↦C1)={f1↦f1,g1↦g1}
  3. η2,C1=η(C2)(C1)={f1↦f2,g1↦g2}
  4. {f1↦f1,g1↦g1}≪{f1↦f2,g1↦g2}={f1↦f2,g1↦g2}
  5. id(ran({f1↦f2,g1↦g2}))={f2↦f2,g2↦g2}

So we get:

βS2(C2↦C2)={f2↦f2,g2↦g2}

Calculate βS2(C1↦C2)

According to the definition: βS2(C1↦C2)=βS2′(C1↦C2)≪θS2(C1↦C2)

Where: βS2′(C1↦C2)=UNION b ⋅ (b∈α2 | βS1(C1↦b);(id(ran(βS1(C1↦b)))≪η2,b))

And: θS2(C1↦C2)=UNION b ⋅ (b∈α2 | βS1(C1↦b);(id(ran(βS1(C1↦b)))≪η2,b)▹σ2,b)

Here are the steps taken to compute the part:

  1. βS1(C1↦C1);(id(ran(βS1(C1↦C1)))≪η2,C1)
    1. id(ran(βS1(C1↦C1)))={f1↦f1,g1↦g1}
    2. {f1↦f1,g1↦g1}≪{f1↦f2,g1↦g2}={f1↦f2,g1↦g2}
    3. {f1↦f1,g1↦g1};{f1↦f2,g1↦g2}={f1↦f2,g1↦g2}
    4. βS2′(C1↦C2)={f1↦f2,g1↦g2}
  2. βS1(C1↦C1);(id(ran(βS1(C1↦C1)))≪η2,C1)▹σ2,C1
    1. σ2,C1=∅
    2. id(ran(βS1(C1↦C1)))≪∅=∅
    3. βS1(C1↦C1);∅=∅
    4. θS2(C1↦C2)=∅
  3. {f1↦f2,g1↦g2}≪∅={f1↦f2,g1↦g2}

So we get:

βS2(C1↦C2)={f1↦f2,g1↦g2}

Putting the parts together:

We can know show the complete total function:

βS2={

(C1↦C1)↦{f1↦f1,g1↦g1},

(C1↦C2)↦{f1↦f2,g1↦g2},

(C2↦C1)↦∅,

(C2↦C2)↦{f2↦f2,g2↦g2} }

Calculating βS3

We will not show the complete construction of βS3 but restrict our self to the most interesting parts.

Calculate βS3(C1↦C3)

According to the definition: βS3(C1↦C3)=βS3′(C1↦C3)≪θS3(C1↦C3)

Where: βS3′(C1↦C3)=UNION b ⋅ (b∈α3 | βS2(C1↦b);(id(ran(βS2(C1↦b)))≪η3,b))

And: θS3(C1↦C3)=UNION b ⋅ (b∈α3 | βS2(C1↦b);(id(ran(βS2(C1↦b)))≪η3,b)▹σ3,b)

Note that we can ommit η3,b from the formulas since it is always empty.

  1. βS2(C1↦C2);id(ran(βS2(C1↦C2))) ∪ βS2(C1↦C1);id(ran(βS2(C1↦C1)))
    1. βS2(C1↦C2)={f1↦f2,g1↦g2}
    2. id(ran(βS2(C1↦C2)))={f2↦f2,g2↦g2}
    3. βS2(C1↦C2);id(ran(βS2(C1↦C2)))={f1↦f2,g1↦g2}
    4. βS2(C1↦C1)={f1↦f1,g1↦g1}
    5. id(ran(βS2(C1↦C1)))={f1↦f1,g1↦g1}
    6. βS2(C1↦C1);id(ran(βS2(C1↦C1)))={f1↦f1,g1↦g1}
    7. {f1↦f2,g1↦g2} ∪ {f1↦f1,g1↦g1}={f1↦f1,f1↦f2,g1↦g1,g1↦g2}
  2. βS2(C1↦C2);id(ran(βS2(C1↦C2))) ▹ σ3,C2 ∪ βS2(C1↦C1);id(ran(βS2(C1↦C1))) ▹ σ3,C1
    1. σ3,C2=σ(C3)(C2)={f2}
    2. σ3,C1=σ(C3)(C1)={g1}
    3. βS2(C1↦C2);id(ran(βS2(C1↦C2))) ▹ σ3,C2={f1↦f2}
    4. βS2(C1↦C1);id(ran(βS2(C1↦C1))) ▹ σ3,C1={g1↦g1}
    5. {f1↦f2} ∪ {g1↦g1}={f1↦f2,g1↦g1}
    6. {f1↦f1,f1↦f2,g1↦g1,g1↦g2}≪{f1↦f2,g1↦g1}={f1↦f2,g1↦g1}

So we get:

βS3(C1↦C3)={f1↦f2,g1↦g1}

The complete naming function

βS3={

(C1↦C1)↦{f1↦f1,g1↦g1},

(C1↦C2)↦{f1↦f2,g1↦g2},

(C2↦C1)↦∅,

(C2↦C2)↦{f2↦f2,g2↦g2},

(C1↦C3)↦{f1↦f2,g1↦g1},

(C2↦C3)↦{f2↦f2,g2↦g2},

(C3↦C3)↦{f1↦f1,g1↦g1,f2↦f2,g2↦g2},

(C3↦C1)↦∅,

(C3↦C2)↦∅ }


The dynamic binding function

To calculate the dynamic binding function, we need to get δS3. We will again calculate it incrementaly:

Calculating δS1

According to the definition:

δS1(C1↦C1)=βS(C1↦C1);((UNIONb⋅(b∈α1|(βS(b↦b);η1,b)−1;δS0(b↦b)))≪τ1)

Since α1 is empty this simplifies to: δS1(C1↦C1)=βS(C1↦C1);τ1={f1↦f1,g1↦g1};{f1↦C1.f1_,g1↦C1.g1_}

So we get: δS1={(C1↦C1)↦{f1↦C1.f1_,g1↦C1.g1_}}

Calculating δS2

Again we calculate the different parts of the function in separate sections:

Calculate δS2(C1↦C1)

According to the definition: δS2(C1↦C1)=δS1(C1↦C1)={f1↦C1.f1_,g1↦C1.g1_}

Calculate δS2(C2↦C1)

According to the definition: δS2(C1↦C1)=∅

Calculate δS2(C2↦C2)

According to the definition:

δS2(C2↦C2)=βS(C2↦C2);((UNIONb⋅(b∈α2|(βS(b↦b);η2,b)−1;δS1(b↦b)))≪τ2)

  1. UNIONb⋅(b∈{C1}|(βS(b↦b);η2,b)−1;δS1(b↦b))=(βS(C1↦C1);η2,C1)−1;δS1(C1↦C1)
    1. βS(C1↦C1);η2,C1={f1↦f2,g1↦g2}
    2. (βS(C1↦C1);η2,C1)−1={f2↦f1,g2↦g1}
    3. (βS(C1↦C1);η2,C1)−1;δS1(C1↦C1)={f2↦C1.f1_,g2↦C1.g1_}
  2. τ2=τ(C2)={f2↦C2.f2_,g2↦C2.g2_}
  3. {f2↦C1.f1_,g2↦C1.g1_}≪{f2↦C2.f2_,g2↦C2.g2_}={f2↦C2.f2_,g2↦C2.g2_}

So we get: δS2(C2↦C2)={f2↦C2.f2_,g2↦C2.g2_}

Calculate δS2(C1↦C2)

According to the definition:

δS2(C1↦C2)=βS(C1↦C2);((UNIONb⋅(b∈α2|(βS(b↦b);η2,b)−1;δS1(b↦b)))≪τ2)

At this stage it should be clear how to calculate this, so we just give the result:

δS2(C1↦C2)={f1↦C2.f2_,g1↦C2.g2_}

Putting the parts together:

We can know show the complete total function:

δS2={

(C1↦C1)↦{f1↦C1.f1_,g1↦C1.g1_},

(C1↦C2)↦{f1↦C2.f2_,g1↦C2.g2_},

(C2↦C1)↦∅,

(C2↦C2)↦{f2↦C2.f2_,g2↦C2.g2_} }

Calculating δS3

There is nothing new for this calculation so we just present the result:

δS3={

(C1↦C1)↦{f1↦C1.f1_,g1↦C1.g1_},

(C1↦C2)↦{f1↦C2.f2_,g1↦C2.g2_},

(C2↦C1)↦∅,

(C2↦C2)↦{f2↦C2.f2_,g2↦C2.g2_},

(C1↦C3)↦{f1↦C2.f2_,g1↦C3.g1_},

(C2↦C3)↦{f2↦C2.f2_,g2↦C2.g2_},

(C3↦C3)↦{f1↦C3.f1_,g1↦C3.g1_,f2↦C2.f2_,g2↦C2.g2_},

(C3↦C1)↦∅,

(C3↦C2)↦∅ }

Deriving the dynamic binding function

The function is now given. We evaluate it at two interesting points:

  • δ(C1↦f1)={C1↦C1.f1_,C2↦C2.f2_,C3↦C2.f2_}
  • δ(C1↦fg)={C1↦C1.fg_,C2↦C2.g2_,C3↦C2.g1_}