wampy-prolog 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. wampy_prolog-0.1.0/.github/workflows/release.yml +82 -0
  2. wampy_prolog-0.1.0/.gitignore +223 -0
  3. wampy_prolog-0.1.0/LICENSE +21 -0
  4. wampy_prolog-0.1.0/PKG-INFO +48 -0
  5. wampy_prolog-0.1.0/README.md +23 -0
  6. wampy_prolog-0.1.0/benchmark/benchmark.py +348 -0
  7. wampy_prolog-0.1.0/benchmark/benchmark_plot.py +460 -0
  8. wampy_prolog-0.1.0/benchmark/benchmark_results.json +502 -0
  9. wampy_prolog-0.1.0/demo_wampy.ipynb +217 -0
  10. wampy_prolog-0.1.0/pyproject.toml +56 -0
  11. wampy_prolog-0.1.0/src/wampy/__init__.py +119 -0
  12. wampy_prolog-0.1.0/src/wampy/ast.py +1 -0
  13. wampy_prolog-0.1.0/src/wampy/compiler/__init__.py +13 -0
  14. wampy_prolog-0.1.0/src/wampy/compiler/compiler.py +665 -0
  15. wampy_prolog-0.1.0/src/wampy/compiler/opcodes.py +42 -0
  16. wampy_prolog-0.1.0/src/wampy/config.py +262 -0
  17. wampy_prolog-0.1.0/src/wampy/engine.py +440 -0
  18. wampy_prolog-0.1.0/src/wampy/frontend/__init__.py +3 -0
  19. wampy_prolog-0.1.0/src/wampy/frontend/answers.py +310 -0
  20. wampy_prolog-0.1.0/src/wampy/frontend/ast/__init__.py +74 -0
  21. wampy_prolog-0.1.0/src/wampy/frontend/ast/analysis.py +202 -0
  22. wampy_prolog-0.1.0/src/wampy/frontend/ast/goals.py +36 -0
  23. wampy_prolog-0.1.0/src/wampy/frontend/ast/program.py +373 -0
  24. wampy_prolog-0.1.0/src/wampy/frontend/ast/regeneration_old.py +456 -0
  25. wampy_prolog-0.1.0/src/wampy/frontend/ast/symbol_id.py +43 -0
  26. wampy_prolog-0.1.0/src/wampy/frontend/ast/transforms.py +29 -0
  27. wampy_prolog-0.1.0/src/wampy/frontend/parser.py +682 -0
  28. wampy_prolog-0.1.0/src/wampy/frontend/render.py +289 -0
  29. wampy_prolog-0.1.0/src/wampy/frontend/symbol_table.py +98 -0
  30. wampy_prolog-0.1.0/src/wampy/runtime/interpreter.py +839 -0
  31. wampy_prolog-0.1.0/src/wampy/runtime/stack.py +219 -0
  32. wampy_prolog-0.1.0/src/wampy/runtime/term_decode.py +133 -0
  33. wampy_prolog-0.1.0/src/wampy/runtime/unify.py +161 -0
  34. wampy_prolog-0.1.0/src/wampy/status.py +28 -0
  35. wampy_prolog-0.1.0/src/wampy/utils/__init__.py +17 -0
  36. wampy_prolog-0.1.0/src/wampy/utils/debug.py +198 -0
  37. wampy_prolog-0.1.0/src/wampy/utils/jit_print.py +368 -0
  38. wampy_prolog-0.1.0/tests/__init__.py +1 -0
  39. wampy_prolog-0.1.0/tests/cases.py +548 -0
  40. wampy_prolog-0.1.0/tests/compiler/__init__.py +1 -0
  41. wampy_prolog-0.1.0/tests/compiler/test_compiler.py +984 -0
  42. wampy_prolog-0.1.0/tests/compiler/test_compiler__onto.py +310 -0
  43. wampy_prolog-0.1.0/tests/frontend/ast/test_analysis.py +106 -0
  44. wampy_prolog-0.1.0/tests/frontend/ast/test_program.py +110 -0
  45. wampy_prolog-0.1.0/tests/frontend/example_parser.py +85 -0
  46. wampy_prolog-0.1.0/tests/frontend/test_answers.py +108 -0
  47. wampy_prolog-0.1.0/tests/frontend/test_parser.py +367 -0
  48. wampy_prolog-0.1.0/tests/frontend/test_render.py +119 -0
  49. wampy_prolog-0.1.0/tests/frontend/test_symbol_table.py +83 -0
  50. wampy_prolog-0.1.0/tests/runtime/__init__.py +1 -0
  51. wampy_prolog-0.1.0/tests/runtime/test_dynamic_solve.py +191 -0
  52. wampy_prolog-0.1.0/tests/runtime/test_interpreter.py +332 -0
  53. wampy_prolog-0.1.0/tests/runtime/test_stack.py +642 -0
  54. wampy_prolog-0.1.0/tests/runtime/test_unify.py +430 -0
  55. wampy_prolog-0.1.0/tests/test_engine.py +404 -0
  56. wampy_prolog-0.1.0/tests/utils/test_debug.py +53 -0
  57. wampy_prolog-0.1.0/tests/utils/test_jit_print.py +52 -0
