Raw

6. Control questions and tasks / Контрольні запитання і завдання

Propositions and connectives

  1. What is a proposition? Give an example of a sentence that is a proposition and one that is not.
  2. Write the truth tables of ¬A\neg A, ABA \wedge B, and ABA \vee B.
  3. State the precedence of NOT, AND, and OR. How do parentheses change the reading of an expression? Fully parenthesise NOT A AND B OR C.

Evaluation and truth tables

  1. How many rows does the truth table of a formula with nn distinct variables have? Why?
  2. Define a tautology, a contradiction, and a contingency in terms of a formula’s truth table.
  3. Two formulas are logically equivalent when their truth tables are identical. Are NOT (A AND B) and (NOT A) OR (NOT B) equivalent? Justify your answer. (This is one of De Morgan’s laws.)

Implementation

  1. Why should you not use the host language’s eval to solve Task 1? Name one risk and one limitation.
  2. Outline how a recursive-descent parser encodes the precedence of NOT, AND, and OR. Which grammar rule handles the lowest-precedence operator?
  3. Describe an algorithm that enumerates all 2n2^n assignments of nn variables. How can counting in binary from 00 to 2n12^n - 1 help?
  4. What is the time complexity of generating a full truth table for an expression of size mm with nn variables?

Tasks by hand

  1. Evaluate (A AND B) OR (NOT C) under A=F, B=T, C=FA = F,\ B = T,\ C = F. Show each step.
  2. Build the complete truth table of A OR (NOT B).
  3. Determine, by building its truth table, whether (A AND B) OR (NOT A) is a tautology, a contradiction, or a contingency.

Laboratory/Laboratory4/6questions.md · 1.7 KB · updated 2026-07-31 21:14