category: dfa

prompt: For DFA M, report 1 if the string is accepted and 0 if it is rejected, for the strings 'ab', 'aab', 'baa', 'bbbb' and '' (the empty string), in that order. Return one row of five values.

api_description:
The tasks refer to these fixed machines. The alphabet is {a, b} unless stated.

DFA M (states q0, q1, q2; start q0; accepting {q2}):
  q0 -a-> q1    q0 -b-> q0
  q1 -a-> q2    q1 -b-> q0
  q2 -a-> q2    q2 -b-> q2

NFA N (states p0, p1, p2; start p0; accepting {p2}; no epsilon transitions):
  p0 -a-> {p0, p1}    p0 -b-> {p0}
  p1 -a-> {}          p1 -b-> {p2}
  p2 -a-> {p2}        p2 -b-> {p2}

CFG G in Chomsky normal form, start symbol S:
  S -> AB | CC
  A -> BC | a
  B -> AA | b
  C -> AB | b

TURING MACHINE T over {0, 1} with blank '_', start state t0, halting state HALT:
  t0,0 -> t0, write 1, move R
  t0,1 -> t0, write 0, move R
  t0,_ -> HALT, write _, stay
  The head starts on the leftmost input symbol. A "step" is one transition taken.

STATE COUNTS — say which you mean, because there are three different right answers: the number
of subsets the subset construction could produce (2 to the power of the NFA's states), the
number REACHABLE from the start subset, and the number left after minimising. Every task below
names the one it wants.

Available imports: itertools, re. Nothing else is needed.

Strings are ordered SHORTLEX throughout: shorter strings first, and strings of the same length
in alphabetical order — so "", "a", "b", "aa", "ab", "ba", "bb", "aaa", ...

Put the requested values in `result` as a list of rows of plain values. Every value is an
integer or a string; there are no floats in this environment.


category: dfa

prompt: How many strings of length exactly n does DFA M accept, for n = 3, n = 5 and n = 8? Return one row of the three integers.

api_description:
The tasks refer to these fixed machines. The alphabet is {a, b} unless stated.

DFA M (states q0, q1, q2; start q0; accepting {q2}):
  q0 -a-> q1    q0 -b-> q0
  q1 -a-> q2    q1 -b-> q0
  q2 -a-> q2    q2 -b-> q2

NFA N (states p0, p1, p2; start p0; accepting {p2}; no epsilon transitions):
  p0 -a-> {p0, p1}    p0 -b-> {p0}
  p1 -a-> {}          p1 -b-> {p2}
  p2 -a-> {p2}        p2 -b-> {p2}

CFG G in Chomsky normal form, start symbol S:
  S -> AB | CC
  A -> BC | a
  B -> AA | b
  C -> AB | b

TURING MACHINE T over {0, 1} with blank '_', start state t0, halting state HALT:
  t0,0 -> t0, write 1, move R
  t0,1 -> t0, write 0, move R
  t0,_ -> HALT, write _, stay
  The head starts on the leftmost input symbol. A "step" is one transition taken.

STATE COUNTS — say which you mean, because there are three different right answers: the number
of subsets the subset construction could produce (2 to the power of the NFA's states), the
number REACHABLE from the start subset, and the number left after minimising. Every task below
names the one it wants.

Available imports: itertools, re. Nothing else is needed.

Strings are ordered SHORTLEX throughout: shorter strings first, and strings of the same length
in alphabetical order — so "", "a", "b", "aa", "ab", "ba", "bb", "aaa", ...

Put the requested values in `result` as a list of rows of plain values. Every value is an
integer or a string; there are no floats in this environment.


category: dfa

prompt: In SHORTLEX order (shorter first, ties alphabetically), give the first three strings that DFA M accepts. Return one row of the three strings.

api_description:
The tasks refer to these fixed machines. The alphabet is {a, b} unless stated.

DFA M (states q0, q1, q2; start q0; accepting {q2}):
  q0 -a-> q1    q0 -b-> q0
  q1 -a-> q2    q1 -b-> q0
  q2 -a-> q2    q2 -b-> q2

NFA N (states p0, p1, p2; start p0; accepting {p2}; no epsilon transitions):
  p0 -a-> {p0, p1}    p0 -b-> {p0}
  p1 -a-> {}          p1 -b-> {p2}
  p2 -a-> {p2}        p2 -b-> {p2}

CFG G in Chomsky normal form, start symbol S:
  S -> AB | CC
  A -> BC | a
  B -> AA | b
  C -> AB | b

TURING MACHINE T over {0, 1} with blank '_', start state t0, halting state HALT:
  t0,0 -> t0, write 1, move R
  t0,1 -> t0, write 0, move R
  t0,_ -> HALT, write _, stay
  The head starts on the leftmost input symbol. A "step" is one transition taken.

STATE COUNTS — say which you mean, because there are three different right answers: the number
of subsets the subset construction could produce (2 to the power of the NFA's states), the
number REACHABLE from the start subset, and the number left after minimising. Every task below
names the one it wants.

Available imports: itertools, re. Nothing else is needed.

Strings are ordered SHORTLEX throughout: shorter strings first, and strings of the same length
in alphabetical order — so "", "a", "b", "aa", "ab", "ba", "bb", "aaa", ...

Put the requested values in `result` as a list of rows of plain values. Every value is an
integer or a string; there are no floats in this environment.


category: dfa

prompt: Give the state DFA M is in after reading each of 'a', 'ab', 'aba' and 'abaa', starting from q0. Return one row of the four state names.

api_description:
The tasks refer to these fixed machines. The alphabet is {a, b} unless stated.

DFA M (states q0, q1, q2; start q0; accepting {q2}):
  q0 -a-> q1    q0 -b-> q0
  q1 -a-> q2    q1 -b-> q0
  q2 -a-> q2    q2 -b-> q2

NFA N (states p0, p1, p2; start p0; accepting {p2}; no epsilon transitions):
  p0 -a-> {p0, p1}    p0 -b-> {p0}
  p1 -a-> {}          p1 -b-> {p2}
  p2 -a-> {p2}        p2 -b-> {p2}

CFG G in Chomsky normal form, start symbol S:
  S -> AB | CC
  A -> BC | a
  B -> AA | b
  C -> AB | b

TURING MACHINE T over {0, 1} with blank '_', start state t0, halting state HALT:
  t0,0 -> t0, write 1, move R
  t0,1 -> t0, write 0, move R
  t0,_ -> HALT, write _, stay
  The head starts on the leftmost input symbol. A "step" is one transition taken.

STATE COUNTS — say which you mean, because there are three different right answers: the number
of subsets the subset construction could produce (2 to the power of the NFA's states), the
number REACHABLE from the start subset, and the number left after minimising. Every task below
names the one it wants.

Available imports: itertools, re. Nothing else is needed.

Strings are ordered SHORTLEX throughout: shorter strings first, and strings of the same length
in alphabetical order — so "", "a", "b", "aa", "ab", "ba", "bb", "aaa", ...

Put the requested values in `result` as a list of rows of plain values. Every value is an
integer or a string; there are no floats in this environment.


category: dfa

prompt: Minimise DFA M by partition refinement. How many states does the minimal DFA have, and how many of M's three states are unreachable from q0? Return one row [minimal_states, unreachable].

api_description:
The tasks refer to these fixed machines. The alphabet is {a, b} unless stated.

DFA M (states q0, q1, q2; start q0; accepting {q2}):
  q0 -a-> q1    q0 -b-> q0
  q1 -a-> q2    q1 -b-> q0
  q2 -a-> q2    q2 -b-> q2

NFA N (states p0, p1, p2; start p0; accepting {p2}; no epsilon transitions):
  p0 -a-> {p0, p1}    p0 -b-> {p0}
  p1 -a-> {}          p1 -b-> {p2}
  p2 -a-> {p2}        p2 -b-> {p2}

CFG G in Chomsky normal form, start symbol S:
  S -> AB | CC
  A -> BC | a
  B -> AA | b
  C -> AB | b

TURING MACHINE T over {0, 1} with blank '_', start state t0, halting state HALT:
  t0,0 -> t0, write 1, move R
  t0,1 -> t0, write 0, move R
  t0,_ -> HALT, write _, stay
  The head starts on the leftmost input symbol. A "step" is one transition taken.

STATE COUNTS — say which you mean, because there are three different right answers: the number
of subsets the subset construction could produce (2 to the power of the NFA's states), the
number REACHABLE from the start subset, and the number left after minimising. Every task below
names the one it wants.

Available imports: itertools, re. Nothing else is needed.

Strings are ordered SHORTLEX throughout: shorter strings first, and strings of the same length
in alphabetical order — so "", "a", "b", "aa", "ab", "ba", "bb", "aaa", ...

Put the requested values in `result` as a list of rows of plain values. Every value is an
integer or a string; there are no floats in this environment.


category: dfa

prompt: Consider the COMPLEMENT of DFA M — the same machine with accepting and non-accepting states swapped. How many strings of length exactly 3, 5 and 8 does it accept? Return one row of the three integers.

api_description:
The tasks refer to these fixed machines. The alphabet is {a, b} unless stated.

DFA M (states q0, q1, q2; start q0; accepting {q2}):
  q0 -a-> q1    q0 -b-> q0
  q1 -a-> q2    q1 -b-> q0
  q2 -a-> q2    q2 -b-> q2

NFA N (states p0, p1, p2; start p0; accepting {p2}; no epsilon transitions):
  p0 -a-> {p0, p1}    p0 -b-> {p0}
  p1 -a-> {}          p1 -b-> {p2}
  p2 -a-> {p2}        p2 -b-> {p2}

CFG G in Chomsky normal form, start symbol S:
  S -> AB | CC
  A -> BC | a
  B -> AA | b
  C -> AB | b

TURING MACHINE T over {0, 1} with blank '_', start state t0, halting state HALT:
  t0,0 -> t0, write 1, move R
  t0,1 -> t0, write 0, move R
  t0,_ -> HALT, write _, stay
  The head starts on the leftmost input symbol. A "step" is one transition taken.

STATE COUNTS — say which you mean, because there are three different right answers: the number
of subsets the subset construction could produce (2 to the power of the NFA's states), the
number REACHABLE from the start subset, and the number left after minimising. Every task below
names the one it wants.

Available imports: itertools, re. Nothing else is needed.

Strings are ordered SHORTLEX throughout: shorter strings first, and strings of the same length
in alphabetical order — so "", "a", "b", "aa", "ab", "ba", "bb", "aaa", ...

Put the requested values in `result` as a list of rows of plain values. Every value is an
integer or a string; there are no floats in this environment.


category: nfa

prompt: For NFA N, report 1 if accepted and 0 if rejected, for 'ab', 'ba', 'aab', 'bbb' and 'aba', in that order. Return one row of five values.

api_description:
The tasks refer to these fixed machines. The alphabet is {a, b} unless stated.

DFA M (states q0, q1, q2; start q0; accepting {q2}):
  q0 -a-> q1    q0 -b-> q0
  q1 -a-> q2    q1 -b-> q0
  q2 -a-> q2    q2 -b-> q2

NFA N (states p0, p1, p2; start p0; accepting {p2}; no epsilon transitions):
  p0 -a-> {p0, p1}    p0 -b-> {p0}
  p1 -a-> {}          p1 -b-> {p2}
  p2 -a-> {p2}        p2 -b-> {p2}

CFG G in Chomsky normal form, start symbol S:
  S -> AB | CC
  A -> BC | a
  B -> AA | b
  C -> AB | b

TURING MACHINE T over {0, 1} with blank '_', start state t0, halting state HALT:
  t0,0 -> t0, write 1, move R
  t0,1 -> t0, write 0, move R
  t0,_ -> HALT, write _, stay
  The head starts on the leftmost input symbol. A "step" is one transition taken.

STATE COUNTS — say which you mean, because there are three different right answers: the number
of subsets the subset construction could produce (2 to the power of the NFA's states), the
number REACHABLE from the start subset, and the number left after minimising. Every task below
names the one it wants.

Available imports: itertools, re. Nothing else is needed.

Strings are ordered SHORTLEX throughout: shorter strings first, and strings of the same length
in alphabetical order — so "", "a", "b", "aa", "ab", "ba", "bb", "aaa", ...

Put the requested values in `result` as a list of rows of plain values. Every value is an
integer or a string; there are no floats in this environment.


category: nfa

prompt: Run the subset construction on NFA N. Give (a) the number of subsets a naive construction would consider, which is 2 to the power of N's state count, (b) the number REACHABLE from the start subset, and (c) the number of states after minimising the reachable machine. Return one row of the three integers.

api_description:
The tasks refer to these fixed machines. The alphabet is {a, b} unless stated.

DFA M (states q0, q1, q2; start q0; accepting {q2}):
  q0 -a-> q1    q0 -b-> q0
  q1 -a-> q2    q1 -b-> q0
  q2 -a-> q2    q2 -b-> q2

NFA N (states p0, p1, p2; start p0; accepting {p2}; no epsilon transitions):
  p0 -a-> {p0, p1}    p0 -b-> {p0}
  p1 -a-> {}          p1 -b-> {p2}
  p2 -a-> {p2}        p2 -b-> {p2}

CFG G in Chomsky normal form, start symbol S:
  S -> AB | CC
  A -> BC | a
  B -> AA | b
  C -> AB | b

TURING MACHINE T over {0, 1} with blank '_', start state t0, halting state HALT:
  t0,0 -> t0, write 1, move R
  t0,1 -> t0, write 0, move R
  t0,_ -> HALT, write _, stay
  The head starts on the leftmost input symbol. A "step" is one transition taken.

STATE COUNTS — say which you mean, because there are three different right answers: the number
of subsets the subset construction could produce (2 to the power of the NFA's states), the
number REACHABLE from the start subset, and the number left after minimising. Every task below
names the one it wants.

Available imports: itertools, re. Nothing else is needed.

Strings are ordered SHORTLEX throughout: shorter strings first, and strings of the same length
in alphabetical order — so "", "a", "b", "aa", "ab", "ba", "bb", "aaa", ...

Put the requested values in `result` as a list of rows of plain values. Every value is an
integer or a string; there are no floats in this environment.


category: nfa

prompt: Give the set of NFA N states reachable after reading 'a', then after 'aa', then after 'ab', each as the state names in alphabetical order joined by a comma with no spaces (an empty set is the string 'none'). Return one row of three strings.

api_description:
The tasks refer to these fixed machines. The alphabet is {a, b} unless stated.

DFA M (states q0, q1, q2; start q0; accepting {q2}):
  q0 -a-> q1    q0 -b-> q0
  q1 -a-> q2    q1 -b-> q0
  q2 -a-> q2    q2 -b-> q2

NFA N (states p0, p1, p2; start p0; accepting {p2}; no epsilon transitions):
  p0 -a-> {p0, p1}    p0 -b-> {p0}
  p1 -a-> {}          p1 -b-> {p2}
  p2 -a-> {p2}        p2 -b-> {p2}

CFG G in Chomsky normal form, start symbol S:
  S -> AB | CC
  A -> BC | a
  B -> AA | b
  C -> AB | b

TURING MACHINE T over {0, 1} with blank '_', start state t0, halting state HALT:
  t0,0 -> t0, write 1, move R
  t0,1 -> t0, write 0, move R
  t0,_ -> HALT, write _, stay
  The head starts on the leftmost input symbol. A "step" is one transition taken.

STATE COUNTS — say which you mean, because there are three different right answers: the number
of subsets the subset construction could produce (2 to the power of the NFA's states), the
number REACHABLE from the start subset, and the number left after minimising. Every task below
names the one it wants.

Available imports: itertools, re. Nothing else is needed.

Strings are ordered SHORTLEX throughout: shorter strings first, and strings of the same length
in alphabetical order — so "", "a", "b", "aa", "ab", "ba", "bb", "aaa", ...

Put the requested values in `result` as a list of rows of plain values. Every value is an
integer or a string; there are no floats in this environment.


category: nfa

prompt: How many strings of length exactly n does NFA N accept, for n = 2, n = 4 and n = 6? Return one row of the three integers.

api_description:
The tasks refer to these fixed machines. The alphabet is {a, b} unless stated.

DFA M (states q0, q1, q2; start q0; accepting {q2}):
  q0 -a-> q1    q0 -b-> q0
  q1 -a-> q2    q1 -b-> q0
  q2 -a-> q2    q2 -b-> q2

NFA N (states p0, p1, p2; start p0; accepting {p2}; no epsilon transitions):
  p0 -a-> {p0, p1}    p0 -b-> {p0}
  p1 -a-> {}          p1 -b-> {p2}
  p2 -a-> {p2}        p2 -b-> {p2}

CFG G in Chomsky normal form, start symbol S:
  S -> AB | CC
  A -> BC | a
  B -> AA | b
  C -> AB | b

TURING MACHINE T over {0, 1} with blank '_', start state t0, halting state HALT:
  t0,0 -> t0, write 1, move R
  t0,1 -> t0, write 0, move R
  t0,_ -> HALT, write _, stay
  The head starts on the leftmost input symbol. A "step" is one transition taken.

STATE COUNTS — say which you mean, because there are three different right answers: the number
of subsets the subset construction could produce (2 to the power of the NFA's states), the
number REACHABLE from the start subset, and the number left after minimising. Every task below
names the one it wants.

Available imports: itertools, re. Nothing else is needed.

Strings are ordered SHORTLEX throughout: shorter strings first, and strings of the same length
in alphabetical order — so "", "a", "b", "aa", "ab", "ba", "bb", "aaa", ...

Put the requested values in `result` as a list of rows of plain values. Every value is an
integer or a string; there are no floats in this environment.


category: nfa

prompt: Do DFA M and NFA N accept the same language? Compare them on every string of length 0 through 8 and give the number of strings on which they DISAGREE, followed by the shortest such string in shortlex order (or 'none' if there is no disagreement). Return one row [count, witness].

api_description:
The tasks refer to these fixed machines. The alphabet is {a, b} unless stated.

DFA M (states q0, q1, q2; start q0; accepting {q2}):
  q0 -a-> q1    q0 -b-> q0
  q1 -a-> q2    q1 -b-> q0
  q2 -a-> q2    q2 -b-> q2

NFA N (states p0, p1, p2; start p0; accepting {p2}; no epsilon transitions):
  p0 -a-> {p0, p1}    p0 -b-> {p0}
  p1 -a-> {}          p1 -b-> {p2}
  p2 -a-> {p2}        p2 -b-> {p2}

CFG G in Chomsky normal form, start symbol S:
  S -> AB | CC
  A -> BC | a
  B -> AA | b
  C -> AB | b

TURING MACHINE T over {0, 1} with blank '_', start state t0, halting state HALT:
  t0,0 -> t0, write 1, move R
  t0,1 -> t0, write 0, move R
  t0,_ -> HALT, write _, stay
  The head starts on the leftmost input symbol. A "step" is one transition taken.

STATE COUNTS — say which you mean, because there are three different right answers: the number
of subsets the subset construction could produce (2 to the power of the NFA's states), the
number REACHABLE from the start subset, and the number left after minimising. Every task below
names the one it wants.

Available imports: itertools, re. Nothing else is needed.

Strings are ordered SHORTLEX throughout: shorter strings first, and strings of the same length
in alphabetical order — so "", "a", "b", "aa", "ab", "ba", "bb", "aaa", ...

Put the requested values in `result` as a list of rows of plain values. Every value is an
integer or a string; there are no floats in this environment.


category: regex

prompt: How many strings of length exactly 4 over {a,b} contain 'aa' as a substring, and how many contain 'ab'? Return one row [with_aa, with_ab].

api_description:
The tasks refer to these fixed machines. The alphabet is {a, b} unless stated.

DFA M (states q0, q1, q2; start q0; accepting {q2}):
  q0 -a-> q1    q0 -b-> q0
  q1 -a-> q2    q1 -b-> q0
  q2 -a-> q2    q2 -b-> q2

NFA N (states p0, p1, p2; start p0; accepting {p2}; no epsilon transitions):
  p0 -a-> {p0, p1}    p0 -b-> {p0}
  p1 -a-> {}          p1 -b-> {p2}
  p2 -a-> {p2}        p2 -b-> {p2}

CFG G in Chomsky normal form, start symbol S:
  S -> AB | CC
  A -> BC | a
  B -> AA | b
  C -> AB | b

TURING MACHINE T over {0, 1} with blank '_', start state t0, halting state HALT:
  t0,0 -> t0, write 1, move R
  t0,1 -> t0, write 0, move R
  t0,_ -> HALT, write _, stay
  The head starts on the leftmost input symbol. A "step" is one transition taken.

STATE COUNTS — say which you mean, because there are three different right answers: the number
of subsets the subset construction could produce (2 to the power of the NFA's states), the
number REACHABLE from the start subset, and the number left after minimising. Every task below
names the one it wants.

Available imports: itertools, re. Nothing else is needed.

Strings are ordered SHORTLEX throughout: shorter strings first, and strings of the same length
in alphabetical order — so "", "a", "b", "aa", "ab", "ba", "bb", "aaa", ...

Put the requested values in `result` as a list of rows of plain values. Every value is an
integer or a string; there are no floats in this environment.


category: regex

prompt: Do the patterns '^.*aa.*$' and '^.*ab.*$' describe the same language over {a,b}? Compare on every string of length 0 through 8 and give the number of disagreements and the shortest witness in shortlex order (or 'none'). Return one row [count, witness].

api_description:
The tasks refer to these fixed machines. The alphabet is {a, b} unless stated.

DFA M (states q0, q1, q2; start q0; accepting {q2}):
  q0 -a-> q1    q0 -b-> q0
  q1 -a-> q2    q1 -b-> q0
  q2 -a-> q2    q2 -b-> q2

NFA N (states p0, p1, p2; start p0; accepting {p2}; no epsilon transitions):
  p0 -a-> {p0, p1}    p0 -b-> {p0}
  p1 -a-> {}          p1 -b-> {p2}
  p2 -a-> {p2}        p2 -b-> {p2}

CFG G in Chomsky normal form, start symbol S:
  S -> AB | CC
  A -> BC | a
  B -> AA | b
  C -> AB | b

TURING MACHINE T over {0, 1} with blank '_', start state t0, halting state HALT:
  t0,0 -> t0, write 1, move R
  t0,1 -> t0, write 0, move R
  t0,_ -> HALT, write _, stay
  The head starts on the leftmost input symbol. A "step" is one transition taken.

STATE COUNTS — say which you mean, because there are three different right answers: the number
of subsets the subset construction could produce (2 to the power of the NFA's states), the
number REACHABLE from the start subset, and the number left after minimising. Every task below
names the one it wants.

Available imports: itertools, re. Nothing else is needed.

Strings are ordered SHORTLEX throughout: shorter strings first, and strings of the same length
in alphabetical order — so "", "a", "b", "aa", "ab", "ba", "bb", "aaa", ...

Put the requested values in `result` as a list of rows of plain values. Every value is an
integer or a string; there are no floats in this environment.


category: regex

prompt: Does the pattern '^.*aa.*$' describe exactly the language of DFA M? Compare on every string of length 0 through 8 and give the number of disagreements, then the number of strings in that range that BOTH accept. Return one row [disagreements, both_accept].

api_description:
The tasks refer to these fixed machines. The alphabet is {a, b} unless stated.

DFA M (states q0, q1, q2; start q0; accepting {q2}):
  q0 -a-> q1    q0 -b-> q0
  q1 -a-> q2    q1 -b-> q0
  q2 -a-> q2    q2 -b-> q2

NFA N (states p0, p1, p2; start p0; accepting {p2}; no epsilon transitions):
  p0 -a-> {p0, p1}    p0 -b-> {p0}
  p1 -a-> {}          p1 -b-> {p2}
  p2 -a-> {p2}        p2 -b-> {p2}

CFG G in Chomsky normal form, start symbol S:
  S -> AB | CC
  A -> BC | a
  B -> AA | b
  C -> AB | b

TURING MACHINE T over {0, 1} with blank '_', start state t0, halting state HALT:
  t0,0 -> t0, write 1, move R
  t0,1 -> t0, write 0, move R
  t0,_ -> HALT, write _, stay
  The head starts on the leftmost input symbol. A "step" is one transition taken.

STATE COUNTS — say which you mean, because there are three different right answers: the number
of subsets the subset construction could produce (2 to the power of the NFA's states), the
number REACHABLE from the start subset, and the number left after minimising. Every task below
names the one it wants.

Available imports: itertools, re. Nothing else is needed.

Strings are ordered SHORTLEX throughout: shorter strings first, and strings of the same length
in alphabetical order — so "", "a", "b", "aa", "ab", "ba", "bb", "aaa", ...

Put the requested values in `result` as a list of rows of plain values. Every value is an
integer or a string; there are no floats in this environment.


category: regex

prompt: Over {a,b}, how many strings of length exactly 5 match '^(ab)*$', '^a*b*$' and '^.*aba.*$'? Return one row of the three integers.

api_description:
The tasks refer to these fixed machines. The alphabet is {a, b} unless stated.

DFA M (states q0, q1, q2; start q0; accepting {q2}):
  q0 -a-> q1    q0 -b-> q0
  q1 -a-> q2    q1 -b-> q0
  q2 -a-> q2    q2 -b-> q2

NFA N (states p0, p1, p2; start p0; accepting {p2}; no epsilon transitions):
  p0 -a-> {p0, p1}    p0 -b-> {p0}
  p1 -a-> {}          p1 -b-> {p2}
  p2 -a-> {p2}        p2 -b-> {p2}

CFG G in Chomsky normal form, start symbol S:
  S -> AB | CC
  A -> BC | a
  B -> AA | b
  C -> AB | b

TURING MACHINE T over {0, 1} with blank '_', start state t0, halting state HALT:
  t0,0 -> t0, write 1, move R
  t0,1 -> t0, write 0, move R
  t0,_ -> HALT, write _, stay
  The head starts on the leftmost input symbol. A "step" is one transition taken.

STATE COUNTS — say which you mean, because there are three different right answers: the number
of subsets the subset construction could produce (2 to the power of the NFA's states), the
number REACHABLE from the start subset, and the number left after minimising. Every task below
names the one it wants.

Available imports: itertools, re. Nothing else is needed.

Strings are ordered SHORTLEX throughout: shorter strings first, and strings of the same length
in alphabetical order — so "", "a", "b", "aa", "ab", "ba", "bb", "aaa", ...

Put the requested values in `result` as a list of rows of plain values. Every value is an
integer or a string; there are no floats in this environment.


category: regex

prompt: In shortlex order over {a,b}, give the first four strings matching '^a*b*$' that are NOT matched by '^(ab)*$'. Return one row of the four strings (the empty string is written as the two characters '""' if it occurs — it does not here).

api_description:
The tasks refer to these fixed machines. The alphabet is {a, b} unless stated.

DFA M (states q0, q1, q2; start q0; accepting {q2}):
  q0 -a-> q1    q0 -b-> q0
  q1 -a-> q2    q1 -b-> q0
  q2 -a-> q2    q2 -b-> q2

NFA N (states p0, p1, p2; start p0; accepting {p2}; no epsilon transitions):
  p0 -a-> {p0, p1}    p0 -b-> {p0}
  p1 -a-> {}          p1 -b-> {p2}
  p2 -a-> {p2}        p2 -b-> {p2}

CFG G in Chomsky normal form, start symbol S:
  S -> AB | CC
  A -> BC | a
  B -> AA | b
  C -> AB | b

TURING MACHINE T over {0, 1} with blank '_', start state t0, halting state HALT:
  t0,0 -> t0, write 1, move R
  t0,1 -> t0, write 0, move R
  t0,_ -> HALT, write _, stay
  The head starts on the leftmost input symbol. A "step" is one transition taken.

STATE COUNTS — say which you mean, because there are three different right answers: the number
of subsets the subset construction could produce (2 to the power of the NFA's states), the
number REACHABLE from the start subset, and the number left after minimising. Every task below
names the one it wants.

Available imports: itertools, re. Nothing else is needed.

Strings are ordered SHORTLEX throughout: shorter strings first, and strings of the same length
in alphabetical order — so "", "a", "b", "aa", "ab", "ba", "bb", "aaa", ...

Put the requested values in `result` as a list of rows of plain values. Every value is an
integer or a string; there are no floats in this environment.


category: cfg

prompt: Using CYK on grammar G, report 1 if the string is generated and 0 if not, for 'ab', 'ba', 'aab', 'bab' and 'abb', in that order. Return one row of five values.

api_description:
The tasks refer to these fixed machines. The alphabet is {a, b} unless stated.

DFA M (states q0, q1, q2; start q0; accepting {q2}):
  q0 -a-> q1    q0 -b-> q0
  q1 -a-> q2    q1 -b-> q0
  q2 -a-> q2    q2 -b-> q2

NFA N (states p0, p1, p2; start p0; accepting {p2}; no epsilon transitions):
  p0 -a-> {p0, p1}    p0 -b-> {p0}
  p1 -a-> {}          p1 -b-> {p2}
  p2 -a-> {p2}        p2 -b-> {p2}

CFG G in Chomsky normal form, start symbol S:
  S -> AB | CC
  A -> BC | a
  B -> AA | b
  C -> AB | b

TURING MACHINE T over {0, 1} with blank '_', start state t0, halting state HALT:
  t0,0 -> t0, write 1, move R
  t0,1 -> t0, write 0, move R
  t0,_ -> HALT, write _, stay
  The head starts on the leftmost input symbol. A "step" is one transition taken.

STATE COUNTS — say which you mean, because there are three different right answers: the number
of subsets the subset construction could produce (2 to the power of the NFA's states), the
number REACHABLE from the start subset, and the number left after minimising. Every task below
names the one it wants.

Available imports: itertools, re. Nothing else is needed.

Strings are ordered SHORTLEX throughout: shorter strings first, and strings of the same length
in alphabetical order — so "", "a", "b", "aa", "ab", "ba", "bb", "aaa", ...

Put the requested values in `result` as a list of rows of plain values. Every value is an
integer or a string; there are no floats in this environment.


category: cfg

prompt: How many strings of length exactly n does grammar G generate, for n = 2, n = 3 and n = 4? Return one row of the three integers.

api_description:
The tasks refer to these fixed machines. The alphabet is {a, b} unless stated.

DFA M (states q0, q1, q2; start q0; accepting {q2}):
  q0 -a-> q1    q0 -b-> q0
  q1 -a-> q2    q1 -b-> q0
  q2 -a-> q2    q2 -b-> q2

NFA N (states p0, p1, p2; start p0; accepting {p2}; no epsilon transitions):
  p0 -a-> {p0, p1}    p0 -b-> {p0}
  p1 -a-> {}          p1 -b-> {p2}
  p2 -a-> {p2}        p2 -b-> {p2}

CFG G in Chomsky normal form, start symbol S:
  S -> AB | CC
  A -> BC | a
  B -> AA | b
  C -> AB | b

TURING MACHINE T over {0, 1} with blank '_', start state t0, halting state HALT:
  t0,0 -> t0, write 1, move R
  t0,1 -> t0, write 0, move R
  t0,_ -> HALT, write _, stay
  The head starts on the leftmost input symbol. A "step" is one transition taken.

STATE COUNTS — say which you mean, because there are three different right answers: the number
of subsets the subset construction could produce (2 to the power of the NFA's states), the
number REACHABLE from the start subset, and the number left after minimising. Every task below
names the one it wants.

Available imports: itertools, re. Nothing else is needed.

Strings are ordered SHORTLEX throughout: shorter strings first, and strings of the same length
in alphabetical order — so "", "a", "b", "aa", "ab", "ba", "bb", "aaa", ...

Put the requested values in `result` as a list of rows of plain values. Every value is an
integer or a string; there are no floats in this environment.


category: cfg

prompt: In shortlex order, give the first three strings that grammar G generates. Return one row of the three strings.

api_description:
The tasks refer to these fixed machines. The alphabet is {a, b} unless stated.

DFA M (states q0, q1, q2; start q0; accepting {q2}):
  q0 -a-> q1    q0 -b-> q0
  q1 -a-> q2    q1 -b-> q0
  q2 -a-> q2    q2 -b-> q2

NFA N (states p0, p1, p2; start p0; accepting {p2}; no epsilon transitions):
  p0 -a-> {p0, p1}    p0 -b-> {p0}
  p1 -a-> {}          p1 -b-> {p2}
  p2 -a-> {p2}        p2 -b-> {p2}

CFG G in Chomsky normal form, start symbol S:
  S -> AB | CC
  A -> BC | a
  B -> AA | b
  C -> AB | b

TURING MACHINE T over {0, 1} with blank '_', start state t0, halting state HALT:
  t0,0 -> t0, write 1, move R
  t0,1 -> t0, write 0, move R
  t0,_ -> HALT, write _, stay
  The head starts on the leftmost input symbol. A "step" is one transition taken.

STATE COUNTS — say which you mean, because there are three different right answers: the number
of subsets the subset construction could produce (2 to the power of the NFA's states), the
number REACHABLE from the start subset, and the number left after minimising. Every task below
names the one it wants.

Available imports: itertools, re. Nothing else is needed.

Strings are ordered SHORTLEX throughout: shorter strings first, and strings of the same length
in alphabetical order — so "", "a", "b", "aa", "ab", "ba", "bb", "aaa", ...

Put the requested values in `result` as a list of rows of plain values. Every value is an
integer or a string; there are no floats in this environment.


category: cfg

prompt: Grammar G is AMBIGUOUS. How many distinct parse trees does it give to 'bbabb', to 'aaaab' and to 'ba'? Return one row of the three integers.

api_description:
The tasks refer to these fixed machines. The alphabet is {a, b} unless stated.

DFA M (states q0, q1, q2; start q0; accepting {q2}):
  q0 -a-> q1    q0 -b-> q0
  q1 -a-> q2    q1 -b-> q0
  q2 -a-> q2    q2 -b-> q2

NFA N (states p0, p1, p2; start p0; accepting {p2}; no epsilon transitions):
  p0 -a-> {p0, p1}    p0 -b-> {p0}
  p1 -a-> {}          p1 -b-> {p2}
  p2 -a-> {p2}        p2 -b-> {p2}

CFG G in Chomsky normal form, start symbol S:
  S -> AB | CC
  A -> BC | a
  B -> AA | b
  C -> AB | b

TURING MACHINE T over {0, 1} with blank '_', start state t0, halting state HALT:
  t0,0 -> t0, write 1, move R
  t0,1 -> t0, write 0, move R
  t0,_ -> HALT, write _, stay
  The head starts on the leftmost input symbol. A "step" is one transition taken.

STATE COUNTS — say which you mean, because there are three different right answers: the number
of subsets the subset construction could produce (2 to the power of the NFA's states), the
number REACHABLE from the start subset, and the number left after minimising. Every task below
names the one it wants.

Available imports: itertools, re. Nothing else is needed.

Strings are ordered SHORTLEX throughout: shorter strings first, and strings of the same length
in alphabetical order — so "", "a", "b", "aa", "ab", "ba", "bb", "aaa", ...

Put the requested values in `result` as a list of rows of plain values. Every value is an
integer or a string; there are no floats in this environment.


category: cfg

prompt: For the CYK table on the string 'bbabb', give the number of variables in the cell spanning the whole string, and the number of non-empty cells in the whole table. Return one row [top_cell_size, non_empty_cells].

api_description:
The tasks refer to these fixed machines. The alphabet is {a, b} unless stated.

DFA M (states q0, q1, q2; start q0; accepting {q2}):
  q0 -a-> q1    q0 -b-> q0
  q1 -a-> q2    q1 -b-> q0
  q2 -a-> q2    q2 -b-> q2

NFA N (states p0, p1, p2; start p0; accepting {p2}; no epsilon transitions):
  p0 -a-> {p0, p1}    p0 -b-> {p0}
  p1 -a-> {}          p1 -b-> {p2}
  p2 -a-> {p2}        p2 -b-> {p2}

CFG G in Chomsky normal form, start symbol S:
  S -> AB | CC
  A -> BC | a
  B -> AA | b
  C -> AB | b

TURING MACHINE T over {0, 1} with blank '_', start state t0, halting state HALT:
  t0,0 -> t0, write 1, move R
  t0,1 -> t0, write 0, move R
  t0,_ -> HALT, write _, stay
  The head starts on the leftmost input symbol. A "step" is one transition taken.

STATE COUNTS — say which you mean, because there are three different right answers: the number
of subsets the subset construction could produce (2 to the power of the NFA's states), the
number REACHABLE from the start subset, and the number left after minimising. Every task below
names the one it wants.

Available imports: itertools, re. Nothing else is needed.

Strings are ordered SHORTLEX throughout: shorter strings first, and strings of the same length
in alphabetical order — so "", "a", "b", "aa", "ab", "ba", "bb", "aaa", ...

Put the requested values in `result` as a list of rows of plain values. Every value is an
integer or a string; there are no floats in this environment.


category: cfg

prompt: Is the language of grammar G the same as the language of DFA M? Compare on every string of length 1 through 6 and give the number of disagreements and the shortest witness in shortlex order (or 'none'). Return one row [count, witness].

api_description:
The tasks refer to these fixed machines. The alphabet is {a, b} unless stated.

DFA M (states q0, q1, q2; start q0; accepting {q2}):
  q0 -a-> q1    q0 -b-> q0
  q1 -a-> q2    q1 -b-> q0
  q2 -a-> q2    q2 -b-> q2

NFA N (states p0, p1, p2; start p0; accepting {p2}; no epsilon transitions):
  p0 -a-> {p0, p1}    p0 -b-> {p0}
  p1 -a-> {}          p1 -b-> {p2}
  p2 -a-> {p2}        p2 -b-> {p2}

CFG G in Chomsky normal form, start symbol S:
  S -> AB | CC
  A -> BC | a
  B -> AA | b
  C -> AB | b

TURING MACHINE T over {0, 1} with blank '_', start state t0, halting state HALT:
  t0,0 -> t0, write 1, move R
  t0,1 -> t0, write 0, move R
  t0,_ -> HALT, write _, stay
  The head starts on the leftmost input symbol. A "step" is one transition taken.

STATE COUNTS — say which you mean, because there are three different right answers: the number
of subsets the subset construction could produce (2 to the power of the NFA's states), the
number REACHABLE from the start subset, and the number left after minimising. Every task below
names the one it wants.

Available imports: itertools, re. Nothing else is needed.

Strings are ordered SHORTLEX throughout: shorter strings first, and strings of the same length
in alphabetical order — so "", "a", "b", "aa", "ab", "ba", "bb", "aaa", ...

Put the requested values in `result` as a list of rows of plain values. Every value is an
integer or a string; there are no floats in this environment.


category: tm

prompt: Run Turing machine T on the input '1011'. Give the final tape content with any trailing blanks removed, the number of steps taken, and the final head position as a 0-based index. Return one row [tape, steps, head].

api_description:
The tasks refer to these fixed machines. The alphabet is {a, b} unless stated.

DFA M (states q0, q1, q2; start q0; accepting {q2}):
  q0 -a-> q1    q0 -b-> q0
  q1 -a-> q2    q1 -b-> q0
  q2 -a-> q2    q2 -b-> q2

NFA N (states p0, p1, p2; start p0; accepting {p2}; no epsilon transitions):
  p0 -a-> {p0, p1}    p0 -b-> {p0}
  p1 -a-> {}          p1 -b-> {p2}
  p2 -a-> {p2}        p2 -b-> {p2}

CFG G in Chomsky normal form, start symbol S:
  S -> AB | CC
  A -> BC | a
  B -> AA | b
  C -> AB | b

TURING MACHINE T over {0, 1} with blank '_', start state t0, halting state HALT:
  t0,0 -> t0, write 1, move R
  t0,1 -> t0, write 0, move R
  t0,_ -> HALT, write _, stay
  The head starts on the leftmost input symbol. A "step" is one transition taken.

STATE COUNTS — say which you mean, because there are three different right answers: the number
of subsets the subset construction could produce (2 to the power of the NFA's states), the
number REACHABLE from the start subset, and the number left after minimising. Every task below
names the one it wants.

Available imports: itertools, re. Nothing else is needed.

Strings are ordered SHORTLEX throughout: shorter strings first, and strings of the same length
in alphabetical order — so "", "a", "b", "aa", "ab", "ba", "bb", "aaa", ...

Put the requested values in `result` as a list of rows of plain values. Every value is an
integer or a string; there are no floats in this environment.


category: tm

prompt: Run T on '0000' and on '1111'. Give each final tape with trailing blanks removed, then the number of steps for each. Return one row [tape1, tape2, steps1, steps2].

api_description:
The tasks refer to these fixed machines. The alphabet is {a, b} unless stated.

DFA M (states q0, q1, q2; start q0; accepting {q2}):
  q0 -a-> q1    q0 -b-> q0
  q1 -a-> q2    q1 -b-> q0
  q2 -a-> q2    q2 -b-> q2

NFA N (states p0, p1, p2; start p0; accepting {p2}; no epsilon transitions):
  p0 -a-> {p0, p1}    p0 -b-> {p0}
  p1 -a-> {}          p1 -b-> {p2}
  p2 -a-> {p2}        p2 -b-> {p2}

CFG G in Chomsky normal form, start symbol S:
  S -> AB | CC
  A -> BC | a
  B -> AA | b
  C -> AB | b

TURING MACHINE T over {0, 1} with blank '_', start state t0, halting state HALT:
  t0,0 -> t0, write 1, move R
  t0,1 -> t0, write 0, move R
  t0,_ -> HALT, write _, stay
  The head starts on the leftmost input symbol. A "step" is one transition taken.

STATE COUNTS — say which you mean, because there are three different right answers: the number
of subsets the subset construction could produce (2 to the power of the NFA's states), the
number REACHABLE from the start subset, and the number left after minimising. Every task below
names the one it wants.

Available imports: itertools, re. Nothing else is needed.

Strings are ordered SHORTLEX throughout: shorter strings first, and strings of the same length
in alphabetical order — so "", "a", "b", "aa", "ab", "ba", "bb", "aaa", ...

Put the requested values in `result` as a list of rows of plain values. Every value is an
integer or a string; there are no floats in this environment.


category: tm

prompt: How many steps does T take on inputs of length 0, 1, 4 and 10? Return one row of the four integers.

api_description:
The tasks refer to these fixed machines. The alphabet is {a, b} unless stated.

DFA M (states q0, q1, q2; start q0; accepting {q2}):
  q0 -a-> q1    q0 -b-> q0
  q1 -a-> q2    q1 -b-> q0
  q2 -a-> q2    q2 -b-> q2

NFA N (states p0, p1, p2; start p0; accepting {p2}; no epsilon transitions):
  p0 -a-> {p0, p1}    p0 -b-> {p0}
  p1 -a-> {}          p1 -b-> {p2}
  p2 -a-> {p2}        p2 -b-> {p2}

CFG G in Chomsky normal form, start symbol S:
  S -> AB | CC
  A -> BC | a
  B -> AA | b
  C -> AB | b

TURING MACHINE T over {0, 1} with blank '_', start state t0, halting state HALT:
  t0,0 -> t0, write 1, move R
  t0,1 -> t0, write 0, move R
  t0,_ -> HALT, write _, stay
  The head starts on the leftmost input symbol. A "step" is one transition taken.

STATE COUNTS — say which you mean, because there are three different right answers: the number
of subsets the subset construction could produce (2 to the power of the NFA's states), the
number REACHABLE from the start subset, and the number left after minimising. Every task below
names the one it wants.

Available imports: itertools, re. Nothing else is needed.

Strings are ordered SHORTLEX throughout: shorter strings first, and strings of the same length
in alphabetical order — so "", "a", "b", "aa", "ab", "ba", "bb", "aaa", ...

Put the requested values in `result` as a list of rows of plain values. Every value is an
integer or a string; there are no floats in this environment.


category: tm

prompt: Run T on '1011' and then run T again on its OWN output. Give the tape after the second run with trailing blanks removed, and 1 if it equals the original input or 0 if it does not. Return one row [tape, equals_original].

api_description:
The tasks refer to these fixed machines. The alphabet is {a, b} unless stated.

DFA M (states q0, q1, q2; start q0; accepting {q2}):
  q0 -a-> q1    q0 -b-> q0
  q1 -a-> q2    q1 -b-> q0
  q2 -a-> q2    q2 -b-> q2

NFA N (states p0, p1, p2; start p0; accepting {p2}; no epsilon transitions):
  p0 -a-> {p0, p1}    p0 -b-> {p0}
  p1 -a-> {}          p1 -b-> {p2}
  p2 -a-> {p2}        p2 -b-> {p2}

CFG G in Chomsky normal form, start symbol S:
  S -> AB | CC
  A -> BC | a
  B -> AA | b
  C -> AB | b

TURING MACHINE T over {0, 1} with blank '_', start state t0, halting state HALT:
  t0,0 -> t0, write 1, move R
  t0,1 -> t0, write 0, move R
  t0,_ -> HALT, write _, stay
  The head starts on the leftmost input symbol. A "step" is one transition taken.

STATE COUNTS — say which you mean, because there are three different right answers: the number
of subsets the subset construction could produce (2 to the power of the NFA's states), the
number REACHABLE from the start subset, and the number left after minimising. Every task below
names the one it wants.

Available imports: itertools, re. Nothing else is needed.

Strings are ordered SHORTLEX throughout: shorter strings first, and strings of the same length
in alphabetical order — so "", "a", "b", "aa", "ab", "ba", "bb", "aaa", ...

Put the requested values in `result` as a list of rows of plain values. Every value is an
integer or a string; there are no floats in this environment.


category: tm

prompt: Give the state and the symbol under the head after exactly 2 steps of T on the input '101', and after exactly 3 steps. Return one row [state2, symbol2, state3, symbol3].

api_description:
The tasks refer to these fixed machines. The alphabet is {a, b} unless stated.

DFA M (states q0, q1, q2; start q0; accepting {q2}):
  q0 -a-> q1    q0 -b-> q0
  q1 -a-> q2    q1 -b-> q0
  q2 -a-> q2    q2 -b-> q2

NFA N (states p0, p1, p2; start p0; accepting {p2}; no epsilon transitions):
  p0 -a-> {p0, p1}    p0 -b-> {p0}
  p1 -a-> {}          p1 -b-> {p2}
  p2 -a-> {p2}        p2 -b-> {p2}

CFG G in Chomsky normal form, start symbol S:
  S -> AB | CC
  A -> BC | a
  B -> AA | b
  C -> AB | b

TURING MACHINE T over {0, 1} with blank '_', start state t0, halting state HALT:
  t0,0 -> t0, write 1, move R
  t0,1 -> t0, write 0, move R
  t0,_ -> HALT, write _, stay
  The head starts on the leftmost input symbol. A "step" is one transition taken.

STATE COUNTS — say which you mean, because there are three different right answers: the number
of subsets the subset construction could produce (2 to the power of the NFA's states), the
number REACHABLE from the start subset, and the number left after minimising. Every task below
names the one it wants.

Available imports: itertools, re. Nothing else is needed.

Strings are ordered SHORTLEX throughout: shorter strings first, and strings of the same length
in alphabetical order — so "", "a", "b", "aa", "ab", "ba", "bb", "aaa", ...

Put the requested values in `result` as a list of rows of plain values. Every value is an
integer or a string; there are no floats in this environment.