0

I have been working on this project and came to this trouble on the process of obtaining the parts of the formula for a separate evaluation.

Like for example: (~p>~q)^(~(p^q))

I should get:

  1. (~p)
  2. (~q)
  3. (~p>~q)
  4. (p^q)
  5. (~(p^q))
  6. (~p>~q)^(~(p^q))

I managed to get the most basic ones like 1,2,3 and 4 but from there i haven't managed to get the 5 and 6.

This website shows exactly how I want to do it: Truth table generator

  • 1
    This requires a parser, something which is a bit too broad for a single Stack Overflow question. If you want to stick to standard libraries, one possibility is to replace negation with `-`, and with `*` and or with `+`, let the `ast` module parse the resulting expression, and then walk the resulting parse tree. – John Coleman Feb 27 '22 at 19:22
  • Please provide enough code so others can better understand or reproduce the problem. – Community Feb 27 '22 at 23:53

0 Answers0