FIT2014 Unit Cheatsheet

Context: FIT2014_MOC · the WHOLE unit in one re-read — languages → logic → automata → grammars → parsing → Turing machines → decidability → complexity → NP-completeness. Links for depth only. Read order: ⛔ = firing precondition (where marks die) · ⚙️ Procedure boxes = execute by hand · 🧮 Blueprint boxes = proof skeleton to fill in · Route: Mid-sem ⟵ §1–§8 · A1 ⟵ §5 · A2 ⟵ §6 lexing, §8 parsing, §9–§11 · Exam ⟵ all.

Quick Revision

  • 🎯 Objective: classify the question — construct/execute (run a ⚙️ procedure) or prove (fill a 🧮 blueprint) — then place the language on the ladder below.
  • ⚡ Key Constraint: hypothesis discipline — infinite vs finite, regular vs context-free, decidable vs recognisable, vs ; a rule fired without its precondition scores nothing.

🪜 The Ladder — the Whole Unit on One Screen

ClassMachineGeneratorProve NOT in itWitness just outside
RegularDFA NFAregex · regular grammarpumping lemma or closure shortcut (§6)
Context-freePDA (nondeterministic)CFGCFL pumping lemma (§8)
decider———
Decidabledecider TM, —reduce from an undecidable language (§11)
r.e. (type 0)recogniser TM · enumerator—show r.e. but undecidable
All languages——uncountably many, TMs countable—
  • Proved vs open ➔ every in the first chain is a theorem with a witness above · the signs in the second chain are not known strict — is open · straddles the /decidable frontier, not a tier of its own.

1️⃣ Languages and Words (W1)

  • Alphabet & word ➔ finite non-empty · word finite sequence over · empty word · ⛔ — no words vs one word.
  • Closure ➔ all finite words incl. · · is countably infinite for finite .
  • Language ➔ any · ⛔ state the defining predicate, never membership by intuition.
  • Named test languages ➔ EVEN-EVEN · DOUBLEWORD · PALINDROME · EQUAL () · HALF-AND-HALF (-style split).

2️⃣ Propositional Logic → CNF Encoding (W1)

  • Connectives ➔ · · ⛔ eliminate implications before De Morgan.
  • De Morgan ➔ · · terms by induction, not assertion.
From a truth tableShapeRead offOne term per rowLiterals
DNFOR of ANDsTrue rowsconjunctas in the row
CNFAND of ORsFalse rowsclausenegated — the whole trick
Constraint on variablesClause size ClausesLiterals
at least trueall unnegated
at most trueall negated (at-least false)
exactly both rows abovesum⛔ write both halves

🧮 Blueprint — encode a problem in CNF

① one variable per atomic choice ② clauses per validity rule ③ conjoin · ⛔ encode the rules, not just the certificate.

3️⃣ Predicates and Quantifiers (W1)

  • Predicate ➔ proposition-valued · a free variable leaves it not yet a proposition; bound makes it one.
  • Pairing rule ➔ with , with · ⛔ over-claims; is vacuously true.
  • Negation ➔ · .
  • Order matters ➔ (the second is stronger) · ⛔ swap only like quantifiers.
  • Distribution ➔ over , over · the mixed pairs do not distribute.

4️⃣ Proof Craft (W2)

Claim shapeTechnique
exhibit one witness
general argument — never by example
direct, or contrapositive
“no such thing exists”contradiction: assume , derive absurdity ()
(sets)double inclusion , , each from “let “
induction
countablean explicit listing
uncountablediagonalisation — e.g. languages over ⟹ some language has no description
  • Induction ➔ base at the smallest relevant , then · ⛔ hypothesis is the full statement for ; test the smallest step ( is the classic failure).
  • Faulty-proof tells ➔ missing/wrong base · hypothesis assumed for · ex falso (false premise proves anything) · example offered for a .

5️⃣ Regular Expressions and Finite Automata (W2–W3 · A1)

  • Regex ➔ , letters, , concatenation, · precedence › concat › · ⛔ and .
  • Finding one ➔ describe the shape of an accepted word, then test the shortest strings incl. .
Automaton-movesAccepts iffComplement by swapping Final?
DFA total, single-valuednothe unique run ends in yes
NFAmulti-valued or missingyessome path ends in ⛔ no — “some path” doesn’t negate pointwise
  • Kleene’s Theorem ➔ regex NFA DFA, proved by the cycle regex → NFA → DFA → regex.

⚙️ Procedure — the Kleene cycle

  • regex → NFA ➔ Thompson-style edge rewriting, one construction per operator.
  • NFA → DFA ➔ states are sets of NFA states · start -closure of · Final iff the set meets · cost up to states ⟹ not polynomial (§1️⃣2️⃣).
  • FA → regex ➔ GNFA state elimination: before deleting a state, relabel every ordered pair as · ⛔ a missed pair loses strings; keep in the union.

