1.17. Collection Type Set: Operations
1.17.4. Constants: mtSet
denition mtSet::(0A,0α::null)Set (Set{})
where Set{} ≡(λ τ . Abs-Setbasexx{}::0αsetyy)
lemma mtSet-dened[simp,code-unfold]:δ(Set{}) =true hproofi
lemma mtSet-valid[simp,code-unfold]:υ(Set{}) =true hproofi
lemma mtSet-rep-set:ppRep-Setbase (Set{}τ)qq={}
hproofi
lemma[simp,code-unfold]:const Set{}
hproofi
Note that the collection types in OCL allow for null to be included; however, there is the null-collection into which inclusion yields invalid.
1.17.5. Denition: Including
denition OclIncluding :: [(0A,0α::null) Set,(0A,0α)val]⇒(0A,0α)Set where OclIncluding x y = (λ τ .if (δ x)τ =true τ ∧(υ y)τ =true τ
then Abs-Setbasexx ppRep-Setbase (x τ)qq ∪ {y τ}yy else invalid τ )
notation OclIncluding (-−>includingS et0(-0))
interpretation OclIncluding :prole-bind-v OclIncluding λx y.Abs-SetbasexxppRep-Setbase xqq∪ {y}yy hproofi
syntax
-OclFinset ::args =>(0A,0a::null)Set (Set{(-)}) translations
Set{x,xs}==CONST OclIncluding (Set{xs}) x Set{x} ==CONST OclIncluding (Set{})x
1.17.6. Denition: Excluding
denition OclExcluding :: [(0A,0α::null)Set,(0A,0α)val]⇒(0A,0α)Set where OclExcluding x y = (λ τ . if (δx) τ =true τ ∧ (υ y)τ =true τ
then Abs-Setbasexx ppRep-Setbase(x τ)qq− {y τ}yy else ⊥)
notation OclExcluding (-−>excludingS et0
(-0))
lemma OclExcluding-inv: (x::Set(0b::{null}))6=⊥=⇒x 6=null =⇒ y 6=⊥ =⇒ xxppRep-Setbasexqq− {y}yy∈ {X.X =bot ∨X =null ∨(∀x∈ppXqq.x 6=bot)}
hproofi
interpretation OclExcluding :prole-bind-vOclExcluding λx y.Abs-SetbasexxppRep-Setbasexqq− {y}yy hproofi
1.17.7. Denition: Includes
denition OclIncludes :: [(0A,0α::null)Set,(0A,0α)val]⇒ 0ABoolean where OclIncludes x y = (λ τ . if (δx)τ =true τ ∧ (υ y)τ =true τ
then xx(y τ)∈ppRep-Setbase (x τ)qq yy else ⊥ )
notation OclIncludes (-−>includesS et0
(-0) )
interpretation OclIncludes :prole-bind-vOclIncludes λx y.xxy ∈ppRep-Setbase xqqyy hproofi
1.17.8. Denition: Excludes
denition OclExcludes :: [(0A,0α::null)Set,(0A,0α) val]⇒ 0ABoolean where OclExcludes x y = (not(OclIncludes x y))
notation OclExcludes (-−>excludesS et0
(-0) )
The case of the size denition is somewhat special, we admit explicitly in Featherweight OCL the possibility of innite sets. For the size denition, this requires an extra condition that assures that the cardinality of the set is actually a dened integer.
interpretation OclExcludes :prole-bind-v OclExcludesλx y.xxy ∈/ppRep-Setbasexqqyy hproofi
1.17.9. Denition: Size
denition OclSize :: (0A,0α::null)Set ⇒ 0AInteger
where OclSize x = (λ τ . if (δ x)τ =true τ ∧nite(ppRep-Setbase(x τ)qq) then xxint(card ppRep-Setbase (x τ)qq)yy
else ⊥) notation
OclSize (-−>sizeS et0
(0) )
The following denition follows the requirement of the standard to treat null as neutral element of sets.
It is a well-documented exception from the general strictness rule and the rule that the distinguished argument self should be non-null.
1.17.10. Denition: IsEmpty
denition OclIsEmpty :: (0A,0α::null)Set ⇒ 0ABoolean
where OclIsEmpty x = ((υ x and not(δx))or ((OclSize x) .
=0)) notation OclIsEmpty (-−>isEmptyS et0
(0) )
1.17.11. Denition: NotEmpty
denition OclNotEmpty :: (0A,0α::null)Set ⇒ 0ABoolean where OclNotEmpty x = not(OclIsEmpty x)
notation OclNotEmpty (-−>notEmptyS et0
(0) )
1.17.12. Denition: Any
denition OclANY :: [(0A,0α::null)Set]⇒(0A,0α) val where OclANY x = (λ τ . if (υ x)τ =true τ
then if (δ x and OclNotEmpty x) τ =true τ then SOME y.y ∈ppRep-Setbase (x τ)qq else null τ
else ⊥) notation OclANY (-−>anyS et0
(0))
1.17.13. Denition: Forall
The denition of OclForall mimics the one of op and: OclForall is not a strict operation.
denition OclForall :: [(0A,0α::null)Set,(0A,0α)val⇒(0A)Boolean]⇒ 0ABoolean where OclForall S P = (λ τ .if (δS)τ =true τ
then if (∃x∈ppRep-Setbase (S τ)qq.P(λ-.x)τ =false τ) then false τ
else if (∃x∈ppRep-Setbase (S τ)qq.P(λ-.x) τ =invalid τ) then invalid τ
else if (∃x∈ppRep-Setbase(S τ)qq.P(λ-.x)τ =null τ) then null τ
else true τ else ⊥)
syntax
-OclForallSet :: [(0A,0α::null)Set,id,(0A)Boolean]⇒ 0ABoolean ((-)−>forAllS et0
(-|-0)) translations
X−>forAllS et(x |P) ==CONST UML-Set.OclForall X (%x.P)
1.17.14. Denition: Exists
Like OclForall, OclExists is also not strict.
denition OclExists :: [(0A,0α::null)Set,(0A,0α)val⇒(0A)Boolean]⇒ 0ABoolean
where OclExists S P =not(UML-Set.OclForall S (λX.not (P X))) syntax
-OclExistSet :: [(0A,0α::null)Set,id,(0A)Boolean]⇒ 0ABoolean ((-)−>existsS et0
(-|-0)) translations
X−>existsS et(x |P) ==CONST UML-Set.OclExists X (%x.P)
1.17.15. Denition: Iterate
denition OclIterate :: [(0A,0α::null)Set,(0A,0β::null)val,
(0A,0α)val⇒(0A,0β)val⇒(0A,0β)val]⇒(0A,0β)val
where OclIterate S A F = (λ τ . if (δ S) τ =true τ ∧(υ A) τ =true τ ∧ niteppRep-Setbase (S τ)qq then (Finite-Set.fold (F) (A) ((λa τ .a) ` ppRep-Setbase(S τ)qq))τ
else ⊥) syntax
-OclIterateSet :: [(0A,0α::null)Set,idt,idt, 0α, 0β] =>(0A,0γ)val (-−>iterateS et0
(-;-=-|-0) ) translations
X−>iterateS et(a;x =A |P) ==CONST OclIterate X A(%a.(%x.P))
1.17.16. Denition: Select
denition OclSelect :: [(0A,0α::null)Set,(0A,0α)val⇒(0A)Boolean]⇒(0A,0α)Set where OclSelect S P = (λτ .if (δ S)τ =true τ
then if (∃x∈ppRep-Setbase (S τ)qq.P(λ-.x) τ =invalid τ) then invalid τ
else Abs-Setbasexx{x∈ppRep-Setbase (S τ)qq.P (λ-.x)τ 6=false τ}yy else invalid τ)
syntax
-OclSelectSet :: [(0A,0α::null)Set,id,(0A)Boolean]⇒ 0ABoolean ((-)−>selectS et0(-|-0)) translations
X−>selectS et(x |P) ==CONST OclSelect X (%x.P)
1.17.17. Denition: Reject
denition OclReject :: [(0A,0α::null)Set,(0A,0α)val⇒(0A)Boolean]⇒(0A,0α::null)Set where OclReject S P =OclSelect S (not o P)
syntax
-OclRejectSet :: [(0A,0α::null) Set,id,(0A)Boolean]⇒ 0ABoolean ((-)−>rejectS et0(-|-0)) translations
X−>rejectS et(x |P) ==CONST OclReject X (%x.P)
1.17.18. Denition: IncludesAll
denition OclIncludesAll :: [(0A,0α::null)Set,(0A,0α) Set]⇒ 0ABoolean where OclIncludesAll x y = (λ τ . if (δ x)τ =true τ ∧(δy)τ =true τ
then xxppRep-Setbase(yτ)qq⊆ppRep-Setbase(x τ)qq yy else ⊥ )
notation OclIncludesAll (-−>includesAllS et0
(-0) )
interpretation OclIncludesAll :prole-bind-dOclIncludesAll λx y.xxppRep-Setbaseyqq⊆ppRep-Setbasexqqyy hproofi
1.17.19. Denition: ExcludesAll
denition OclExcludesAll :: [(0A,0α::null) Set,(0A,0α)Set]⇒ 0ABoolean where OclExcludesAll x y = (λ τ . if (δx) τ =true τ ∧(δ y)τ =true τ
then xxppRep-Setbase(yτ)qq∩ppRep-Setbase (x τ)qq={}yy
else ⊥ ) notation OclExcludesAll (-−>excludesAllS et0
(-0) )
interpretation OclExcludesAll :prole-bind-d OclExcludesAll λx y.xxppRep-Setbase yqq∩ppRep-Setbasexqq= {}yy
hproofi
1.17.20. Denition: Union
denition OclUnion :: [(0A,0α::null)Set,(0A,0α)Set]⇒(0A,0α)Set where OclUnion x y = (λ τ . if (δx) τ =true τ ∧ (δ y) τ =true τ
then Abs-SetbasexxppRep-Setbase (y τ)qq∪ ppRep-Setbase(x τ)qq yy else ⊥ )
notation OclUnion (-−>unionS et0(-0) )
lemma OclUnion-inv: (x::Set(0b::{null}))6=⊥=⇒x 6=null =⇒ y 6=⊥ =⇒y 6=null =⇒ xxppRep-Setbase yqq∪ppRep-Setbase xqqyy∈ {X.X =bot ∨X =null ∨(∀x∈ppXqq.x 6=bot)}
hproofi
interpretation OclUnion :prole-bind-dOclUnion λx y.Abs-SetbasexxppRep-Setbaseyqq∪ppRep-Setbasexqqyy hproofi
1.17.21. Denition: Intersection
denition OclIntersection :: [(0A,0α::null)Set,(0A,0α)Set]⇒(0A,0α)Set where OclIntersection x y = (λ τ . if (δx) τ =true τ ∧(δ y)τ =true τ
then Abs-SetbasexxppRep-Setbase (y τ)qq
∩ppRep-Setbase(x τ)qqyy else ⊥ )
notation OclIntersection(-−>intersectionS et0(-0) )
lemma OclIntersection-inv: (x::Set(0b::{null}))6=⊥=⇒x 6=null =⇒ y 6=⊥ =⇒y 6=null =⇒ xxppRep-Setbase yqq∩ppRep-Setbase xqqyy∈ {X.X =bot ∨X =null ∨(∀x∈ppXqq.x 6=bot)}
hproofi
interpretation OclIntersection : prole-bind-d OclIntersection λx y. Abs-SetbasexxppRep-Setbase yqq ∩ ppRep-Setbasexqqyy
hproofi
1.17.22. Denition (future operators)
consts
OclCount :: [(0A,0α::null)Set,(0A,0α) Set]⇒ 0AInteger OclSum :: (0A,0α::null) Set⇒ 0AInteger
notation OclCount (-−>countS et0(-0) ) notation OclSum (-−>sumS et0
(0) )
1.17.23. Logical Properties
OclIncluding
lemma OclIncluding-valid-args-valid:
(τ |=υ(X−>includingS et(x))) = ((τ |=(δ X))∧(τ |=(υ x))) hproofi
lemma OclIncluding-valid-args-valid00[simp,code-unfold]:
υ(X−>includingS et(x)) = ((δ X) and (υ x))
hproofi etc. etc.
OclExcluding
lemma OclExcluding-valid-args-valid:
(τ |=υ(X−>excludingS et(x))) = ((τ |=(δX))∧(τ |=(υ x))) hproofi
lemma OclExcluding-valid-args-valid00[simp,code-unfold]:
υ(X−>excludingS et(x)) = ((δX)and (υ x)) hproofi
OclIncludes
lemma OclIncludes-valid-args-valid:
(τ |=υ(X−>includesS et(x))) = ((τ |=(δ X))∧(τ |=(υ x))) hproofi
lemma OclIncludes-valid-args-valid00[simp,code-unfold]:
υ(X−>includesS et(x)) = ((δX)and (υ x)) hproofi
OclExcludes
lemma OclExcludes-valid-args-valid:
(τ |=υ(X−>excludesS et(x))) = ((τ |=(δ X))∧(τ |=(υx))) hproofi
lemma OclExcludes-valid-args-valid00[simp,code-unfold]:
υ(X−>excludesS et(x)) = ((δ X) and (υ x)) hproofi
OclSize
lemma OclSize-dened-args-valid:τ |=δ(X−>sizeS et()) =⇒τ |=δ X hproofi
lemma OclSize-innite:
assumes non-nite:τ |=not(δ(S−>sizeS et()))
shows (τ |=not(δ(S)))∨ ¬ niteppRep-Setbase (S τ)qq hproofi
lemmaτ |=δ X =⇒ ¬nite ppRep-Setbase (X τ)qq=⇒ ¬τ |=δ(X−>sizeS et()) hproofi
lemma size-dened: assumes X-nite:V
τ . niteppRep-Setbase(X τ)qq shows δ(X−>sizeS et()) =δ X
hproofi
lemma size-dened0:
assumes X-nite:nite ppRep-Setbase(X τ)qq shows (τ |=δ(X−>sizeS et())) = (τ |=δ X) hproofi
OclIsEmpty
lemma OclIsEmpty-dened-args-valid:τ |=δ(X−>isEmptyS et()) =⇒τ |=υ X hproofi
lemmaτ |=δ(null−>isEmptyS et()) hproofi
lemma OclIsEmpty-innite:τ |=δ X =⇒ ¬niteppRep-Setbase (X τ)qq=⇒ ¬τ |=δ (X−>isEmptyS et()) hproofi
OclNotEmpty
lemma OclNotEmpty-dened-args-valid:τ |=δ(X−>notEmptyS et()) =⇒τ |=υ X hproofi
lemmaτ |=δ(null−>notEmptyS et()) hproofi
lemma OclNotEmpty-innite:τ |=δX =⇒ ¬niteppRep-Setbase(X τ)qq=⇒ ¬τ |=δ(X−>notEmptyS et()) hproofi
lemma OclNotEmpty-has-elt :τ |=δ X =⇒ τ |=X−>notEmptyS et() =⇒
∃e.e ∈ppRep-Setbase(X τ)qq hproofi
OclANY
lemma OclANY-dened-args-valid:τ |=δ(X−>anyS et()) =⇒τ |=δ X hproofi
lemmaτ |=δX =⇒τ |=X−>isEmptyS et() =⇒ ¬τ |=δ (X−>anyS et()) hproofi
lemma OclANY-valid-args-valid: (τ |=υ(X−>anyS et())) = (τ |=υ X) hproofi
lemma OclANY-valid-args-valid00[simp,code-unfold]:
υ(X−>anyS et()) = (υ X) hproofi