Computational Thinking (CO2412) Tutorial 4.1: Week 17
4.1 Parse tree data structure for statements in propositional logic
The propositional logic statements notebook defines a data structure, the class Propositional,
that represents a logical statement by a tree (this is also known as a parse tree).

- Have a look at the code and the examples.
Raise anything that is unclear for discussion during the tutorial.
- Create a Propositional object for the
statement ((p ∨ q) ∧ (¬p ∨ ¬q))
and print its truth table.
- What would be the correct truth table for the statement ((p ∧ q) ↔ (q ∧ r))?
- In the method evaluate(self, valuation) of the class Propositional,
the implementation of logical equivalence (operator ↔, also called biconditionality)
is missing. Add an implementation for this and check that it works correctly, e.g.,
by printing the truth table of the Propositional object statement_R
that represents the propositional logic statement ((p ∧ q) ↔ (q ∧ r)).
- Create a Propositional object that generates the following truth table:
False(p) False(q) False(r) <> False
False(p) False(q) True(r) <> False
False(p) True(q) False(r) <> False
False(p) True(q) True(r) <> True
True(p) False(q) False(r) <> True
True(p) False(q) True(r) <> True
True(p) True(q) False(r) <> True
True(p) True(q) True(r) <> True
Submission deadline: 12th February 2022; discussion planned for
8th March 2022. Group work by up to four people is welcome.