6️⃣ Limits of Regularity (W4)

⚙️ Procedure — minimise a DFA

⛔ complete the DFA first · ① two colours: Final / non-Final ② split any class whose rows disagree on successor colours ③ iterate to fixpoint.

  • Lexing vocabulary (A2) ➔ pattern the regex · token the name · lexeme the matched text · conflicts: maximal munch, then first-listed rule.
  • Closure ➔ closed under complement, , (via De Morgan), concatenation, · ⛔ subsets and supersets are not closed.
  • Pumping lemma ➔ infinite regular, -state FA ⟹ every with splits : , , · ⛔ infinite and regular; necessary, never sufficient.

🧮 Blueprint — prove non-regular

① assume regular, pumping length ② choose so forces into one block (canonical ) ③ pump up or down ( is legal) ④ contradiction. Shortcut: non-regular for a regular ⟹ non-regular (EQUAL ).

7️⃣ Context-Free Grammars and PDAs (W5)

  • CFG ➔ terminals, nonterminals, rules with one nonterminal on the left, start · CFL language of some CFG.
  • Derivations ➔ leftmost and rightmost give the same tree and length · the prefix property makes leftmost usable for parsing.
LanguageGrammar
Dyck (balanced brackets)
PALINDROME
any regular languageregular grammar: NFA edge ⟹ (semiword RHS) ⟹ regular CFL
  • PDA ➔ NFA stack · read , pop , push · \texttt{\}$ marks the bottom · accepts iff some path reaches Final.
  • Equivalence ➔ CFG PDA, both directions constructive · an NFA is a stackless PDA · ⛔ deterministic PDAs are strictly weaker: .

8️⃣ Parsing, Chomsky Normal Form, CYK (W6 · A2)

  • Shift-reduce ➔ stack buffer · shift moves a token across · reduce applies a rule in reverse · accept iff stack and buffer empty.
  • Conflicts ➔ shift-reduce (both legal) and reduce-reduce (two rules match) both signal ambiguity.
ToolEmitsEntry pointDefault conflict resolution
Lexlex.yy.cyylex()maximal munch, then first-listed rule (§6)
Yaccy.tab.cyyparse()shift-reduce ⟹ shift · reduce-reduce ⟹ first-listed rule
  • Chomsky NF ➔ every rule (live) or (dead) · ⛔ generates non-empty words only — goes to the nullability algorithm · ⚠ not Conjunctive Normal Form.

⚙️ Procedure — CFG → Chomsky NF, then CYK

  • Convert ➔ ① remove -productions (to fixpoint) ② remove unit productions ③ isolate terminals into dead rules ④ break long RHS into binary chains ⑤ drop unreachable/dead nonterminals.
  • CYK ➔ fill by increasing substring length; a length- cell is the union over its binary splits · accept iff is in the whole-string cell · ⛔ grammar in Chomsky NF · .
CFL pumping — what changes from §6RegularContext-free
Hypothesis-state FACFG in Chomsky NF, nonterminals
Long word
Split
Non-empty part
Window (binary-tree height)
Pump,

🧮 Blueprint — prove non-context-free

① take or ② case-split on which blocks occupy ③ stops them spanning all three blocks ④ pumping breaks the counts in every case.

9️⃣ Turing Machines (W7 · A2)

  • TM ➔ two-way infinite tape, head, finite program · Start , Accept · a crash (no applicable transition) rejects.
  • Three outcomes ➔ · is a decider iff .
  • FA → TM ➔ 5-step conversion ⟹ every regular language is decidable.
  • Mark-and-sweep ➔ mark the leftmost unmarked , run right to its matching , mark, return, repeat · accept when a sweep finds nothing left.
  • Computable function ➔ unary , tuples split by ; computable iff some TM leaves on the tape · ⛔ Church–Turing is a thesis, never a proof step.
  • Code words ➔ one row per transition, 5 fields (state , 2-letter symbols, 1-letter direction) · is regular but larger than the set of genuine codes.
  • UTM ➔ input \langle M\rangle\,\texttt{\},xMx$ — programs as data.

🔟 Decidability and Mapping Reductions (W8 · A2)

  • Decidable (recursive, solvable) ➔ for a decider ; comes free.
  • Problem ↔ language ➔ the YES-inputs · objects encoded , tuples .
  • Closure ➔ decidable languages closed under complement, , , concatenation — deciders as subroutines · ⛔ show every call terminates (a decider guarantees it).
  • FA-Empty ➔ mark Start, propagate forward along transitions to fixpoint · accept iff no Final state is marked.
  • CFG-Empty ➔ mark terminals, propagate upward through rules to fixpoint · accept iff is unmarked.
  • RegExpEquiv ➔ decide emptiness of · needs determinisation ⟹ decidable, not polynomial.
  • Mapping reduction ➔ computable total with · ⛔ write the iff chain both ways.
  • Transfer ➔ decidable ⟹ decidable · undecidable ⟹ undecidable · ⛔ reflexive and transitive, not symmetric — direction is everything.
  • Degenerate case ➔ reducing from a decidable proves nothing about , and needs to exist.

