Course Test · University: upper level

Theory of computation: test

A DFA for parity, the minimal DFA for words ending in 01, the subset construction for ((a|b)^*abb), equivalence of regular expressions, intersecting languages with a product automaton, a regular expression from a DFA, the grammar and PDA for (a^nb^n), Chomsky normal form, a Turing machine adding one in binary, primitive recursive and (mu)-recursive functions, the pumping lemma and the halting problem (where no computation can stand in for the proof), a full adder, and the master theorem.

Twenty exercises of the kind this course sets. Answers are on the independent answers page; the same exercises done with RatMath are on the RatMath answers page.

  1. 1.Deterministic automata
    Design a DFA over {0,1}\{0, 1\} accepting words with an even number of 1s. Does it accept 1011? 1001?
  2. 2.Minimal DFA
    How many states does the minimal DFA for binary words ending in 01 have?
  3. 3.Subset construction
    Convert (a∣b)∗abb(a|b)^*abb to a DFA and minimise it. How many states? Does it accept aababbaababb and abababab?
  4. 4.Equivalent regular expressions
    Are (a∣b)∗(a|b)^* and (a∗b∗)∗(a^*b^*)^* equivalent?
  5. 5.Product construction
    Build an automaton for words over {a,b}\{a, b\} with an even number of aas and an odd number of bbs. Test aabaab and abab.
  6. 6.From DFA to regular expression
    Give a regular expression for binary words with an even number of 1s.
  7. 7.Context-free grammars
    Give a grammar for {anbn:n≥0}\{a^nb^n : n \ge 0\}. Does it generate aabbaabb? aabaab? List its words of length at most 6.
  8. 8.Chomsky normal form
    Convert S→aSb∣εS \to aSb \mid \varepsilon to Chomsky normal form.
  9. 9.Pushdown automata
    Run a PDA for anbna^nb^n (push on aa, pop on bb) on aabbaabb and aabaab.
  10. 10.Pumping lemma
    Prove that {anbn}\{a^nb^n\} is not regular.
  11. 11.Turing machines
    Run a Turing machine that adds one to a binary number on the input 1011.
  12. 12.Primitive recursion
    Using only primitive recursive building blocks, compute 3+43 + 4, 2102^{10} and 7!7!.
  13. 13.Composition of recursive functions
    Define d(x)=x+xd(x) = x + x by composing addition with projections, and evaluate d(21)d(21).
  14. 14.Minimisation
    Use the μ\mu operator to compute the integer square root of 30: the least yy with (y+1)2>30(y + 1)^2 > 30.
  15. 15.The halting problem
    Is there an algorithm that decides, for every program and input, whether the program halts?
  16. 16.Circuits
    A full adder adds bits a,ba, b and a carry cinc_{in}. What are the sum and carry for 1+1+11 + 1 + 1?
  17. 17.Ripple-carry adder
    How many gates and what depth does a ripple-carry adder for 4-bit numbers have, built from full adders of 5 gates and depth 3?
  18. 18.Master theorem
    Solve T(n)=2T(n/2)+nT(n) = 2T(n/2) + n and T(n)=8T(n/2)+n2T(n) = 8T(n/2) + n^2 asymptotically.
  19. 19.SAT as a decision problem
    Is (x1∨x2)∧(¬x1∨x3)∧(¬x2∨¬x3)∧(x1∨¬x3)(x_1 \lor x_2) \land (\lnot x_1 \lor x_3) \land (\lnot x_2 \lor \lnot x_3) \land (x_1 \lor \lnot x_3) satisfiable? Give a satisfying assignment.
  20. 20.Counting accepted words
    How many binary words of length 4 have an even number of 1s?