9
1 April 2009 Instructor: Tasneem Darwi sh 1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Formal Methods Relations

1 April 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Formal

Embed Size (px)

Citation preview

1 April 2009 Instructor: Tasneem Darwish 1

University of PalestineFaculty of Applied Engineering and Urban Planning

Software Engineering Department

Formal Methods

Relations

1 April 2009 Instructor: Tasneem Darwish 2

Outlines

Binary relations.

1 April 2009 Instructor: Tasneem Darwish 3

Introduction

In a formal specification, it is often necessary to describe relationships between Objects.

Example:1.This object is greater than that.2.This action takes priority over that one.

These relationships can be described using simple mathematical objects called relations.

1 April 2009 Instructor: Tasneem Darwish 4

Binary RelationsWe can define relations between a finite number of objects, but

its enough to define binary relations.

Binary relations are relations that express links between pairs of objects.

In our mathematical language a relation is a set of ordered pairs, a subset of a Cartesian product.

If X and Y are sets, then X ↔Y denotes the set of all relations between X and Y.

The relation symbol can be defined using generic abbreviation:

1 April 2009 Instructor: Tasneem Darwish 5

Binary RelationsExample 7.1 The set of relations {a, b} ↔ {0, 1} is the set of sets of pairs

The relation that associates a with 0, a with 1, and b with 0 is the set

The expression is another way of writing (x,y)

1 April 2009 Instructor: Tasneem Darwish 6

Binary RelationsExample 7.2 The relation drives is used to record which makes of car are driven by the members of a small group of people.

If the group of people is defined by:

and the choice of cars is defined by

Then drives is an element of , and the statement `Kate drives a cortina' could be formalised as:

1 April 2009 Instructor: Tasneem Darwish 7

Binary RelationsWe may also choose to introduce a relation as an infix symbol: a

symbol that sits between its arguments.

Many familiar relations are written in this way:the less-than-or-equal-to relation on numbers; the subset relation on sets.

If the pair (x, y) is an element of the infix relation R, then we may write x R y.

When we define an infix relation, we include underscores to indicate where the arguments should go.

1 April 2009 Instructor: Tasneem Darwish 8

Binary RelationsExample 7.3 The relation drives could be defined by

•Simple relations can be illustrated using diagrams with arrows, or graphs.

1 April 2009 Instructor: Tasneem Darwish 9

Binary RelationsExample 7.3 The relation drives could be defined by

•Simple relations can be illustrated using diagrams with arrows, or graphs.