Please enable JavaScript.
Coggle requires JavaScript to display documents.
Functions, Sequences and Arrays - Coggle Diagram
Functions, Sequences and Arrays
A function from S to T is:
A relation containing pairs (x,y) : S*T with a special property: elements x from S may only relate to one element y from T
Types of function which can be used in Atelier-B
Injective function
Surjective function
Total function
Bijective function
Partial function
Sequences are a special type of function
They are used to describe lists of a given type
Operations of a sequence
Reverse
Returns the reverse of a given sequence s
Prefixing
Prefixing an element e onto the front of a sequence s
Concatenation
Receives two sequences and returns one sequence resulting from putting together the two original sequences
First
Returns the first element of a sequence
Size
Returns the size of a sequence
Last
Returns the last element of a sequence
Front
Return the initial part of a sequence (All elements except the last)
Truncation
Returns the first n elements of s
Removal
Remove the first n elements of a sequence
There are three special types of sequence
iseq(S)
Injective sequences containing elements of S. Sequences with no repetition
seq1(S)
All non-empty sequences containing elements of S
perm(S)
Contains all the permutations of S. It must have all the elements (Only the order can be changed)
They can be defined by a list of separated elements between square brackets
Any sequence is a total function from index to elements
Sequences can be like: colours = [red, green, blue]. Or they can be empty, with no elements in it: S = []. Sequences can have repeated elements
Arrays are total functions with 0 as the lower bound
It is described as function that maps each index to an element
How to assign elements or relations to an array
r(3) := E
r := 0..3*{F}
Arrays can have other types rather than numbers, like names