Skip to content
Lavínia Beghini edited this page Sep 23, 2020 · 8 revisions

{ Algebra of Sets }

Algebra of Sets is an application developed for an assignment of a Discrete Mathematics class, with the goal of deepening the knowledege on the general subject. First, the subject was aproached in the form of theory studies and then, in a practical manner. The main purpouse of the application is to implement the basic operations related to sets, in a very basic stack of tools.

System Specifications

These specifications was given from the teacher of the Discrete Mathematics class. It was originally written in portuguese. This is an open translation.

Build a system with the following characteristics:

1. Data entry read from a text file.

2. The lines in the file may contain the following information:

  • One or more sets.
  • One or more elements.

3. Line format:

  • Set: A single capital letter, the equal sign, key opening, n elements separated by commas (n ≥ 0), closing the key.
A = {1, 87, 4, −1, 43}
  • Element: A single lowercase letter, the equal sign, a value.
b = 87

Elements are always integers.

4. A menu that displays and checks or calculates the following operations:

  • Belongs
  • Does not belong
  • Subset
  • Not subset
  • Proper subset
  • Not proper subset
  • Union
  • Intersection
  • Cartesian product
  • Set of parts
  • Subtrataction

5. Observe the necessary and sufficient operands for each operation.

If operands are missing, report an error. If left over, use the first ones in the input file and ignore the rest.

6. If possible, use all the operands in the input file.

7. Examples:

  • Belongs and Does not Belong: use the first occurrence of the set and the first of the element. Despise the others.
  • Union and Intersection: use all occurrences of sets and ignore the elements.
  • Cartesian product: use the first two occurrences of sets.
  • Set of parts: use the first set occurrence.

8. Outputs can be for screen or file.

9. The menu options are elementary operations. Whenever possible, use them in more complex computations.

In other words, create functions or methods to implement them and reuse them instead of repeating code snippets or reasoning elsewhere in the system.
For example, use Belongs or Does not belong to check Subset.

10. Whenever the operation is reversible, at the end of the execution of the operation, ask if the user wants to revert (find the original operands).

If the user chooses yes, revert (find the initial operands).
Important: do not take the initial operands on some object or in the input data. Perform the reverse operation!