FIT2014 Unit Cheatsheet
Context: FIT2014_MOC Β· the WHOLE unit in one re-read β languages β logic β automata β grammars β parsing β Turing machines β decidability β complexity β NP-completeness. Every claim is hand-derivable; links for depth only.
Quick Revision
- π― Objective: match the claimβs SHAPE to a formula or proof blueprint β derive in
\begin{aligned}, seal with Q.E.D.- β οΈ Key Constraint: hypothesis discipline β every rule here has a precondition; marks die when a rule fires without it (infinite vs finite, regular vs context-free, decidable vs recognisable, vs ).
1οΈβ£ Languages and Words
- Alphabet & word β finite non-empty; a word is a finite sequence over ; is the empty word Β· precondition β the empty language has no words, the language has one.
- Closure β all finite words including ; ; is countably infinite for any finite .
- Language β any Β· precondition membership must be decidable by definition, not by intuition β state the defining predicate.
- Named test languages β EVEN-EVEN Β· DOUBLEWORD Β· PALINDROME Β· EQUAL () Β· HALF-AND-HALF (-style split).
2οΈβ£ Propositional Logic β CNF Encoding
- Connectives β ; Β· precondition for CNF conversion β implications must be eliminated before De Morgan.
- De Morgan β , ; extends to terms by induction, not by assertion.
- DNF β OR of ANDs; read off the True rows of the truth table, one conjunct per row.
- CNF β AND of ORs; read off the False rows, negating each literal β the sign flip is the whole trick.
- [[CNF Encoding Patterns (At Least, At Most, Exactly)|At least from ]] β clause size , write all clauses, literals unnegated.
- At most from β same formula on negated literals with , giving and clauses.
- Exactly β (at least ) (at most ) Β· precondition both halves must be written; one alone is a strict inequality.
- Encoding a problem β β variable per atomic choice β‘ clauses per validity rule β’ conjoin Β· precondition the rules, not just the certificate, must be encoded.
3οΈβ£ Predicates and Quantifiers
- Predicate β a proposition-valued function ; a free variable makes it not yet a proposition, a bound one does.
- Pairing rule β pairs with , pairs with Β· precondition β over-claims and is vacuously true.
- Negation β ; .
- Order sensitivity β ; the second is strictly stronger Β· precondition swapping is only safe for like quantifiers.
- Distribution β distributes over , over ; the mixed pairs do not.
4οΈβ£ Proof Craft
- Claim shape β technique β : exhibit one witness Β· : never by example Β· : direct or contrapositive Β· βno such thingβ: contradiction.
- Set equality β by double inclusion and ; each inclusion starts βlet β.
- Contrapositive β ; contradiction assumes and derives absurdity (canonical: ).
- Induction β base case at the smallest relevant , then Β· precondition the hypothesis must be the full statement for , and the smallest step must be tested (the classic failure is ).
- Faulty-proof tells β missing/ wrong base case Β· hypothesis assumed for Β· ex falso (a false premise proves anything) Β· example offered for a claim.
- Countability β an explicit listing proves countable; diagonalisation proves languages over uncountable βΉ some language has no description at all.
5οΈβ£ Regular Expressions and Finite Automata
- Regex β built from , letters, , concatenation, Β· precondition includes , and β precedence is then concat then .
- Finding one β describe the shape of an accepted word, then verify on the shortest strings including .
- DFA β with total and single-valued; accept iff the unique run ends in .
- NFA β may be multi-valued or missing, -moves allowed; accept iff some path ends in .
- Complement β swap Final/non-Final Β· precondition DFA only β the same swap on an NFA is wrong, because βsome path acceptsβ does not negate pointwise.
- Kleeneβs Theorem β regex NFA DFA; proved by the cycle regex NFA DFA regex.
- [[Converting Regular Expressions to NFA|regex NFA]] β Thompson-style edge rewriting, one construction per operator.
- [[NFA to DFA (Subset Construction)|NFA DFA]] β states are sets of NFA states; start -closure of ; Final iff the set meets Β· cost up to states β this is why the construction is not polynomial (see Β§1οΈβ£2οΈβ£).
- [[FA to Regular Expression (GNFA State Elimination)|FA regex]] β GNFA state elimination; before deleting a state, relabel every ordered pair as Β· precondition missing a pair loses strings, and must be kept in the union.
6οΈβ£ Limits of Regularity
- Minimisation β seed two colours (Final / non-Final), split any class whose rows disagree on successor colours, iterate to fixpoint Β· precondition the DFA must be complete first.
- Lexing vocabulary β pattern = the regex Β· token = the name Β· lexeme = the matched text; conflicts resolved by maximal munch, then first-listed rule.
- Closure β regular languages are closed under , , , concatenation, Β· note is obtained via De Morgan; subsets and supersets are NOT closed.
- Pumping Lemma β infinite regular with an -state FA βΉ , : , , , Β· precondition infinite and regular; it is necessary, never sufficient.
- Non-regularity recipe β assume regular with pumping length β choose so that forces into one block (canonically ) β pump up or down ( is legal) β contradiction.
- Closure shortcut β if is known non-regular for a regular , then is non-regular (e.g. EQUAL ).
7οΈβ£ Context-Free Grammars and PDAs
- CFG β terminals, nonterminals, productions with a single nonterminal on the left, start symbol ; a CFL is any language some CFG generates.
- Derivation β leftmost and rightmost give the same tree and the same length; the prefix property is what makes leftmost usable for parsing.
- Grammar-writing stock β : Β· Dyck: Β· PALINDROME: .
- Regular grammar β every rule has a semiword RHS; from an NFA, becomes βΉ regularCFL.
- PDA β NFA + stack; transition = read , pop , push ; $$$ marks the stack bottom; accept iff some path reaches a Final state.
- Equivalence β CFG PDA (both directions constructive); an NFA is a stackless PDA Β· precondition deterministic PDAs are strictly weaker β .
8οΈβ£ Parsing, Chomsky Normal Form, CYK
- Shift-reduce β stack + buffer; shift moves one 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 grammar ambiguity.
- Toolchain β Lex
lex.yy.c/yylex(); Yaccy.tab.c/yyparse(); defaults resolve shift-reduce by shifting and reduce-reduce by the first-listed rule. - Chomsky NF β every rule (live) or (dead) Β· precondition CNF generates the non-empty words only; goes to the nullability algorithm. β not Conjunctive Normal Form.
- 5-step conversion β β eliminate -productions (to fixpoint) β‘ eliminate unit productions β’ isolate terminals into dead rules β£ break long RHS into binary chains β€ tidy unreachable/dead nonterminals.
- CYK β fill by increasing substring length; length- cell takes the union over the binary splits; Accept iff appears in the whole-string cell Β· precondition grammar in Chomsky NF Β· cost .
- CFL Pumping Lemma β CFG in CNF with nonterminals βΉ with , : , , , Β· note CNF enters via the binary-tree height argument.
- Non-CF recipe β take or β case-split on which blocks occupy β stops them spanning all three blocks βΉ pumping breaks the counts.
9οΈβ£ Turing Machines
- TM β two-way infinite tape, head, finite program; Start , Accept ; a crash (no applicable transition) rejects.
- Three outcomes β partitions into , , Β· definition is a decider iff .
- FA TM β 5-step conversion βΉ every regular language is decidable.
- Building recipe β mark-and-sweep: mark leftmost unmarked , run right to the matching , mark, return, repeat; accept when a full sweep finds nothing left to match.
- Unary code β , tuples separated by ; is computable iff some TM leaves on the tape Β· precondition the ChurchβTuring thesis is a thesis, not a theorem β it cannot be cited as a proof step.
- Code words β one row per transition, 5 fields: state , 2-letter symbols, 1-letter direction; is regular but strictly larger than the set of genuine TM codes.
- UTM β takes \langle M\rangle\,\texttt{\},xMx$ β programs as data, the stored-program idea.
π Decidability and Mapping Reductions
- Decidable β for some decider ; then comes free. Synonyms: recursive, solvable.
- Problem language β a decision problem becomes the language of its YES-inputs; objects encode as , tuples as .
- Closure β decidable languages are closed under , concatenation β proved by running deciders as subroutines Β· precondition subroutine calls must be shown to terminate, which is exactly what a decider guarantees.
- FA-Empty β mark the Start state, 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 Β· cost requires determinisation, so decidable but not polynomial.
- Mapping reduction β computable total with , written Β· precondition the certifying iff chain must be written both ways.
- Transfer β decidable decidable; undecidable undecidable Β· precondition is reflexive and transitive, not symmetric β direction is everything.
- Degenerate case β reducing from a decidable proves nothing about , and needs to exist at all.
1οΈβ£1οΈβ£ Undecidability and Recursive Enumerability
- Existence argument β TMs are countable, languages are uncountable βΉ undecidable languages exist Β· limitation names none of them.
- HALT β halts on is undecidable; proof builds that flips the diagonal, so the assumed decider cannot exist.
- Input-blind gadget β from build = βignore the input, run on β βΉ HALT-FOR-ZERO, ALWAYS HALTS, SOMETIMES HALTS all undecidable.
- NEVER HALTS β obtained by the Accept/Reject swap Β· precondition the swap is illegal on recognisers (a loop is neither), legal only on deciders.
- Decidable side β bounded-step halting and state-counting are decidable; acceptance and -input halting are not.
- r.e. β with unrestricted; synonyms Turing-recognisable, type 0.
- Bridge theorem β decidable and are both r.e. β proved by interleaving both machines one step at a time.
- Separation β is r.e. but undecidable; is not r.e.; decidable r.e. co-r.e.
- Enumeration β r.e. is enumerated by some machine, using the -then- dovetailing schedule Β· precondition a naive βrun input 1 to completion firstβ schedule fails on a looping input.
1οΈβ£2οΈβ£ P, NP and Polynomial-Time Reductions
- Running time β Β· precondition must be a decider, else the max is undefined.
- β languages with an decider, fixed β does not qualify. Placement: regular CFL decidable.
- Model independence β reasonable machine models simulate each other with polynomial slowdown, and a polynomial of a polynomial is a polynomial.
- Verifier & certificate β iff some polynomial-time has accepts Β· precondition the time bound is in , never .
- 4-part membership proof β β state the certificate β‘ state the verifier β’ prove the iff β£ bound the time. All four are marked.
- Inclusions β (ignore the certificate) and (search certificates).
- NDTM β = languages decided by a nondeterministic TM in polynomial time Β· precondition the DFA NFA equivalence does not transfer β determinising costs exponential time here, not just states.
- Instance stock β VERTEX COVER () Β· INDEPENDENT SET, CLIQUE () Β· SAT / 2-SAT / 3-SAT Β· -COLOURABILITY Β· HAMILTONIAN CIRCUIT Β· PARTITION Β· SUBSET SUM Β· GRAPH ISOMORPHISM.
- [[Polynomial-Time Reductions|]] β with computable in ; three marked parts: function Β· iff chain Β· time bound.
- Output-length lemma β a TM emits symbol per step βΉ in time forces Β· precondition this is the step that makes composition work; omitting it is the standard deduction.
- Transfer β ; Β· precondition every old construction must be re-timed β is not .
- Reduction stock β : Β· : Β· : target .
1οΈβ£3οΈβ£ NP-Completeness
- Definition β is NP-complete iff (a) and (b) Β· precondition (b) alone is only NP-hard.
- Master theorem β an NP-complete has a polynomial-time decider ; () spends condition (a), () spends (b) plus the transfer theorem.
- Equivalence class β for NP-complete : , and is NP-complete .
- Cook-Levin Theorem β SATISFIABILITY (satisfiable CNF expressions) is NP-complete Β· note the proof is non-examinable; part (a) β certificate = truth assignment, verify clause-by-clause β is not.
- Encoding recipe β β variables for the certificate β‘ auxiliary variables β’ rules CNF via the at-least / at-most templates of Β§2οΈβ£ β£ state as an algorithm and count the clauses.
- PARTITION INTO TRIANGLES SAT β per triangle; per vertex one at-least-one clause and per triangle pair at it Β· cost variables, clauses.
- Inheritance theorem β NP-complete NP-complete Β· precondition the reduction runs from the known-hard language; proves nothing.
- β pad clauses of size with fresh in all sign patterns; chain clauses of size with fresh links .
- β variable-edge per variable, triangle per clause, connector edge from each clause position to its literal; Β· precondition must be the exact minimum, else the correspondence breaks.
- Chain β βΉ all five NP-complete.
- Living with it β drop exactly one of efficient Β· deterministic Β· all-cases Β· exact βΉ exponential exact / randomised / special-case / approximation algorithm.
- co-NP β complements of languages; , and whether that inclusion is equality is open.
πͺ The ladder, in one line
- Named separating inhabitants β (not regular) Β· (not context-free, still decidable) Β· (r.e., not decidable) Β· (not r.e.).
- The unproved links β every in the first chain is a theorem with a witness above; the second chainβs signs are not known to be strict β is the open question, and straddles the /decidable frontier rather than sitting in a tier of its own.