Skip to content

How to Use

Lavínia Beghini edited this page Sep 23, 2020 · 5 revisions

Operation Strings

This program utilizes String inputs to get the solutions. It is necessary to pay attention to the outputs of each operation so the String can work. The Operation Strings where design so you can make more diverse operations.

Combinations of Sets

When combined, you can understand the operations that return sets as a unique set.

The operations that returns sets are:

OPERATION OPERATOR
Union +
Subtraction -
Intersection *

Example

Given Sets A = {1, 3, 5}, B = {1, 2, 4} and C = {5, 2, 9}, then

-----------------------------------------------
OPERATION STRING: A + B - C 
-----------------------------------------------
SOLUTION: {1, 4, 3}
-----------------------------------------------

Element operations

You can compare if an Element belongs to a Set or a Combination of Sets.

The element operators are:

OPERATION OPERATOR
Belongs <
Does not belong >

The only thing you should pay attention is that this comparison must follow the structure:

element (element operator) set

The element and element operator needs to be in the beginning of the string. The semantics matters.

Example

Given Sets A = {1, 3, 5}, B = {1, 2, 4} and C = {5, 2, 9}, and Element x = 2, then:

-----------------------------------------------
OPERATION STRING: x < A * B - C
-----------------------------------------------
SOLUTION: false
-----------------------------------------------

Operations between two sets

Operations between sets can be written as:

set (operation) set

Set can be a Combination of Sets

The operations between sets two sets are:

OPERATION OPERATOR
Subset (
Not Subset )
Proper subset [
Not proper subset ]
Cartesian Product x

Example

Given Sets A = {1, 3, 5}, B = {1, 2, 4} and C = {5, 2, 9}, then:

-----------------------------------------------
OPERATION STRING: A + B ] C * A
-----------------------------------------------
SOLUTION: true
-----------------------------------------------

Powerset Operations

Inside the powerset brackets, a Set or Combination of Sets can be included.

Example

Given Sets A = {1, 3, 5}, B = {1, 2, 4} and C = {5, 2, 9}, then:

-----------------------------------------------
OPERATION STRING: P(A - B * C)
-----------------------------------------------
SOLUTION: {{ }, {2}}
-----------------------------------------------

Operations

When the program starts, it show the Sets and Elements founded in the file set.txt.
With these, you can choose one of the following operations, that are represented by a special characther:

OPERATION OPERATOR
Union +
Subtraction -
Intersection *
Belongs <
Does not belong >
Subset (
Not Subset )
Proper subset [
Not proper subset ]
Cartesian Product x
Powerset P()

It's important to pay attention to the syntax of each operation.

Union

The union (+) of two sets A and B is the set of elements which are in A, in B, or in both A and B.

Example

Given Sets A = {1, 3, 5, 7} and B = {1, 2, 4, 6, 7}, then

-----------------------------------------------
OPERATION STRING: A + B 
-----------------------------------------------
SOLUTION: {1, 2, 3, 4, 5, 6, 7}
-----------------------------------------------

Subtraction

The subtraction (-) of B and A, is the set of elements in B but not in A.

Example

Given Sets A = {1, 3, 5, 7} and B = {1, 2, 4, 6, 7}, then

-----------------------------------------------
OPERATION STRING: B - A 
-----------------------------------------------
SOLUTION: {2, 4, 5, 6}
-----------------------------------------------

Intersection

The intersection (*) is the set containing all elements of A that also belong to B (or equivalently, all elements of B that also belong to A)

Example

Given Sets A = {1, 3, 5, 7} and B = {1, 2, 4, 6, 7}, then

-----------------------------------------------
OPERATION STRING: B * A 
-----------------------------------------------
SOLUTION: {1, 7}
-----------------------------------------------

Belongs

The belongs (<) test returns if an element x belongs to a set A.

Example

Given Set A = {1, 3, 5, 7} and Element x = 3, then

-----------------------------------------------
OPERATION STRING: x < A
-----------------------------------------------
SOLUTION: true
-----------------------------------------------

Does not belong

The Does not belong (>) test returns if an element x belongs to a set A.

Example

Given Set A = {1, 3, 5, 7} and Element x = 3, then

-----------------------------------------------
OPERATION STRING: x > A
-----------------------------------------------
SOLUTION: false
-----------------------------------------------

Subset

The Subset (() test returns if every element of A belongs to B. A can be equal to B.

Example

Given Sets A = {1, 3, 5, 7} and B = {1, 2, 4, 6, 7}, then

-----------------------------------------------
OPERATION STRING: A ( B
-----------------------------------------------
SOLUTION: false
-----------------------------------------------

Not subset

The Not subset ()) test returns if not every element of A belongs to B.

Example

Given Sets A = {1, 3, 5, 7} and B = {1, 2, 4, 6, 7}, then

-----------------------------------------------
OPERATION STRING: A ) B
-----------------------------------------------
SOLUTION: true
-----------------------------------------------

Proper subset

The Proper subset ([) test returns if every element of A belongs to B. A can't be equal to B.

Example

Given Sets A = {1, 3, 5, 7} and B = {1, 2, 4, 6, 7}, then

-----------------------------------------------
OPERATION STRING: A [ B
-----------------------------------------------
SOLUTION: false
-----------------------------------------------

Not Proper subset

The Not Proper subset (]) test returns if not every element of A belongs to B.

Example

Given Sets A = {1, 3, 5, 7} and B = {1, 2, 4, 6, 7}, then

-----------------------------------------------
OPERATION STRING: A ] B
-----------------------------------------------
SOLUTION: true
-----------------------------------------------

Cartesian Product

The Cartesian Product (x) of two sets A and B, is the set of all ordered pairs <a, b> where a is in A and b is in B.

Example

Given Sets A = {1, 3, 5} and B = {5, 6}, then

-----------------------------------------------
OPERATION STRING: A x B
-----------------------------------------------
SOLUTION: {<1,5>, <1,6>, <3,5>, <3,6>, <5,5>, <5,6>}
-----------------------------------------------

It is a reversive operation, which means that you can redefine the sets that originated this result.

Powerset

The Powerset (P()) is the set of all subsets of A, including the empty set and A itself.

Example

Given Set A = {1, 3, 5}, then

-----------------------------------------------
OPERATION STRING: P(A)
-----------------------------------------------
SOLUTION: {{ }, {1}, {3}, {3, 1}, {5}, {5, 1}, {5, 3}, {5, 3, 1}}
-----------------------------------------------

It is a reversive operation, which means that you can redefine the sets that originated this result.