Datasets:
task_id stringlengths 6 6 | category stringclasses 5
values | prompt stringlengths 99 304 | api_description stringclasses 1
value | expected_output stringlengths 18 39 |
|---|---|---|---|---|
sp-000 | dfa | 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. | 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-... | {"rows": [[0, 1, 1, 0, 0]]} |
sp-001 | dfa | 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. | 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-... | {"rows": [[3, 19, 201]]} |
sp-002 | dfa | In SHORTLEX order (shorter first, ties alphabetically), give the first three strings that DFA M accepts. Return one row of the three strings. | 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-... | {"rows": [["aa", "aaa", "aab"]]} |
sp-003 | dfa | 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. | 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-... | {"rows": [["q1", "q0", "q1", "q2"]]} |
sp-004 | dfa | 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]. | 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-... | {"rows": [[3, 0]]} |
sp-005 | dfa | 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. | 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-... | {"rows": [[5, 13, 55]]} |
sp-006 | nfa | 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. | 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-... | {"rows": [[1, 0, 1, 0, 1]]} |
sp-007 | nfa | 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. | 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-... | {"rows": [[8, 4, 3]]} |
sp-008 | nfa | 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. | 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-... | {"rows": [["p0,p1", "p0,p1", "p0,p2"]]} |
sp-009 | nfa | 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. | 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-... | {"rows": [[1, 11, 57]]} |
sp-010 | nfa | 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]. | 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-... | {"rows": [[153, "aa"]]} |
sp-011 | regex | 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]. | 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-... | {"rows": [[8, 11]]} |
sp-012 | regex | 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]. | 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-... | {"rows": [[153, "aa"]]} |
sp-013 | regex | 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]. | 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-... | {"rows": [[0, 369]]} |
sp-014 | regex | Over {a,b}, how many strings of length exactly 5 match '^(ab)*$', '^a*b*$' and '^.*aba.*$'? Return one row of the three integers. | 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-... | {"rows": [[0, 6, 11]]} |
sp-015 | regex | 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). | 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-... | {"rows": [["a", "b", "aa", "bb"]]} |
sp-016 | cfg | 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. | 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-... | {"rows": [[1, 0, 0, 1, 1]]} |
sp-017 | cfg | 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. | 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-... | {"rows": [[2, 4, 8]]} |
sp-018 | cfg | In shortlex order, give the first three strings that grammar G generates. Return one row of the three strings. | 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-... | {"rows": [["ab", "bb", "aaa"]]} |
sp-019 | cfg | 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. | 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-... | {"rows": [[3, 2, 0]]} |
sp-020 | cfg | 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]. | 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-... | {"rows": [[3, 14]]} |
sp-021 | cfg | 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]. | 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-... | {"rows": [[63, "aa"]]} |
sp-022 | tm | 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]. | 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-... | {"rows": [["0100", 5, 4]]} |
sp-023 | tm | 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]. | 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-... | {"rows": [["1111", "0000", 5, 5]]} |
sp-024 | tm | How many steps does T take on inputs of length 0, 1, 4 and 10? Return one row of the four integers. | 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-... | {"rows": [[1, 2, 5, 11]]} |
sp-025 | tm | 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]. | 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-... | {"rows": [["1011", 1]]} |
sp-026 | tm | 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]. | 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-... | {"rows": [["t0", "1", "t0", "_"]]} |
sipser-tasks-v1
27 automata-and-formal-languages tasks for the
sipser-env RL
environment, on the topics of Introduction to the Theory of Computation (Sipser): DFA and NFA
simulation, the subset construction, DFA minimisation, regular expressions, CYK parsing of a
context-free grammar, and Turing machine execution.
| field | meaning |
|---|---|
task_id |
sp-000 … sp-026 |
category |
dfa / nfa / regex / cfg / tm |
prompt |
the question and the exact shape of the answer |
api_description |
the fixed machines — DFA, NFA, CFG, TM — plus the shortlex ordering rule |
expected_output |
JSON {"rows": [...]}, computed by executing a reference solution |
Categories: dfa 6, nfa 5, regex 5, cfg 6, tm 5. No dependencies — itertools and re are
standard library.
Original machines, not the book's exercises
Nothing is copied. The automata, grammar and Turing machine are invented here — deliberately including the grammar, because the CYK example printed in most textbooks is one and the same and its parse table is all over the web. A model can recall that table; it cannot recall this one.
Why automata theory suits an executed answer key
These questions look like proofs but are almost all decidable by simulation. Whether a DFA accepts a string, how many strings of length n it accepts, how many subsets the construction reaches, whether a regular expression and an automaton describe the same language, whether a grammar generates a string and with how many parse trees — each is a program, and the answer is whatever the program computes.
The trap: "how many states?" has three right answers
For the NFA here, the subset construction has 8 subsets on paper, 4 are reachable, and 3 survive minimisation. All three are correct answers to differently-worded questions, and an environment that was vague about which it wanted would mark correct work wrong. Every task names the one it means, and one task asks for all three at once.
A defect caught before publishing
A parse-tree-counting task asked how many trees the grammar gives to baaba — a string the
grammar does not generate at all, so the answer was 0 and the task taught nothing about
ambiguity. It now asks about bbabb (3 trees), aaaab (2) and ba (0), so one row
distinguishes ambiguous, derivable and non-generated. The builder asserts exactly that.
The two machines' languages are also cross-checked by brute force over every string up to length 10, rather than being trusted from their state diagrams.
Verify with python environments/sipser_env/build_tasks.py --verify (27/27).
Source: https://github.com/eltociear/my-molt-agent/tree/main/environments/sipser_env
- Downloads last month
- 28