1️⃣1️⃣ Undecidability and Recursive Enumerability (W9 · A2)

  • Existence ➔ TMs countable, languages uncountable ⟹ undecidable languages exist — but names none.
  • HALT ➔ undecidable · proof: build that flips the diagonal ⟹ the assumed decider can’t exist.

🧮 Blueprint — prove undecidable

① pick a known-undecidable (HALT) ② build : from make “ignore the input, run on ” (the input-blind gadget) ③ prove ④ conclude by transfer (§🔟) · ⛔ reduce from to .

ProblemStatusWhy
HALT, HALT-FOR-ZERO, ALWAYS HALTS, SOMETIMES HALTSundecidableinput-blind gadget
NEVER HALTSundecidableAccept/Reject swap · ⛔ legal on deciders only — illegal on recognisers (a loop is neither)
acceptance · -input haltingundecidable—
bounded-step halting · state-countingdecidable—
  • r.e. (Turing-recognisable, type 0) ➔ , unrestricted.
  • Bridge theorem ➔ decidable and r.e. — interleave both machines one step at a time ⟹ decidable r.e. co-r.e.
  • Separation ➔ HALT r.e. but undecidable ⟹ not r.e.
  • Enumeration ➔ r.e. some machine enumerates it, via -then- dovetailing · ⛔ “run input 1 to completion first” hangs on a looping input.

1️⃣2️⃣ P, NP and Polynomial-Time Reductions (W10)

  • Running time ➔ · ⛔ must be a decider, else the max is undefined.
  • ➔ an decider, fixed ( fails) · reasonable models simulate each other with polynomial slowdown; poly of poly is poly.
  • NP ➔ some poly-time with accepts · ⛔ time bound in , never · equivalently NDTM in poly time — ⛔ DFA NFA does not transfer (determinising costs exponential time).
  • Inclusions ➔ (ignore the certificate) · (search certificates).

🧮 Blueprint — prove (all four parts are marked)

① state the certificate ② state the verifier ③ prove the iff ④ bound the time in .

Mapping Poly-time
must becomputable, totalcomputable in
Marked partsfunction · iff chainfunction · iff chain · time bound
Transfersdecidabilitymembership in : ,
⛔directionre-time old proofs — is not
  • Output-length lemma ➔ a TM writes symbol per step ⟹ — the step that makes composition work; omitting it is the standard deduction.
  • Instance stock ➔ VERTEX COVER () · INDEPENDENT SET, CLIQUE () · SAT / 2-SAT / 3-SAT · -COLOURABILITY · HAMILTONIAN CIRCUIT · PARTITION · SUBSET SUM · GRAPH ISOMORPHISM.
Reduction
target

1️⃣3️⃣ NP-Completeness (W11)

  • NP-complete ➔ (a) and (b) · ⛔ (b) alone is only NP-hard.
  • Master theorem ➔ an NP-complete has a poly-time decider · () spends (a); () spends (b) transfer.
  • Equivalence class ➔ for NP-complete : · NP-complete .
  • Cook-Levin Theorem ➔ SAT is NP-complete · proof non-examinable; part (a) — certificate truth assignment, check clause by clause — is examinable.

🧮 Blueprint — prove NP-complete

① by the four-part proof (§1️⃣2️⃣) ② pick a known NP-complete ③ give : function · iff · time ④ conclude by inheritance · ⛔ reduce from the known-hard ; proves nothing.

🧮 Blueprint — reduce a problem to SAT

① variables for the certificate ② auxiliary variables ③ rules → CNF via the §2️⃣ at-least / at-most table ④ state it as an algorithm and count the clauses.

ReductionConstructionSize / catch
PARTITION INTO TRIANGLES SAT per triangle; per vertex an at-least-one clause per triangle pair at it variables, clauses
short clauses: pad with fresh in all sign patterns · long clauses: chain with fresh , fresh variables per clause
edge per variable · triangle per clause · connector from each clause position to its literal · ⛔ must be the exact minimum
  • Chain ➔ ⟹ all five NP-complete.
  • Living with it ➔ drop exactly one of efficient · deterministic · all-cases · exact ⟹ exponential exact / randomised / special-case / approximation.
  • co-NP ➔ complements of languages · ; whether it’s equality is open.