Raw

4. Task and order of execution / Завдання та порядок виконання

Source of tasks. Tasks 1–2 are taken exactly from the assignment “Advanced Propositional Logic and Computational Logic” (their input/output examples are authoritative). Tasks 3–4 extend the work to the level of its prerequisite, Lecture 6 — implication/equivalence and a satisfiability/tautology decision.

Order of execution

Implement in order and test each against its example; your score corresponds to the highest band you complete correctly. Reuse the Task 1 evaluator throughout. (The tables below list true before false; Lecture 6 and Practical 3 instead list false first — either order is acceptable as long as your program is consistent.)

Easy tasks (60–74 points)

Task 1 — Complex logical expressions evaluation

Evaluate a logical expression, built from AND, OR, NOT, and parentheses, under a given assignment of truth values to its variables.

  • Input:
    • Expression: "(A AND B) OR (NOT C)"
    • Values: {"A": true, "B": false, "C": true}
  • Output:
    • Result: false

Task 2 — Automated truth table generation

Given a logical expression, generate its complete truth table — one row for every combination of truth values of its variables.

  • Input:
    • Expression: "(A AND B) OR C"
  • Output — Truth Table:
A B C (A AND B) OR C
true true true true
true true false true
true false true true
true false false false
false true true true
false true false false
false false true true
false false false false

Medium tasks (75–89 points)

Task 3 — Implication and equivalence

Extend the evaluator to the connectives IMPLIES (\to) and IFF (\leftrightarrow), with precedence ¬>>>>\neg > \wedge > \vee > \to > \leftrightarrow, and print the truth table of the input expression.

  • Input: Expression: "(A IMPLIES B) IFF ((NOT B) IMPLIES (NOT A))"
  • Output: every row of the truth table is true — the expression is a tautology (it is the contrapositive law AB¬B¬AA\to B \equiv \neg B\to\neg A).

Hard tasks (90–100 points)

Task 4 — Satisfiability / tautology classifier

Given an expression, classify it by scanning its truth table as a tautology (true in every row), a contradiction (false in every row), or a contingency (satisfiable but not a tautology).

  • Input: Expression: "A AND (NOT A)"
  • Output: Classification: Contradiction (unsatisfiable).

Laboratory/Laboratory4/4task.md · 2.6 KB · updated 2026-08-01 17:54