Set Operators

25.2.2 Set Operators

A specialized set of symbology is used to represent set and logic operations. These symbols must be understood by the software engineer who intends to apply formal methods.

Knowledge of set The operator is used to indicate membership of a set. For example, the expression operations is

indispensible when x

formal specifications has the value true if x is a member of the set X and the value false otherwise. For are developed. Spend

the time to familiarize example, the predicate yourself with each, if

you intend to apply formal methods.

has the value true since 12 is a member of the set. The opposite of the

operator. The expression x

operator is the

X has the value true if x is not a member of the set X and false otherwise. For example,

the predicate

13 {13, 1, 124, 22} has the value false.

has the value true if the members of the set A are contained in the set B and has the value false otherwise. Thus, the predicate

has the value true. However, the predicate

has a value of false because the element RC5 is not contained in the set to the right of the operator.

CHAPTER 25

FORMAL METHODS

true. Thus, the value of the predicate

is false, and the predicate

is true. The empty set has the property that it is a subset of every other set. Two useful iden-

tities involving the empty set are

is the intersection operator, sometimes known as cap. The union operator takes two sets and forms a set that contains all the elements in the set with duplicates eliminated. Thus, the result of the expression

“Mathematical structures are among the most beautiful discoveries made by

is the set the human mind.”

{Filel, File2, Tax, Compiler, NewTax, D2, D3}

Douglas Hofstadter

The intersection operator takes two sets and forms a set consisting of the common elements in each set. Thus, the expression

results in the set {12, 1}. The set difference operator, \, as the name suggests, forms a set by removing the elements of its second operand from the elements of its first operand. Thus, the value of the expression

{New, Old, TaxFile, Sysparam} \ {Old, SysParam} results in the set {New, TaxFile}.

The value of the expression

there are no common elements between its operands so the resulting set will have no elements.

uct. This has two operands which are sets of pairs. The result is a set of pairs where each pair consists of an element taken from the first operand combined with an uct. This has two operands which are sets of pairs. The result is a set of pairs where each pair consists of an element taken from the first operand combined with an

The result of this expression is {(1, 4), (1, 5), (1, 6), (2, 4), (2, 5), (2, 6)} Notice that every element of the first operand is combined with every element of the

second operand.

A concept that is important for formal methods is that of a powerset. A powerset of a set is the collection of subsets of that set. The symbol used for the powerset oper-

set of subsets of its operand. For example,

since all the sets are subsets of {1, 2, 3}.