π FIT2014: Theory of Computation
Map of Content
Index for FIT2014 (Malaysia campus). Arc: languages β logic/CNF β automata β grammars β parsing β Turing machines β NP-completeness. Conventions: alphabets, empty word, CNF is the working form β but Conjunctive Normal Form (logic) β Chomsky Normal Form (grammars); W1β2 logic notes are shared dual-unit with FIT1058_MOC.
π Assessment Map
- Practical Preparation (5%) β ongoing weekly prac work β part of the in-semester threshold hurdle.
- Assignment 1 (10%) β Regular Expressions + Finite Automata β the W2 logic/CNF + coming automata material.
- Mid-semester Test (15%) β everything to ~W6 βΉ languages, logic, encoding, regexβautomata must be solid EARLY.
- Assignment 2 (20%) β Lexical Analysis, Parsing, Computability.
- Final exam (3h10, 50%) β whole unit; the exam is a hurdle AND the in-semester tasks form a threshold hurdle.
- Reference text β Sipser (pp. 13β14 strings/languages; Β§0.3 pp. 17β20 definitions/theorems/proofs; pp. 14β15 and p. 302 for normal forms).
- LO thread so far β define and manipulate formal languages; read/write propositional and predicate logic; encode real problems in CNF (the recurring assessable skill).
π§° Toolkit Cheatsheets
- FIT2014 Unit Cheatsheet β the whole-unit exam crib β W1βW11 as formulas/rules with firing preconditions, in syllabus order; the single re-read before the 3h10 exam
- Shell Toolkit (Cheatsheet) β tri-unit (FIT1043 + FIT2014 + FIT2109); FIT2014 adds the
sed/tr/grep-regex block (Lab 0)
π Knowledge Index
Lab 0 β Linux Tooling (all assignment work runs in Linux)
- Unix Shell (Bash) β Parent Framework: FIT2014_MOC (tri-unit β navigate/inspect/pipe/grep; grep patterns are regexes)
- Text Processing with sed and tr β Parent Framework: Unix Shell (Bash) (applied bridge to Regular Expressions β POSIX BRE)
Week 1 β Languages, Propositional & Predicate Logic (Lectures 1β3)
- Formal Languages (Alphabets, Words, Languages) β Parent Framework: FIT2014_MOC
- Theorem and Proof β Parent Framework: FIT1058_MOC (shared with FIT1058 β existential vs universal claims, βproof by example is not a proofβ)
- Proposition and Truth Value β Parent Framework: FIT1058_MOC (shared)
- Logical Connectives β Parent Framework: Proposition and Truth Value (shared β , truth tables, De Morgan)
- Boolean Algebra Laws β Parent Framework: Logical Connectives (shared β tautology, logical equivalence, distributive laws)
- Disjunctive Normal Form β Parent Framework: Boolean Algebra Laws (Smart Merged: dual-unit + the True-row/False-row two-table routine)
- Conjunctive Normal Form β Parent Framework: Boolean Algebra Laws (Smart Merged: dual-unit + FIT2014βs CNF-dominance framing)
- Encoding Problems in Propositional Logic β Parent Framework: Conjunctive Normal Form
- CNF Encoding Patterns (At Least, At Most, Exactly) β Parent Framework: Conjunctive Normal Form
- Predicate β Parent Framework: FIT1058_MOC (Smart Merged: dual-unit + free/bound variables, predicates vs functions)
- Quantifiers (Existential and Universal) β Parent Framework: Theorem and Proof (Smart Merged: dual-unit + multiple quantifiers, order sensitivity, distribution laws)
Week 2 β Proof Craft & Regular Expressions (Lectures 4β6)
- Proof Techniques β Parent Framework: Theorem and Proof (Smart Merged: dual-unit + set/numerical equality strategies, canonical)
- Mathematical Induction β Parent Framework: Proof Techniques (Smart Merged: dual-unit + correct hypothesis phrasing, extended De Morgan)
- Proof Critique (Good, Bad and Ugly Proofs) β Parent Framework: Proof Techniques
- Countability and Cantor Diagonalisation β Parent Framework: Formal Languages (Alphabets, Words, Languages)
- Regular Expressions β Parent Framework: Formal Languages (Alphabets, Words, Languages) (A1 material)
- Finding Regular Expressions β Parent Framework: Regular Expressions (A1 hand skill)
Week 3 β Finite Automata & Kleeneβs Theorem (Lectures 7β9)
- Finite Automata (DFA and NFA) β Parent Framework: Formal Languages (Alphabets, Words, Languages) (A1 material β DFA/NFA clustered as variants + complement construction)
- Kleeneβs Theorem β Parent Framework: Formal Languages (Alphabets, Words, Languages) (the equivalence + the four-leg conversion cycle)
- Converting Regular Expressions to NFA β Parent Framework: Kleeneβs Theorem (A1 hand skill)
- NFA to DFA (Subset Construction) β Parent Framework: Kleeneβs Theorem (A1 hand skill)
- FA to Regular Expression (GNFA State Elimination) β Parent Framework: Kleeneβs Theorem (A1 hand skill)
Week 4 β Minimisation, Lexical Analysis & the Limits of Regularity (Lectures 10β11)
- DFA Minimisation (Colouring) β Parent Framework: Finite Automata (DFA and NFA) (completes the regex β NFA β DFA β simplify pipeline)
- Lexical Analysis (Patterns, Tokens, Lexemes) β Parent Framework: Finite Automata (DFA and NFA) (A2 material β the application of FAs)
- Closure Properties of Regular Languages β Parent Framework: Kleeneβs Theorem (complement/union/intersection/concatenation; the De Morgan route)
- Pumping Lemma for Regular Languages β Parent Framework: Finite Automata (DFA and NFA) (circuits + the pigeonhole proof)
- Proving a Language Non-Regular β Parent Framework: Pumping Lemma for Regular Languages (the exam hand skill β HALF-AND-HALF, PALINDROME, EQUAL)
- (Closes the standing question: regular languages is a proper subset of all languages β see Kleeneβs Theorem and Countability and Cantor Diagonalisation.)
Week 5 β Context-Free Grammars & Pushdown Automata (Lectures 12β14)
- Context-Free Grammars (CFG) β Parent Framework: Formal Languages (Alphabets, Words, Languages) (terminals/nonterminals/productions, BNF, CFL definition)
- Derivations and Parse Trees β Parent Framework: Context-Free Grammars (CFG) (leftmost/rightmost, the prefix property)
- Writing a CFG β Parent Framework: Context-Free Grammars (CFG) (hand skill β Dyck, PALINDROME, )
- Regular Grammars and the CFL Hierarchy β Parent Framework: Context-Free Grammars (CFG) (NFAβgrammar; regular β context-free)
- Pushdown Automata (PDA) β Parent Framework: Context-Free Grammars (CFG) (NFA + stack; CFG βΊ PDA)
- (Picks up the pumping-lemma escapees: EQUAL, HALF-AND-HALF, PALINDROME are all context-free β see Proving a Language Non-Regular.)
Week 6 β Parsing, Chomsky Normal Form & the CFL Frontier (Lectures 15β17)
- Parsing and Shift-Reduce Parsers β Parent Framework: Derivations and Parse Trees (A2 material β stack/buffer trace + shift-reduce & reduce-reduce conflicts)
- Lex and Yacc (Parser Generators) β Parent Framework: Parsing and Shift-Reduce Parsers (A2 toolchain β
lex.yy.c/yylex(),y.tab.c/yyparse()) - Chomsky Normal Form β Parent Framework: Context-Free Grammars (CFG) (the 5-step conversion + nullability; β not Conjunctive Normal Form)
- CYK Algorithm β Parent Framework: Chomsky Normal Form (hand skill β the length-ordered table, )
- Pumping Lemma for Context-Free Languages β Parent Framework: Context-Free Grammars (CFG) (, ; the two-lemma contrast table)
- Proving a Language Non-Context-Free β Parent Framework: Pumping Lemma for Context-Free Languages (the exam hand skill β , )
- (Closes the hierarchy picture: regular β context-free β all languages β escapes even the CFLs.)
Week 7 β Turing Machines & Universality (Lectures 18β19)
- Turing Machines β Parent Framework: Formal Languages (Alphabets, Words, Languages) (A2 material β the model, , deciders, FAβTM)
- Building Turing Machines β Parent Framework: Turing Machines (the exam hand skill β the marking recipe, and )
- Computable Functions and the Church-Turing Thesis β Parent Framework: Turing Machines (unary codes, successor/double/addition, the thesis is not a theorem)
- Encoding Turing Machines (Code Words) β Parent Framework: Turing Machines (hand skill β encode/decode a table; CWL is regular but β {TM codes})
- Universal Turing Machine β Parent Framework: Turing Machines (programs as data β the stored-program idea)
- (Breaks the hierarchyβs ceiling: defeated the CFL pumping lemma yet a TM decides it β see Proving a Language Non-Context-Free.)
Week 8 β Decidability & Mapping Reductions (Lectures 20β21)
- Decidability and Decision Problems β Parent Framework: Turing Machines (deciders, decidable = recursive = solvable, problem β· language, encoding, closure)
- Deciding Properties of FAs and CFGs β Parent Framework: Decidability and Decision Problems (hand skill β FA-Empty & CFG-Empty marking, RegExpEquiv via symmetric difference)
- Mapping Reductions β Parent Framework: Decidability and Decision Problems (the exam hand skill β , the transfer theorem, direction discipline)
- (Adds the tier above the hierarchy: regular β context-free β decidable β ? β the outer ring stays unnamed until undecidability.)
Week 9 β Undecidability & Recursive Enumerability (Lectures 22β23)
- Undecidability and the Halting Problem β Parent Framework: Decidability and Decision Problems (names the ring β counting + the diagonalisation/Liar proof)
- Proving Undecidability by Reduction β Parent Framework: Mapping Reductions (the exam hand skill β the input-blind gadget )
- Recursively Enumerable Languages β Parent Framework: Decidability and Decision Problems (decidable r.e. co-r.e.; vs )
- Enumerators and Dovetailing β Parent Framework: Recursively Enumerable Languages (the generative characterisation + the -then- schedule)
- (Fills in the outer ring at last: regular β context-free β decidable β r.e. β all languages β and are the two named separating inhabitants.)
Week 10 β Complexity: P, NP & Polynomial-Time Reductions (Lectures 24β26)
- Polynomial Time and the Class P β Parent Framework: Decidability and Decision Problems (decidability is not enough β , fixed , the polynomial-slowdown model-independence proof)
- Verifiers, Certificates and the Class NP β Parent Framework: Polynomial Time and the Class P (the exam hand skill β the 4-part membership proof; ; NDTMs)
- Standard NP Problems and Certificates β Parent Framework: Verifiers, Certificates and the Class NP (the named instance stock β VC/IS/CLIQUE, SAT family, Euler vs Hamilton, PARTITION/SUBSET SUM)
- Polynomial-Time Reductions β Parent Framework: Mapping Reductions (the exam hand skill β , the output-length lemma, the transfer theorem)
- (Splits the decidable tier by cost: regular β context-free β P β decidable, with straddling the frontier β and re-times Mapping Reductions, which transferred decidability but not tractability.)
Week 11 β NP-Completeness (Lectures 27β30)
- NP-Completeness β Parent Framework: Verifiers, Certificates and the Class NP (conditions (a)+(b), the master theorem poly-decider , co-NP, the four engineering options)
- Reducing to SATISFIABILITY β Parent Framework: NP-Completeness (the W11 hand skill β the 4-step recipe + PARTITION INTO TRIANGLES worked end-to-end; the W1 CNF templates re-timed)
- Cook-Levin Theorem β Parent Framework: NP-Completeness (SAT is NP-complete; proof explicitly non-examinable β statement, part (a), and architecture only)
- Proving NP-Completeness by Reduction β Parent Framework: NP-Completeness (the exam hand skill β inheritance theorem, SAT 3-SAT, 3-SAT VERTEX COVER with )
- (Closes the unitβs arc: the [[Polynomial-Time Reductions|]] relation acquires a summit β one efficient algorithm for any NP-complete language would settle vs outright.)
π§ Suggested Reading Order
(read leftβright within each week Β· bold = assessment-critical hand skill)
- Lab 0 β Linux: Unix Shell (Bash) β Text Processing with sed and tr (sed/grep = regex in practice)
- W1 β languages & logic: Formal Languages (Alphabets, Words, Languages) β Theorem and Proof β Proposition and Truth Value β Logical Connectives β Boolean Algebra Laws β Disjunctive Normal Form β Conjunctive Normal Form β Encoding Problems in Propositional Logic (assessable skill) β CNF Encoding Patterns (At Least, At Most, Exactly) (fastest marks) β Predicate β Quantifiers (Existential and Universal) (order sensitivity)
- W2 β proof craft β regex: Proof Techniques (subset-proof blueprint) β Mathematical Induction (hypothesis phrasing) β Proof Critique (Good, Bad and Ugly Proofs) (spot-the-flaw) β Countability and Cantor Diagonalisation β Regular Expressions β Finding Regular Expressions (A1 hand skill)
- W3 β automata & equivalence: Finite Automata (DFA and NFA) (trace + complement) β Kleeneβs Theorem (the cycle) β Converting Regular Expressions to NFA β NFA to DFA (Subset Construction) β FA to Regular Expression (GNFA State Elimination) (all three are A1 hand skills)
- W4 β minimisation β limits: DFA Minimisation (Colouring) (finishes the pipeline) β Lexical Analysis (Patterns, Tokens, Lexemes) (A2) β Closure Properties of Regular Languages β Pumping Lemma for Regular Languages β Proving a Language Non-Regular (the exam kill-shot)
- W5 β context-free tier: Context-Free Grammars (CFG) β Derivations and Parse Trees (leftmost = prefix property) β Writing a CFG (hand skill) β Regular Grammars and the CFL Hierarchy (regular β CFL) β Pushdown Automata (PDA) (NFA + stack; CFG βΊ PDA)
- W6 β parsing β the CFL frontier: Parsing and Shift-Reduce Parsers (A2 trace) β Lex and Yacc (Parser Generators) (A2 toolchain) β Chomsky Normal Form (enables both below) β CYK Algorithm (hand skill) β Pumping Lemma for Context-Free Languages β Proving a Language Non-Context-Free (the exam kill-shot)
- W7 β Turing machines β universality: Turing Machines (three outcomes, deciders) β Building Turing Machines (the marking recipe) β Computable Functions and the Church-Turing Thesis (unary codes) β Encoding Turing Machines (Code Words) (encode/decode) β Universal Turing Machine (programs as data)
- W8 β decidability β reductions: Decidability and Decision Problems (halting is the point) β Deciding Properties of FAs and CFGs (marking to fixpoint) β Mapping Reductions (direction discipline)
- W9 β undecidability β r.e.: Undecidability and the Halting Problem (the diagonalisation proof) β Proving Undecidability by Reduction (the exam hand skill) β Recursively Enumerable Languages (the bridge theorem) β Enumerators and Dovetailing (the schedule)
- W10 β complexity: Polynomial Time and the Class P (fixed , slowdown) β Verifiers, Certificates and the Class NP (4-part membership proof) β Standard NP Problems and Certificates (instance stock) β Polynomial-Time Reductions (the exam hand skill)
- W11 β NP-completeness: NP-Completeness (both conditions) β Reducing to SATISFIABILITY (the CNF hand skill) β Cook-Levin Theorem (non-examinable proof) β Proving NP-Completeness by Reduction (the exam kill-shot)
- SWOTVAC β whole unit: FIT2014 Unit Cheatsheet (one re-read, all 11 weeks)
π― Learning Outcomes (key skills per week)
- Lab 0 (Linux) β
- navigate the filesystem (
pwd/ls/cd/mkdir) - pipe & redirect (
|,>,>>,<) - transform text with
sed 's/pat/rep/g'(backrefs\(...\)/\1, char classes, anchors),tr(map/-d/-s),grepregex - know
sed/grepuse POSIX BRE (escaped\(...\)) β the applied face of Regular Expressions
- navigate the filesystem (
- W1 β
- define /word/language (, , )
- decide EVEN-EVEN / DOUBLEWORD / PALINDROMES membership
- one example proves , never
- truth-table the connectives + prove equivalence via the Boolean laws
- DNF from True rows, CNF from False rows
- encode problems in CNF + cardinality templates ( literals, clauses)
- quantifier discipline ( / , order, negation)
- W2 β
- pick the proof technique from the claimβs shape
- prove by double inclusion
- phrase the inductive hypothesis correctly + test the smallest step
- diagnose faulty inductions and ex falso traps
- listings prove countable; Cantor diagonalisation proves languages uncountable
- read/write regexes (; includes )
- find a regex from a description, checking the smallest strings
- W3 β
- define an FA both ways (state diagram + transition table)
- trace acceptance + state the language
- complement a DFA by swapping Final states (fails for NFAs)
- define an NFA (accept iff SOME path)
- state Kleeneβs cycle Regexp β NFA β FA β Regexp
- run the three conversions by hand (regexβNFA edge rewriting
- NFAβDFA subset construction with -closure
- FAβregex GNFA state elimination)
- W4 β
- minimise a DFA by colouring (Final/non-Final seed; split when row colour-patterns differ; iterate to fixpoint)
- implement an FA from its table
- distinguish pattern (regex) vs token (name) vs lexeme (text); lexer conventions maximal munch then first-listed
- prove closure under complement/union/intersection via De Morgan/concatenation (subsets & supersets are NOT closed)
- state + prove the Pumping Lemma from the circuit/pigeonhole argument, quantifiers exact
- prove non-regularity: choose so leaves one case (), pump up or down, or use the closure shortcut (EQUAL = HALF-AND-HALF)
- W5 β
- define a CFG (terminals/nonterminals/productions, start symbol) + read/write BNF
- give the language generated; a CFL is what some CFG generates
- build a derivation and its parse tree, distinguish leftmost/rightmost (same tree, same length) and use the prefix property
- write a grammar from an inductive definition (Dyck ; PALINDROME; via )
- recognise a regular grammar (semiword rules) and build one from an NFA (); know {regular} β {CFL}
- define a PDA (NFA + stack; transition = read/pop/push; $$$ bottom-marker; accept iff some path reaches Final) and know CFG βΊ PDA (both construction directions), that NFA = stackless PDA, and that deterministic PDAs are weaker
- W6 β
- run a shift-reduce trace (stack + buffer; reduce = rule in reverse; accept iff stack , buffer empty)
- diagnose shift-reduce vs reduce-reduce conflicts and read them as grammar ambiguity; know
- set up Lex (
lex.yy.c,yylex()) + Yacc (y.tab.c,yyparse()) and their conflict defaults (shift; first-listed rule) - convert a grammar to Chomsky Normal Form by the 5 steps and decide by nullability
- fill a CYK table by increasing substring length; state
- state the CFL pumping lemma (, , , ) and where CNF enters its proof
- prove non-context-freeness: pick , split on where sit, kill straddling cases by repeated boundary patterns
- W7 β
- define a TM (tape, head, program; Start , Accept ; crash reject) and trace one
- partition into , , ; a decider has
- convert an FA β TM by the 5 steps βΉ every regular language is decidable
- build a TM for and by the mark-and-sweep recipe
- read the unary code (, tuples -separated) and define by a TM; state the ChurchβTuring thesis and why it is not a theorem
- encode and decode a TM table ( states, 2-letter symbols, 1-letter direction); know is regular but {TM codes}
- say what a UTM does, lay out \langle M\rangle\,\,x$, and justify why UTMs exist
- W8 β
- define a decider () and decidable (, so free); decidable recursive solvable
- convert a decision problem to its YES-input language and back; encode objects as , tuples as
- place the tier: regular β context-free β decidable; prove closure under , , , concatenation by running deciders as subroutines
- run the FA-Empty marking algorithm (seed Start, propagate forward, Accept iff no Final State marked)
- run the CFG-Empty marking algorithm (seed terminals, propagate upward, Accept iff unmarked)
- decide RegExpEquiv by emptiness of
- define a mapping reduction ( computable, ) and write the certifying iff chain
- apply the transfer theorem: decidable decidable; undecidable undecidable; is transitive, not symmetric
- build the standard reductions (EQUAL β HALF-AND-HALF by sorting, FA-Empty β No-Digraph-Path by the sink vertex )
- know why reducing from a decidable to any proves nothing
- W9 β
- argue from countability that undecidable languages exist (existence only β names nobody)
- state the Halting Problem and its diagonal one-argument form
- prove undecidability: build flipping the diagonal, say which assumption dies
- run the input-blind gadget = βignore , run on β βΉ HALT-FOR-ZERO / ALWAYS HALTS / SOMETIMES HALTS
- get NEVER HALTS by the Accept/Reject swap; say why that is illegal on recognisers
- classify: bounded-step halting and state-counting decidable; acceptance and -input halting not
- define r.e. (, unrestricted) + synonyms (Turing recognisable, type 0)
- prove decidable and both r.e. via the one-step interleaved decider
- prove is r.e. but undecidable, is not r.e.; decidable r.e. co-r.e.
- prove r.e. enumerated, with the -then- dovetailing schedule
- W10 β
- compute and say why it needs a decider
- define polynomial time (, fixed) and ; place regular β CFL β β decidable
- run the polynomial-slowdown argument for model-independence of
- define verifier and certificate; bound time in , never
- prove membership of in 4 parts: certificate Β· verifier Β· iff claim Β· time claim (3-colourability, )
- prove (ignore the certificate) and (search certificates)
- state the NDTM characterisation of and why DFA NFA does not transfer
- recall instance certificate for VERTEX COVER, INDEPENDENT SET, CLIQUE, SAT/2-SAT/3-SAT, colouring, PARTITION, SUBSET SUM
- build a reduction: function iff chain time bound, via the one-symbol-per-step output-length lemma
- apply the transfer theorem (; ) and re-time old reductions
- W11 β
- define NP-complete by both conditions and name the failure mode of each (NP-hard when (a) fails)
- prove the master theorem: an NP-complete has a poly decider
- place SAT/3-SAT/VC/IS/CLIQUE, GRAPH ISOMORPHISM, and the problems on the two-lobe diagram
- reduce a language to SAT: certificate variables rule clauses clause count
- state the Cook-Levin Theorem and prove part (a) only (the rest is non-examinable)
- apply the inheritance theorem ( NP-complete, , ) β just one reduction
- run (fresh-variable padding and chaining) and ()
- choose the response to NP-completeness: exponential Β· randomised Β· special-case Β· approximation