0

I am currently using Atelier B and would like to have a better understanding of the difference between union and quantified union. An example would be much appreciated

klutt
  • 25,535
  • 14
  • 43
  • 72

1 Answers1

0

The union is a binary operator: it has two arguments, both sets and returns the union of those two sets. For instance:

{1, 2} \/ {2, 4}

is

{1, 2, 4}

This operator is associative, and commutative, so you can combine multiple applications of this operator without using parentheses. For instance:

{ 1, 2 } \/ {2, 3, 4, 5} \/ {1, 3, 5, 7}

is

{ 1, 2, 3, 4, 5, 7}

A second operator is quantified union. It is a ternary operator and has three arguments: a list of identifiers, say x1...xn , a predicate, say P(x1...xn) and an expression, say E(x1...xn). The expression E(x1...xn) must be a set. The result is the union of all the sets E(x1...xn) such that P(x1...xn) holds. For instance

UNION(x1, x2) . (x1 : {1, 2, 3} & x2 : {10, 20} | { x1 + x2 }) 

is

{ 1+10 } \/ { 1+20 } \/ { 2+10 } \/ { 2+20 } \/ { 3+10 } \/ { 3+20 }

which simplifies to:

{ 11, 12, 13, 21, 22, 23 }.

A second example for quantified union:

UNION(low, upp).(low : {10, 20} & upp: {12, 14} | { xx | xx : INT & low <= xx & xx <= upp })

is

{ xx | xx : INT & 10 <= xx & xx <= 12 } \/ 
{ xx | xx : INT & 10 <= xx & xx <= 14 } \/ 
{ xx | xx : INT & 20 <= xx & xx <= 12 } \/ 
{ xx | xx : INT & low <= 20 & xx <= 14 }

which simplifies to

{ 10, 11, 12 } \/ { 10, 11, 12, 13, 14 } \/ {} \/ {}

which, in turn, simplifies to

{ 10, 11, 12, 13, 14 }
dde
  • 55
  • 6