**protocol**

`setp`

¶

Set protocol.

**Author:**Paulo Moura

**Version:**1.6

**Date:**2019/5/23

**Compilation flags:**

`static`

**Dependencies:**

**Remarks:**

## Public predicates¶

`as_set/2`

¶

Returns a set with all unique elements from the given list.

**Compilation flags:**

`static`

**Template:**

`as_set(List,Set)`

**Mode and number of proofs:**

`as_set(@list,-set)`

- `one`

`as_list/2`

¶

Returns a list with all elements of the given set.

**Compilation flags:**

`static`

**Template:**

`as_list(Set,List)`

**Mode and number of proofs:**

`as_list(@set,-list)`

- `one`

`delete/3`

¶

Deletes an element from a set returning the set of remaining elements.

**Compilation flags:**

`static`

**Template:**

`delete(Set,Element,Remaining)`

**Mode and number of proofs:**

`delete(+set,@term,?set)`

- `one`

`disjoint/2`

¶

True if the two sets have no element in common.

**Compilation flags:**

`static`

**Template:**

`disjoint(Set1,Set2)`

**Mode and number of proofs:**

`disjoint(+set,+set)`

- `zero_or_one`

`equal/2`

¶

True if the two sets are equal.

**Compilation flags:**

`static`

**Template:**

`equal(Set1,Set2)`

**Mode and number of proofs:**

`equal(+set,+set)`

- `zero_or_one`

`empty/1`

¶

True if the set is empty.

**Compilation flags:**

`static`

**Template:**

`empty(Set)`

**Mode and number of proofs:**

`empty(+set)`

- `zero_or_one`

`insert/3`

¶

Inserts an element in a set, returning the resulting set.

**Compilation flags:**

`static`

**Template:**

`insert(In,Element,Out)`

**Mode and number of proofs:**

`insert(+set,+term,?set)`

- `one`

`insert_all/3`

¶

Inserts a list of elements in a set, returning the resulting set.

**Compilation flags:**

`static`

**Template:**

`insert_all(List,In,Out)`

**Mode and number of proofs:**

`insert_all(+list,+set,?set)`

- `one`

`intersect/2`

¶

True if the two sets have at least one element in common.

**Compilation flags:**

`static`

**Template:**

`intersect(Set1,Set2)`

**Mode and number of proofs:**

`intersect(+set,+set)`

- `zero_or_one`

`intersection/3`

¶

Returns the intersection of `Set1`

and `Set2`

.

**Compilation flags:**

`static`

**Template:**

`intersection(Set1,Set2,Intersection)`

**Mode and number of proofs:**

`intersection(+set,+set,?set)`

- `zero_or_one`

`intersection/4`

¶

True if `Intersection`

is the intersection of `Set1`

and `Set2`

and `Difference`

is the difference between `Set2`

and `Set1`

.

**Compilation flags:**

`static`

**Template:**

`intersection(Set1,Set2,Intersection,Difference)`

**Mode and number of proofs:**

`intersection(+set,+set,?set,?set)`

- `zero_or_one`

`size/2`

¶

Number of set elements.

**Compilation flags:**

`static`

**Template:**

`size(Set,Size)`

**Mode and number of proofs:**

`size(+set,?integer)`

- `zero_or_one`

`member/2`

¶

`Element`

is a member of set `Set`

.

**Compilation flags:**

`static`

**Template:**

`member(Element,Set)`

**Mode and number of proofs:**

`member(+term,+set)`

- `zero_or_one`

`member(-term,+set)`

- `zero_or_more`

`memberchk/2`

¶

Checks if a term is a member of a set.

**Compilation flags:**

`static`

**Template:**

`memberchk(Element,Set)`

**Mode and number of proofs:**

`memberchk(+term,+set)`

- `zero_or_one`

`powerset/2`

¶

Returns the power set of a set, represented as a list of sets.

**Compilation flags:**

`static`

**Template:**

`powerset(Set,Powerset)`

**Mode and number of proofs:**

`powerset(+set,-list)`

- `one`

`product/3`

¶

Returns the cartesian product of two sets.

**Compilation flags:**

`static`

**Template:**

`product(Set1,Set2,Product)`

**Mode and number of proofs:**

`product(+set,+set,-set)`

- `one`

`select/3`

¶

Selects an element from a set, returning the set of remaining elements.

**Compilation flags:**

`static`

**Template:**

`select(Element,Set,Remaining)`

**Mode and number of proofs:**

`select(?term,+set,?set)`

- `zero_or_more`

`selectchk/3`

¶

Checks that an element can be selected from a set, returning the set of remaining elements.

**Compilation flags:**

`static`

**Template:**

`selectchk(Element,Set,Remaining)`

**Mode and number of proofs:**

`selectchk(?term,+set,?set)`

- `zero_or_one`

`subset/2`

¶

True if `Subset`

is a subset of `Set`

.

**Compilation flags:**

`static`

**Template:**

`subset(Subset,Set)`

**Mode and number of proofs:**

`subset(+set,+set)`

- `zero_or_one`

`subtract/3`

¶

True when `Difference`

contains all and only the elements of `Set1`

which are not also in `Set2`

.

**Compilation flags:**

`static`

**Template:**

`subtract(Set1,Set2,Difference)`

**Mode and number of proofs:**

`subtract(+set,+set,?set)`

- `zero_or_one`

`symdiff/3`

¶

True if `Difference`

is the symmetric difference of `Set1`

and `Set2`

, containing all elements that are not in the sets intersection.

**Compilation flags:**

`static`

**Template:**

`symdiff(Set1,Set2,Difference)`

**Mode and number of proofs:**

`symdiff(+set,+set,?set)`

- `zero_or_one`

## Protected predicates¶

(none)

## Private predicates¶

(none)