Universal/Existential Quantifier Testing and Binary Conversion

What does this program do and why is it important?

This program takes a closed formula with “n” elements which is stored in a set. The program also takes a value “m” in which if the domain of “X” is the first “n” elements of a sequence and “m” is another value, both of the quantifiers must be defined.

This program also sums the first “n” elements and converts this number into a binary value. Without using built in functions to find these values, I used the iterative tools and conditional statements.

Guidelines

This was an individual project for a discrete mathematics course I took last spring. I thoroughly enjoyed the combination of mathematical analysis and predicate logic involved. Here is some code that illustrates the binary conversion:

total = sum
binary_total= ''
while total > 0:
  remainder = str(total % 2)
  binary_total += remainder
  total //= 2
print(f'The sum of the first {n} elements is: ({sum})\u2081\u2080 equivalent to ({binary_total[::-1]})\u2082 ')
print(int(binary_total[::-1], 2))