-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
153 changed files
with
14,630 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
pip-wheel-metadata/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# GAMBA tools | ||
|
||
The `gambatools` package is a Python 3 package that aims to | ||
support education in theoretical computer science at | ||
[Eindhoven University of Technology](https://www.tue.nl/en/). | ||
It contains a library for | ||
DFAs, NFAs, PDAs, Turing machines, context free grammars and | ||
regular expressions. Moreover, the package provides Jupyter notebooks with | ||
exercises. The library has been developed by Wieger Wesselink, | ||
and it was designed together with Erik de Vink. | ||
|
||
# GAMBA | ||
The code was developed as part of the GAMBA project, which stands for: | ||
*Grammars and Automata Made Boffo and Assessible*. The goals of the project are | ||
to support | ||
|
||
* practising and assessing formal language techniques | ||
* self-paced learning outside contact hours | ||
* immediate feedback while practising | ||
* automated grading for assessment | ||
|
||
(*boffo*: extremely successful, sensational) | ||
|
||
# License | ||
The code is distributed under the `GPL-3.0-or-later` license. | ||
|
||
# Installation | ||
The package can be installed using | ||
``` | ||
pip install gambatools | ||
``` | ||
The required python packages can be found in `requirements.txt`. | ||
|
||
# Rendering images | ||
For visualization the [graphviz](https://pypi.org/project/graphviz/) python | ||
package is used. **To render the generated DOT source code, you also need to install | ||
Graphviz**. See the [Graphviz website](https://graphviz.org/) for further instructions. | ||
Make sure that the directory containing the `dot` executable is on your systems’ path. | ||
|
||
# Documentation | ||
The file `doc/specifications.pdf` contains formal specifications | ||
of the algorithms in the library. Note that the code maps almost one-to-one | ||
to the specifications, so in order to understand the code please consult the | ||
pseudocode specifications. | ||
|
||
# Notebooks | ||
The directory `notebooks` contains a number of Jupyter notebooks | ||
with exercises. In `notebooks/with-answers` the correct answers are | ||
already given, while in `notebooks/without-answers` they have been | ||
left out. | ||
The answers to the exercises are checked automatically. | ||
Whenever the user makes a mistake, appropriate feedback is given. | ||
|
||
![NFA to DFA](doc/images/nfa2dfa.png) | ||
|
||
For specifying a DFA, NFA, etc. a line based textual input format is used, | ||
see the example below. The documentation contains a section that describes | ||
the syntax, while in the `examples` directory a number of examples can be found. | ||
``` | ||
input_symbols 0 1 | ||
states qA qB qC qD | ||
initial qA | ||
final qC | ||
qA qB 0 | ||
qA qD 1 | ||
qB qB 0 | ||
qB qC 1 | ||
qC qB 0 | ||
qC qC 1 | ||
qD qD 0 | ||
qD qD 1 | ||
``` | ||
|
||
# Notebook generation | ||
For convenience there is a mechanism to automatically generate notebooks from | ||
templates. | ||
The notebooks in `notebooks/with-answers` and `notebooks/without-answers` | ||
have been generated using the commands | ||
``` | ||
make_notebook.py -o without-answers notebooks.batch | ||
make_notebook.py --with-answers -o with-answers notebooks.batch | ||
``` | ||
The templates contain tags of the form `<<tag>>` that are substituted by | ||
the `make_notebook.py` script. This generation is still experimental, and | ||
there is currently no documentation available for this. | ||
|
||
# Contact | ||
If you are interested in using the package for education or have questions | ||
or feedback, the authors can be reached by email: | ||
<[email protected]> or <[email protected]>. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
%% language = \lbrace \, a^{\mkern1mu n} \mkern1mu b^{\mkern1mu m} c^{\mkern1mu \ell} \mid n = m \lor m = \ell \lor n = \ell \, \rbrace | ||
%% accepted = _ aaa bb c aabb bc aabc aabbbcc aaaccc | ||
%% rejected = bcc aab aabbbc ccaaabb bbccaa abab cb aaacccc | ||
%% question = Give a CFG that generates the language $@language@$. | ||
|
||
S -> XC | AY | Z | ||
X -> aXb | ε | ||
Y -> bYc | ε | ||
Z -> aZc | B | ||
A -> aA | ε | ||
B -> bB | ε | ||
C -> cC | ε |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
S -> ASA | aB | ||
A -> B | S | ||
B -> b | ε |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
T -> AC | AS | SA | DB | a | ||
S -> AS | SA | DB | a | AC | ||
B -> b | ||
A -> AC | AS | SA | DB | a | b | ||
C -> SA | ||
D -> a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
%% language = \{ \, w \in \{a,b\}^\ast \mid \#_a(w) \geqslant 2 \, \} | ||
|
||
input_symbols a b | ||
states q0 q1 q2 | ||
initial q0 | ||
final q2 | ||
q0 q0 b | ||
q0 q1 a | ||
q1 q1 b | ||
q1 q2 a | ||
q2 q2 a b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
%% Sipser Exercise 1.6a | ||
%% 0.(0+1)*.1 | ||
|
||
%% question = Give a DFA that generates the language $@language@$. | ||
%% language = \{ w \in {0,1}^\ast \mid w \text{ starts with } 0 \text{ and ends with } 1 \} | ||
|
||
%% selected_word = 0101 | ||
|
||
input_symbols 0 1 | ||
states qA qB qC qD | ||
|
||
initial qA | ||
final qC | ||
|
||
qA qB 0 | ||
qA qD 1 | ||
qB qB 0 | ||
qB qC 1 | ||
qC qB 0 | ||
qC qC 1 | ||
qD qD 0 | ||
qD qD 1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
%% alphabet = \{a,b\} | ||
|
||
initial q0 | ||
final q1 | ||
q0 q1 a | ||
q1 q1 a b | ||
q0 q2 b | ||
q2 q2 a b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
%% language = \{ \, w \in \{a,b\}^\ast \mid \mbox{$\#_a(w)$ even} \, \} | ||
|
||
input_symbols a b | ||
states q0 q1 | ||
initial q0 | ||
final q0 | ||
q0 q0 b | ||
q0 q1 a | ||
q1 q0 a | ||
q1 q1 b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
%% language = \{ \, w \in \{a,b\}^\ast \mid \#_b(w) \geqslant 2 \, \} | ||
|
||
input_symbols a b | ||
states q0 q1 q2 | ||
initial q0 | ||
final q2 | ||
q0 q0 a | ||
q0 q1 b | ||
q1 q1 a | ||
q1 q2 b | ||
q2 q2 a b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
%% language = \{ w \in \{0,1\}^* \mid \#_0(w) \geq 2, \#_1(w) \leq 1 \}^* | ||
%% question = Give an NFA that accepts the language $@language@$. | ||
|
||
initial s6 | ||
final s2 s5 s6 | ||
s0 s1 0 | ||
s0 s3 1 | ||
s1 s2 0 | ||
s1 s4 1 | ||
s2 s0 ε | ||
s2 s2 0 | ||
s2 s5 1 | ||
s3 s4 0 | ||
s4 s5 0 | ||
s5 s0 ε | ||
s5 s5 0 | ||
s6 s0 ε |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
%% question = Give the DFA obtained from the given NFA using the NFA to DFA procedure. Use set notation like `{q0,q1}` (without spaces) for the states in the DFA. | ||
|
||
input_symbols a b | ||
initial q0 | ||
final q2 | ||
q0 q0 a b | ||
q0 q1 ε | ||
q1 q1 a | ||
q1 q2 b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
%% language = \{ \, a^{\mkern1mu n} b^{\mkern1mu n} \mid n \geqslant 0 \, \} | ||
%% question = Give a PDA that accepts the language $@language@$. | ||
|
||
initial q0 | ||
final q3 | ||
|
||
q0 q1 e,e$ | ||
q1 q1 a,eX | ||
q1 q2 e,ee | ||
q2 q2 b,Xe | ||
q2 q3 e,$e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
%% language = \{ w \in \{a,b\}^\ast \mid \#_a(w) = 2\#_b(w) \} | ||
%% question = Give a PDA that generates the language $@language@$. | ||
|
||
initial q0 | ||
final q6 | ||
q0 q1 ε,ε$ | ||
q1 q2 ε,$$ | ||
q1 q3 ε,$$ | ||
q1 q6 ε,$ε | ||
q2 q1 ε,$$ | ||
q2 q2 a,nε | ||
q2 q5 b,εn | ||
q3 q1 ε,$$ | ||
q3 q3 a,εp | ||
q3 q4 b,pε | ||
q4 q3 ε,pε | ||
q4 q5 ε,$$ | ||
q5 q2 ε,εn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
%% language = \{ w \in \{a,b\}^\ast \mid \#_a(w) = 2\#_b(w) \} | ||
%% question = Give a PDA that generates the language $@language@$. | ||
|
||
epsilon ε | ||
initial q0 | ||
final q6 | ||
q0 q1 ε,ε$ | ||
q1 q2 ε,$$ | ||
q1 q3 ε,$$ | ||
q1 q6 ε,$ε | ||
q2 q1 ε,$$ | ||
q2 q2 a,nε | ||
q2 q5 b,εn | ||
q3 q1 ε,$$ | ||
q3 q3 a,εp | ||
q3 q4 b,pε | ||
q4 q3 ε,pε | ||
q4 q5 ε,$$ | ||
q5 q2 ε,εn |
Oops, something went wrong.