@@ -0,0 +1,82 @@
1
+ name: Publish release to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ permissions: {}
9
+
10
+ jobs:
11
+ build:
12
+ name: Build and verify distribution
13
+ runs-on: ubuntu-latest
14
+ permissions:
15
+ contents: read
16
+
17
+ steps:
18
+ - name: Check out the tagged commit
19
+ uses: actions/checkout@v6
20
+ with:
21
+ persist-credentials: false
22
+
23
+ - name: Set up Python
24
+ uses: actions/setup-python@v6
25
+ with:
26
+ python-version: "3.x"
27
+
28
+ - name: Install build tools
29
+ run: python -m pip install --upgrade build twine
30
+
31
+ - name: Verify tag matches package version
32
+ env:
33
+ RELEASE_TAG: ${{ github.ref_name }}
34
+ run: |
35
+ python - <<'PY'
36
+ import os
37
+ import tomllib
38
+
39
+ with open("pyproject.toml", "rb") as pyproject:
40
+ version = tomllib.load(pyproject)["project"]["version"]
41
+
42
+ expected_tag = f"v{version}"
43
+ actual_tag = os.environ["RELEASE_TAG"]
44
+ if actual_tag != expected_tag:
45
+ raise SystemExit(
46
+ f"Release tag {actual_tag!r} does not match {expected_tag!r}"
47
+ )
48
+ PY
49
+
50
+ - name: Build wheel and source distribution
51
+ run: python -m build
52
+
53
+ - name: Check distribution metadata
54
+ run: python -m twine check --strict dist/*
55
+
56
+ - name: Store distribution packages
57
+ uses: actions/upload-artifact@v5
58
+ with:
59
+ name: python-package-distributions
60
+ path: dist/
61
+ if-no-files-found: error
62
+ retention-days: 1
63
+
64
+ publish:
65
+ name: Publish distribution to PyPI
66
+ needs: build
67
+ runs-on: ubuntu-latest
68
+ environment:
69
+ name: pypi
70
+ url: https://pypi.org/p/wampy-prolog
71
+ permissions:
72
+ id-token: write
73
+
74
+ steps:
75
+ - name: Download distribution packages
76
+ uses: actions/download-artifact@v6
77
+ with:
78
+ name: python-package-distributions
79
+ path: dist/
80
+
81
+ - name: Publish distribution to PyPI
82
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,223 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ *.lcov
51
+ .hypothesis/
52
+ .pytest_cache/
53
+ cover/
54
+
55
+ # Translations
56
+ *.mo
57
+ *.pot
58
+
59
+ # Django stuff:
60
+ *.log
61
+ local_settings.py
62
+ db.sqlite3
63
+ db.sqlite3-journal
64
+
65
+ # Flask stuff:
66
+ instance/
67
+ .webassets-cache
68
+
69
+ # Scrapy stuff:
70
+ .scrapy
71
+
72
+ # Sphinx documentation
73
+ docs/_build/
74
+
75
+ # PyBuilder
76
+ .pybuilder/
77
+ target/
78
+
79
+ # Jupyter Notebook
80
+ .ipynb_checkpoints
81
+
82
+ # IPython
83
+ profile_default/
84
+ ipython_config.py
85
+
86
+ # pyenv
87
+ # For a library or package, you might want to ignore these files since the code is
88
+ # intended to run in multiple environments; otherwise, check them in:
89
+ # .python-version
90
+
91
+ # pipenv
92
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
94
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
95
+ # install all needed dependencies.
96
+ # Pipfile.lock
97
+
98
+ # UV
99
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
100
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
101
+ # commonly ignored for libraries.
102
+ # uv.lock
103
+
104
+ # poetry
105
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
106
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
107
+ # commonly ignored for libraries.
108
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
109
+ # poetry.lock
110
+ # poetry.toml
111
+
112
+ # pdm
113
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
114
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
115
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
116
+ # pdm.lock
117
+ # pdm.toml
118
+ .pdm-python
119
+ .pdm-build/
120
+
121
+ # pixi
122
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
123
+ # pixi.lock
124
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
125
+ # in the .venv directory. It is recommended not to include this directory in version control.
126
+ .pixi/*
127
+ !.pixi/config.toml
128
+
129
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
130
+ __pypackages__/
131
+
132
+ # Celery stuff
133
+ celerybeat-schedule*
134
+ celerybeat.pid
135
+
136
+ # Redis
137
+ *.rdb
138
+ *.aof
139
+ *.pid
140
+
141
+ # RabbitMQ
142
+ mnesia/
143
+ rabbitmq/
144
+ rabbitmq-data/
145
+
146
+ # ActiveMQ
147
+ activemq-data/
148
+
149
+ # SageMath parsed files
150
+ *.sage.py
151
+
152
+ # Environments
153
+ .env
154
+ .envrc
155
+ .venv
156
+ env/
157
+ venv/
158
+ ENV/
159
+ env.bak/
160
+ venv.bak/
161
+
162
+ # Spyder project settings
163
+ .spyderproject
164
+ .spyproject
165
+
166
+ # Rope project settings
167
+ .ropeproject
168
+
169
+ # mkdocs documentation
170
+ /site
171
+
172
+ # mypy
173
+ .mypy_cache/
174
+ .dmypy.json
175
+ dmypy.json
176
+
177
+ # Pyre type checker
178
+ .pyre/
179
+
180
+ # pytype static type analyzer
181
+ .pytype/
182
+
183
+ # Cython debug symbols
184
+ cython_debug/
185
+
186
+ # PyCharm
187
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
188
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
189
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
190
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
191
+ # .idea/
192
+
193
+ # Abstra
194
+ # Abstra is an AI-powered process automation framework.
195
+ # Ignore directories containing user credentials, local state, and settings.
196
+ # Learn more at https://abstra.io/docs
197
+ .abstra/
198
+
199
+ # Visual Studio Code
200
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
201
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
202
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
203
+ # you could uncomment the following to ignore the entire vscode folder
204
+ # .vscode/
205
+ # Temporary file for partial code execution
206
+ tempCodeRunnerFile.py
207
+
208
+ # Ruff stuff:
209
+ .ruff_cache/
210
+
211
+ # PyPI configuration file
212
+ .pypirc
213
+
214
+ # Marimo
215
+ marimo/_static/
216
+ marimo/_lsp/
217
+ __marimo__/
218
+
219
+ # Streamlit
220
+ .streamlit/secrets.toml
221
+
222
+ # Mac File Management
223
+ .DS_Store
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Dominik Magiera
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,48 @@
1
+ Metadata-Version: 2.4
2
+ Name: wampy-prolog
3
+ Version: 0.1.0
4
+ Summary: A Numba-accelerated Warren Abstract Machine implementation for Prolog.
5
+ Project-URL: Homepage, https://github.com/cognitive-modeling/WAMpy
6
+ Project-URL: Issues, https://github.com/cognitive-modeling/WAMpy/issues
7
+ Project-URL: Repository, https://github.com/cognitive-modeling/WAMpy
8
+ Author: Dominik Magiera, Lukas Roehrig, Frank Jaekel
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: cognitive science,computational cognitive modeling,simulation,working memory
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Scientific/Engineering
16
+ Requires-Python: >=3.11
17
+ Requires-Dist: numba
18
+ Requires-Dist: numba-toolbox
19
+ Requires-Dist: numpy
20
+ Provides-Extra: dev
21
+ Requires-Dist: pytest; extra == 'dev'
22
+ Provides-Extra: prolog
23
+ Requires-Dist: janus-swi; extra == 'prolog'
24
+ Description-Content-Type: text/markdown
25
+
26
+ # WAMpy
27
+
28
+ ## Installation
29
+
30
+ ```console
31
+ pip install wampy-prolog
32
+ ```
33
+ ### Usage.
34
+
35
+ WAMpy is used as a Python library rather than as a standalone Prolog interpreter.
36
+
37
+ ```
38
+ import wampy as wam
39
+ ast_program, symbol_table = wam.parse("parent(anakin, luke).")
40
+ compiled = wam.compile(ast_program)
41
+ wam.query_from_str(compiled, "parent(X, luke).", symbol_table)
42
+ ```
43
+
44
+ ## Limitations
45
+
46
+ The current implementation provides an X-register subset of the WAM supporting atoms, variables, compound structures, predicate calls, tail calls, unification, and linear clause backtracking.
47
+ It omits standard environment and Y-register instructions, native list operations, clause-indexing instructions, and canonical user-level cut support.
48
+ WAMpy also does not provide the general SWI-Prolog built-in predicate library such as arithmetic, and meta-calls.
@@ -0,0 +1,23 @@
1
+ # WAMpy
2
+
3
+ ## Installation
4
+
5
+ ```console
6
+ pip install wampy-prolog
7
+ ```
8
+ ### Usage.
9
+
10
+ WAMpy is used as a Python library rather than as a standalone Prolog interpreter.
11
+
12
+ ```
13
+ import wampy as wam
14
+ ast_program, symbol_table = wam.parse("parent(anakin, luke).")
15
+ compiled = wam.compile(ast_program)
16
+ wam.query_from_str(compiled, "parent(X, luke).", symbol_table)
17
+ ```
18
+
19
+ ## Limitations
20
+
21
+ The current implementation provides an X-register subset of the WAM supporting atoms, variables, compound structures, predicate calls, tail calls, unification, and linear clause backtracking.
22
+ It omits standard environment and Y-register instructions, native list operations, clause-indexing instructions, and canonical user-level cut support.
23
+ WAMpy also does not provide the general SWI-Prolog built-in predicate library such as arithmetic, and meta-calls.