complexity Flashcards
(114 cards)
How do you convert a regex to an NFA?
- Create an NFA for each regex component (concatenation, union, and Kleene star).
- Combine components following regex rules.
- Use epsilon transitions to join smaller NFAs into a complete structure.
studres ver:
Let N = (Q, Σ, δ, q0, F) be an NFA. We replace states and letters with regular expressions as
follows:
1. Add a new start state s, connected to q0 by an ε-arrow
2. Add a new accept state t, with an ε-arrow from each accept state to t. Set F = {t}, so t is the only accept state
3. “Rip out” one state at a time until only s and t remain, replacing arrows to and from that state with appropriate regular expressions
The process will terminate with just states s and t, with an arrow between them labelled with a regular expression R. This regular expression describes L(N).
How do you construct a PDA that recognises a language?
- Define states, input alphabet, stack alphabet, and transition rules.
- Use transitions to push or pop symbols based on input.
- Ensure final states or empty stack indicate acceptance.
How do you show a language is context free?
- Construct a CFG that produces all valid strings in the language.
- Ensure grammar rules follow the form A → α where A is a variable and α is a string of terminals and variables.
How do you show a Turing Machine is not valid?
- Show inconsistency in transition rules.
- Demonstrate non-halting behaviour for all inputs.
- Prove the machine does not produce the expected output.
What is the language A-DFA?
A-DFA is the set of descriptions of deterministic finite automata (DFAs) that accept a given input string.
What is the language A-REX?
A-REX is the set of descriptions of regular expressions that match a given input string.
What is a the language E-DFA?
E-DFA is the set of descriptions of DFAs whose language is empty.
What is the language EQ-DFA?
EQ-DFA is the set of pairs of DFAs whose languages are identical.
How to consider if a function is one-to-one?
Definition: A function is one-to-one (injective) if distinct inputs yield distinct outputs.
Method: Show f(a) ≠ f(b) whenever a ≠ b.
How to consider if a function is onto?
Definition: A function is onto (surjective) if every element in the output set has a preimage.
Method: Show that for every y in the range, there exists x in the domain such that f(x) = y.
How to consider if a function is a bijection?
Definition: A function is bijective if it is both one-to-one and onto.
Method: Verify injectivity and surjectivity
What is the language A-CFG?
Definition: A-CFG is the set of context-free grammars that generate a given input string.
How do you show a language is decidable?
Definition: A language is decidable if there exists a Turing Machine that always halts with an answer.
Method: Construct a TM that determines membership in a finite number of steps.
How do you show that A is Turing-recognisable if and only if A reduces to ATM?
Definition: If A can be transformed into ATM using a computable function, then A is recognizable.
Method: Show reduction from A to ATM using a mapping function.
If ( A ) is Turing-recognisable, then ( A ) reduces to ( ATM ):
- Definition: Since ( A ) is recognisable, there exists a Turing Machine ( M_A ) that recognises ( A ).
- Reduction Construction: Define a function ( f(w) ) that encodes ( w ) and ( M_A ) into a new input for ( ATM ):- Let ( f(w) = (M_A, w) ) (i.e., an encoding of ( M_A ) running on ( w )).
- Connection to ( ATM ):- If ( M_A ) accepts ( w ), then ( (M_A, w) ) belongs to ( ATM ).
- If ( M_A ) does not accept ( w ), then ( (M_A, w) ) does not belong to ( ATM ).
- Conclusion: The transformation ( f(w) ) is computable, meaning ( A ) is reducible to ( ATM ).
What is big-O?
Definition: Big-O notation describes an upper bound on the growth rate of a function.
Example: O(n²) means the function grows at most quadratically.
How do you show a formula is satisfiable?
Definition: A formula is satisfiable if there exists an assignment of values that makes it true.
Method: Find a truth assignment that results in a TRUE evaluation.
How do you show that P is closed under union?
Theorem: If A and B are in P, then A∪B is in P.
Proof:
Let MA and MB be polynomial-time deciders for A and B respectively.
Let M’ be a machine which runs as follows on the input w:
1. Simulates MA on w. If MA accepts, M’ accepts.
2. Simulates MB on w. If MB accepts M’ accepts. If MB rejects, M’ rejects.
This means M’ accepts w iff w in A OR B, therefore A∪B is recognised by P. Since MA and MB are polynomial, M’ is also polynomial and hence M’ is a polynomial decider for A∪B.
How do you show that P is closed under concatenation?
Theorem: If A and B are regular languages in P, then AB is in P.
Proof:
Let MA and MB be polynomial-time deciders of A and B respectively. Let M’ be a machine that takes input w (of length n) and runs as follows:
1. repeat the following for all n options of splitting w into two words uv.
2. simulate MA on u. If MA accepts, M’ accepts.
3. simulate MB on v. If MA accepts, M’ accepts.
4. If the above loop ends, then reject.
M’ accepts iff u in A and v in B, so M’ recognises AB. Since MA and MB are polynomial, and since only repeated n times, M’ is also polynomial. Hence, M’ is a polynomial decider for AB.
How do you show that P is closed under complement?
Theorem: If A is a language in P, then A’ (A complement) is in P.
Proof:
Let M be a polynomial-time decider for A. Let M’ be a machine that simulate m but returns the opposite result.
M’ accepts input w iff w is not in A, so M’ recognises A’. Since M is polynomial, so is M’. Hence M’ is a polynomial decider for A’.
What is UHAMPATH? And UHAMPATH-EX?
Definition: UHAMPATH is the set of directed graphs with an undirected Hamiltonian path.
UHAMPATH-EX: The decision problem asking whether a Hamiltonian path exists.
How do you show UHAMPATH-EX is NP-complete?
Definition: UHAMPATH-EX is the problem of deciding whether an undirected Hamiltonian path exists in a given graph.
- Show UHAMPATH-EX is in NP: Verify a given path in polynomial time.
- Reduce from an NP-complete problem (such as HAMPATH): Construct a polynomial-time transformation to UHAMPATH-EX.
- Conclusion: Since both conditions hold, UHAMPATH-EX is NP-complete.
What is the TIME class?
Definition: TIME(f(n)) represents the set of problems solvable by a deterministic Turing Machine in ( O(f(n)) ) time.
How would you Prove that TIME(2^n) = TIME(2^n +1)?
Key Idea:
Since a Turing Machine running in ( O(2^n) ), time can trivially execute an extra step in ( O(2^n + 1) ) the classes remain equivalent.
What is PSPACE?
PSPACE is the class of problems solvable by a deterministic Turing Machine using polynomial space.
Hence, NPSPACE is the class of languages that are decidable in polynomial space on a nondeterministic Turing machine.