simasm 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 (72) hide show
  1. simasm-0.1.0/LICENSE +21 -0
  2. simasm-0.1.0/PKG-INFO +207 -0
  3. simasm-0.1.0/README.md +170 -0
  4. simasm-0.1.0/pyproject.toml +65 -0
  5. simasm-0.1.0/setup.cfg +4 -0
  6. simasm-0.1.0/simasm/__init__.py +45 -0
  7. simasm-0.1.0/simasm/config/__init__.py +7 -0
  8. simasm-0.1.0/simasm/config/file_config.py +59 -0
  9. simasm-0.1.0/simasm/core/__init__.py +51 -0
  10. simasm-0.1.0/simasm/core/rules.py +1094 -0
  11. simasm-0.1.0/simasm/core/state.py +549 -0
  12. simasm-0.1.0/simasm/core/terms.py +757 -0
  13. simasm-0.1.0/simasm/core/types.py +161 -0
  14. simasm-0.1.0/simasm/core/update.py +262 -0
  15. simasm-0.1.0/simasm/experimenter/__init__.py +92 -0
  16. simasm-0.1.0/simasm/experimenter/ast.py +227 -0
  17. simasm-0.1.0/simasm/experimenter/cli.py +982 -0
  18. simasm-0.1.0/simasm/experimenter/engine.py +1164 -0
  19. simasm-0.1.0/simasm/experimenter/grammar.lark +169 -0
  20. simasm-0.1.0/simasm/experimenter/transformer.py +609 -0
  21. simasm-0.1.0/simasm/input/__init__.py +0 -0
  22. simasm-0.1.0/simasm/jupyter/__init__.py +37 -0
  23. simasm-0.1.0/simasm/jupyter/magic.py +509 -0
  24. simasm-0.1.0/simasm/log/__init__.py +7 -0
  25. simasm-0.1.0/simasm/log/logger.py +218 -0
  26. simasm-0.1.0/simasm/output/__init__.py +0 -0
  27. simasm-0.1.0/simasm/parser/__init__.py +66 -0
  28. simasm-0.1.0/simasm/parser/ast.py +321 -0
  29. simasm-0.1.0/simasm/parser/grammar.lark +247 -0
  30. simasm-0.1.0/simasm/parser/loader.py +414 -0
  31. simasm-0.1.0/simasm/parser/parser.py +175 -0
  32. simasm-0.1.0/simasm/parser/transformer.py +575 -0
  33. simasm-0.1.0/simasm/runtime/__init__.py +39 -0
  34. simasm-0.1.0/simasm/runtime/random.py +543 -0
  35. simasm-0.1.0/simasm/runtime/stdlib.py +483 -0
  36. simasm-0.1.0/simasm/runtime/stepper.py +464 -0
  37. simasm-0.1.0/simasm/simulation/__init__.py +110 -0
  38. simasm-0.1.0/simasm/simulation/collector.py +554 -0
  39. simasm-0.1.0/simasm/simulation/config.py +314 -0
  40. simasm-0.1.0/simasm/simulation/output.py +637 -0
  41. simasm-0.1.0/simasm/simulation/runner.py +699 -0
  42. simasm-0.1.0/simasm/simulation/statistics.py +776 -0
  43. simasm-0.1.0/simasm/verification/__init__.py +157 -0
  44. simasm-0.1.0/simasm/verification/kinduction.py +684 -0
  45. simasm-0.1.0/simasm/verification/label.py +425 -0
  46. simasm-0.1.0/simasm/verification/phase.py +499 -0
  47. simasm-0.1.0/simasm/verification/product.py +780 -0
  48. simasm-0.1.0/simasm/verification/run_verification.py +312 -0
  49. simasm-0.1.0/simasm/verification/trace.py +589 -0
  50. simasm-0.1.0/simasm/verification/ts.py +413 -0
  51. simasm-0.1.0/simasm.egg-info/PKG-INFO +207 -0
  52. simasm-0.1.0/simasm.egg-info/SOURCES.txt +70 -0
  53. simasm-0.1.0/simasm.egg-info/dependency_links.txt +1 -0
  54. simasm-0.1.0/simasm.egg-info/requires.txt +13 -0
  55. simasm-0.1.0/simasm.egg-info/top_level.txt +1 -0
  56. simasm-0.1.0/test/test_001_types_v1.py +334 -0
  57. simasm-0.1.0/test/test_002_state_v1.py +534 -0
  58. simasm-0.1.0/test/test_003_asmstate_v1.py +645 -0
  59. simasm-0.1.0/test/test_004_update_v1.py +721 -0
  60. simasm-0.1.0/test/test_005_terms_v1.py +911 -0
  61. simasm-0.1.0/test/test_006_rules_v1.py +1622 -0
  62. simasm-0.1.0/test/test_007_stdlib_v1.py +713 -0
  63. simasm-0.1.0/test/test_008_random_v1.py +705 -0
  64. simasm-0.1.0/test/test_009_stepper_v1.py +686 -0
  65. simasm-0.1.0/test/test_010_grammar_expr_v1.py +365 -0
  66. simasm-0.1.0/test/test_011_grammar_stmt_v1.py +342 -0
  67. simasm-0.1.0/test/test_012_grammar_decl_v1.py +355 -0
  68. simasm-0.1.0/test/test_013_transform_expr_v1.py +304 -0
  69. simasm-0.1.0/test/test_014_transform_stmt_v1.py +321 -0
  70. simasm-0.1.0/test/test_015_transform_decl_v1.py +349 -0
  71. simasm-0.1.0/test/test_016_parser_api_v1.py +334 -0
  72. simasm-0.1.0/test/test_017_loader_v1.py +431 -0
simasm-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Steve Yeo
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.
simasm-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,207 @@
1
+ Metadata-Version: 2.2
2
+ Name: simasm
3
+ Version: 0.1.0
4
+ Summary: Abstract State Machine Framework for Discrete Event Simulation
5
+ Author: Steve
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/stevenaeola/simasm
8
+ Project-URL: Documentation, https://github.com/stevenaeola/simasm#readme
9
+ Project-URL: Repository, https://github.com/stevenaeola/simasm
10
+ Project-URL: Issues, https://github.com/stevenaeola/simasm/issues
11
+ Keywords: simulation,discrete-event,state-machine,verification,event-graph,activity-cycle-diagram,stutter-equivalence
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Scientific/Engineering
22
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
23
+ Classifier: Topic :: Software Development :: Interpreters
24
+ Requires-Python: >=3.9
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: lark>=1.1.0
28
+ Provides-Extra: jupyter
29
+ Requires-Dist: ipython>=7.0; extra == "jupyter"
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest>=7.0; extra == "dev"
32
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
33
+ Requires-Dist: build>=1.0; extra == "dev"
34
+ Requires-Dist: twine>=4.0; extra == "dev"
35
+ Provides-Extra: all
36
+ Requires-Dist: simasm[dev,jupyter]; extra == "all"
37
+
38
+ # SimASM
39
+
40
+ **Abstract State Machine Framework for Discrete Event Simulation**
41
+
42
+ SimASM is a Python package for modeling, simulating, and verifying discrete event systems using Abstract State Machines (ASM) as a common semantic foundation.
43
+
44
+ ## Features
45
+
46
+ - **DSL for Simulation Models**: Write discrete event simulation models in a clean, readable syntax
47
+ - **Multiple Formalisms**: Support for Event Graph and Activity Cycle Diagram modeling styles
48
+ - **Stutter Equivalence Verification**: Formally verify that two models produce equivalent observable behavior
49
+ - **Jupyter Integration**: Interactive modeling with `%%simasm` magic commands
50
+ - **Statistics Collection**: Built-in support for time-average, utilization, and count statistics
51
+
52
+ ## Installation
53
+
54
+ ```bash
55
+ pip install simasm
56
+ ```
57
+
58
+ For Jupyter support:
59
+ ```bash
60
+ pip install simasm[jupyter]
61
+ ```
62
+
63
+ ## Quick Start
64
+
65
+ ### In Jupyter/Colab
66
+
67
+ ```python
68
+ import simasm # Auto-registers %%simasm magic
69
+ ```
70
+
71
+ Define a model:
72
+ ```
73
+ %%simasm model --name mm1_queue
74
+ domain Event
75
+ domain Load
76
+
77
+ var sim_clocktime: Real
78
+ var queue: List<Load>
79
+
80
+ // ... model definition
81
+ ```
82
+
83
+ Run an experiment:
84
+ ```
85
+ %%simasm experiment
86
+ experiment MyExperiment:
87
+ model := "mm1_queue"
88
+
89
+ replication:
90
+ count: 10
91
+ warm_up_time: 100.0
92
+ run_length: 1000.0
93
+ endreplication
94
+
95
+ statistics:
96
+ stat AvgQueueLength: time_average
97
+ expression: "lib.length(queue)"
98
+ endstat
99
+ endstatistics
100
+ endexperiment
101
+ ```
102
+
103
+ ### From Python
104
+
105
+ ```python
106
+ from simasm.experimenter.engine import ExperimenterEngine
107
+
108
+ # Run an experiment
109
+ engine = ExperimenterEngine("experiments/my_experiment.simasm")
110
+ result = engine.run()
111
+
112
+ print(f"Average queue length: {result['L_queue']}")
113
+ ```
114
+
115
+ ## Model Syntax
116
+
117
+ SimASM uses a domain-specific language for defining simulation models:
118
+
119
+ ```simasm
120
+ // Domain declarations
121
+ domain Load
122
+ domain Server
123
+
124
+ // Constants and variables
125
+ const server: Server
126
+ var sim_clocktime: Real
127
+ var queue: List<Load>
128
+
129
+ // Random stream variables
130
+ var interarrival_time: rnd.exponential(1.25) as "arrivals"
131
+ var service_time: rnd.exponential(1.0) as "service"
132
+
133
+ // Rules
134
+ rule arrive() =
135
+ let load = new Load
136
+ lib.add(queue, load)
137
+ // Schedule next arrival
138
+ endrule
139
+
140
+ // Main rule
141
+ main rule main =
142
+ if sim_clocktime < sim_end_time then
143
+ run_routine()
144
+ endif
145
+ endrule
146
+
147
+ // Initial state
148
+ init:
149
+ sim_clocktime := 0.0
150
+ queue := []
151
+ endinit
152
+ ```
153
+
154
+ ## Verification
155
+
156
+ SimASM can verify stutter equivalence between two models:
157
+
158
+ ```
159
+ %%simasm verify
160
+ verification EG_vs_ACD:
161
+ models:
162
+ import EG from "event_graph_model.simasm"
163
+ import ACD from "acd_model.simasm"
164
+ endmodels
165
+
166
+ seed: 42
167
+
168
+ labels:
169
+ label queue_empty for EG: "queue_count() == 0"
170
+ label queue_empty for ACD: "queue_count() == 0"
171
+ endlabels
172
+
173
+ observables:
174
+ observable queue_empty:
175
+ EG -> queue_empty
176
+ ACD -> queue_empty
177
+ endobservable
178
+ endobservables
179
+
180
+ check:
181
+ type: stutter_equivalence
182
+ run_length: 1000.0
183
+ endcheck
184
+ endverification
185
+ ```
186
+
187
+ ## Documentation
188
+
189
+ - [Full Documentation](https://github.com/yourusername/simasm)
190
+ - [Examples](https://github.com/yourusername/simasm/tree/main/examples)
191
+
192
+ ## License
193
+
194
+ MIT License - see [LICENSE](LICENSE) for details.
195
+
196
+ ## Citation
197
+
198
+ If you use SimASM in your research, please cite:
199
+
200
+ ```bibtex
201
+ @software{simasm,
202
+ title = {SimASM: Abstract State Machine Framework for Discrete Event Simulation},
203
+ author = {Steve},
204
+ year = {2024},
205
+ url = {https://github.com/yourusername/simasm}
206
+ }
207
+ ```
simasm-0.1.0/README.md ADDED
@@ -0,0 +1,170 @@
1
+ # SimASM
2
+
3
+ **Abstract State Machine Framework for Discrete Event Simulation**
4
+
5
+ SimASM is a Python package for modeling, simulating, and verifying discrete event systems using Abstract State Machines (ASM) as a common semantic foundation.
6
+
7
+ ## Features
8
+
9
+ - **DSL for Simulation Models**: Write discrete event simulation models in a clean, readable syntax
10
+ - **Multiple Formalisms**: Support for Event Graph and Activity Cycle Diagram modeling styles
11
+ - **Stutter Equivalence Verification**: Formally verify that two models produce equivalent observable behavior
12
+ - **Jupyter Integration**: Interactive modeling with `%%simasm` magic commands
13
+ - **Statistics Collection**: Built-in support for time-average, utilization, and count statistics
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ pip install simasm
19
+ ```
20
+
21
+ For Jupyter support:
22
+ ```bash
23
+ pip install simasm[jupyter]
24
+ ```
25
+
26
+ ## Quick Start
27
+
28
+ ### In Jupyter/Colab
29
+
30
+ ```python
31
+ import simasm # Auto-registers %%simasm magic
32
+ ```
33
+
34
+ Define a model:
35
+ ```
36
+ %%simasm model --name mm1_queue
37
+ domain Event
38
+ domain Load
39
+
40
+ var sim_clocktime: Real
41
+ var queue: List<Load>
42
+
43
+ // ... model definition
44
+ ```
45
+
46
+ Run an experiment:
47
+ ```
48
+ %%simasm experiment
49
+ experiment MyExperiment:
50
+ model := "mm1_queue"
51
+
52
+ replication:
53
+ count: 10
54
+ warm_up_time: 100.0
55
+ run_length: 1000.0
56
+ endreplication
57
+
58
+ statistics:
59
+ stat AvgQueueLength: time_average
60
+ expression: "lib.length(queue)"
61
+ endstat
62
+ endstatistics
63
+ endexperiment
64
+ ```
65
+
66
+ ### From Python
67
+
68
+ ```python
69
+ from simasm.experimenter.engine import ExperimenterEngine
70
+
71
+ # Run an experiment
72
+ engine = ExperimenterEngine("experiments/my_experiment.simasm")
73
+ result = engine.run()
74
+
75
+ print(f"Average queue length: {result['L_queue']}")
76
+ ```
77
+
78
+ ## Model Syntax
79
+
80
+ SimASM uses a domain-specific language for defining simulation models:
81
+
82
+ ```simasm
83
+ // Domain declarations
84
+ domain Load
85
+ domain Server
86
+
87
+ // Constants and variables
88
+ const server: Server
89
+ var sim_clocktime: Real
90
+ var queue: List<Load>
91
+
92
+ // Random stream variables
93
+ var interarrival_time: rnd.exponential(1.25) as "arrivals"
94
+ var service_time: rnd.exponential(1.0) as "service"
95
+
96
+ // Rules
97
+ rule arrive() =
98
+ let load = new Load
99
+ lib.add(queue, load)
100
+ // Schedule next arrival
101
+ endrule
102
+
103
+ // Main rule
104
+ main rule main =
105
+ if sim_clocktime < sim_end_time then
106
+ run_routine()
107
+ endif
108
+ endrule
109
+
110
+ // Initial state
111
+ init:
112
+ sim_clocktime := 0.0
113
+ queue := []
114
+ endinit
115
+ ```
116
+
117
+ ## Verification
118
+
119
+ SimASM can verify stutter equivalence between two models:
120
+
121
+ ```
122
+ %%simasm verify
123
+ verification EG_vs_ACD:
124
+ models:
125
+ import EG from "event_graph_model.simasm"
126
+ import ACD from "acd_model.simasm"
127
+ endmodels
128
+
129
+ seed: 42
130
+
131
+ labels:
132
+ label queue_empty for EG: "queue_count() == 0"
133
+ label queue_empty for ACD: "queue_count() == 0"
134
+ endlabels
135
+
136
+ observables:
137
+ observable queue_empty:
138
+ EG -> queue_empty
139
+ ACD -> queue_empty
140
+ endobservable
141
+ endobservables
142
+
143
+ check:
144
+ type: stutter_equivalence
145
+ run_length: 1000.0
146
+ endcheck
147
+ endverification
148
+ ```
149
+
150
+ ## Documentation
151
+
152
+ - [Full Documentation](https://github.com/yourusername/simasm)
153
+ - [Examples](https://github.com/yourusername/simasm/tree/main/examples)
154
+
155
+ ## License
156
+
157
+ MIT License - see [LICENSE](LICENSE) for details.
158
+
159
+ ## Citation
160
+
161
+ If you use SimASM in your research, please cite:
162
+
163
+ ```bibtex
164
+ @software{simasm,
165
+ title = {SimASM: Abstract State Machine Framework for Discrete Event Simulation},
166
+ author = {Steve},
167
+ year = {2024},
168
+ url = {https://github.com/yourusername/simasm}
169
+ }
170
+ ```
@@ -0,0 +1,65 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0,<77.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "simasm"
7
+ version = "0.1.0"
8
+ description = "Abstract State Machine Framework for Discrete Event Simulation"
9
+ readme = "README.md"
10
+ license = {text = "MIT"}
11
+ authors = [
12
+ {name = "Steve"}
13
+ ]
14
+ requires-python = ">=3.9"
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Intended Audience :: Science/Research",
18
+ "Intended Audience :: Developers",
19
+ "Operating System :: OS Independent",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.9",
22
+ "Programming Language :: Python :: 3.10",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Topic :: Scientific/Engineering",
26
+ "Topic :: Scientific/Engineering :: Mathematics",
27
+ "Topic :: Software Development :: Interpreters",
28
+ ]
29
+ keywords = ["simulation", "discrete-event", "state-machine", "verification", "event-graph", "activity-cycle-diagram", "stutter-equivalence"]
30
+
31
+ dependencies = [
32
+ "lark>=1.1.0",
33
+ ]
34
+
35
+ [project.optional-dependencies]
36
+ jupyter = [
37
+ "ipython>=7.0",
38
+ ]
39
+ dev = [
40
+ "pytest>=7.0",
41
+ "pytest-cov>=4.0",
42
+ "build>=1.0",
43
+ "twine>=4.0",
44
+ ]
45
+ all = [
46
+ "simasm[jupyter,dev]",
47
+ ]
48
+
49
+ [project.urls]
50
+ Homepage = "https://github.com/stevenaeola/simasm"
51
+ Documentation = "https://github.com/stevenaeola/simasm#readme"
52
+ Repository = "https://github.com/stevenaeola/simasm"
53
+ Issues = "https://github.com/stevenaeola/simasm/issues"
54
+
55
+ [tool.setuptools.packages.find]
56
+ where = ["."]
57
+ include = ["simasm*"]
58
+
59
+ [tool.setuptools.package-data]
60
+ simasm = ["parser/*.lark", "experimenter/*.lark"]
61
+
62
+ [tool.pytest.ini_options]
63
+ testpaths = ["test"]
64
+ python_files = ["test_*.py"]
65
+ addopts = "-v"
simasm-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,45 @@
1
+ """
2
+ SimASM - Abstract State Machine Framework for Discrete Event Simulation
3
+
4
+ A Python package for modeling, simulating, and verifying discrete event
5
+ systems using Abstract State Machines as the common semantic foundation.
6
+
7
+ Usage in Jupyter/Colab:
8
+ import simasm # Auto-registers %%simasm magic
9
+
10
+ %%simasm model --name mm1_queue
11
+ domain Event
12
+ ...
13
+
14
+ %%simasm experiment
15
+ experiment Test:
16
+ model := "mm1_queue"
17
+ ...
18
+ endexperiment
19
+
20
+ %%simasm verify
21
+ verification Check:
22
+ ...
23
+ endverification
24
+ """
25
+
26
+ __version__ = "0.1.0"
27
+ __author__ = "Steve"
28
+
29
+
30
+ # Auto-register Jupyter magics when imported in IPython/Jupyter
31
+ def _register_jupyter_magics():
32
+ """Auto-register magics if running in IPython/Jupyter."""
33
+ try:
34
+ from IPython import get_ipython
35
+ ipython = get_ipython()
36
+ if ipython is not None:
37
+ from simasm.jupyter.magic import SimASMMagics
38
+ ipython.register_magics(SimASMMagics)
39
+ except ImportError:
40
+ pass # IPython not installed
41
+ except Exception:
42
+ pass # Not in IPython environment or other error
43
+
44
+
45
+ _register_jupyter_magics()
@@ -0,0 +1,7 @@
1
+ """
2
+ SimASM configuration module.
3
+ """
4
+
5
+ from .file_config import FileConfig
6
+
7
+ __all__ = ['FileConfig']
@@ -0,0 +1,59 @@
1
+ """
2
+ config/file_config.py
3
+
4
+ Centralized file path configuration for SimASM.
5
+ """
6
+
7
+ import os
8
+
9
+ # Project root is one level up from config/
10
+ PROJECT_ROOT = os.path.dirname(os.path.abspath(os.path.join(__file__, '../')))
11
+
12
+
13
+ class FileConfig:
14
+ """
15
+ Central configuration for all file paths in SimASM.
16
+
17
+ Usage:
18
+ from simasm.config.file_config import FileConfig
19
+
20
+ log_file = os.path.join(FileConfig.log_path, 'run.log')
21
+ """
22
+
23
+ # Root path
24
+ root_path = PROJECT_ROOT
25
+
26
+ # Main package paths
27
+ config_path = os.path.join(PROJECT_ROOT, 'config')
28
+ core_path = os.path.join(PROJECT_ROOT, 'core')
29
+ experimenter_path = os.path.join(PROJECT_ROOT, 'experimenter')
30
+ jupyter_path = os.path.join(PROJECT_ROOT, 'jupyter')
31
+ log_path = os.path.join(PROJECT_ROOT, 'log')
32
+ parser_path = os.path.join(PROJECT_ROOT, 'parser')
33
+ runtime_path = os.path.join(PROJECT_ROOT, 'runtime')
34
+ verification_path = os.path.join(PROJECT_ROOT, 'verification')
35
+
36
+ # I/O paths
37
+ input_path = os.path.join(PROJECT_ROOT, 'input')
38
+ output_path = os.path.join(PROJECT_ROOT, 'output')
39
+
40
+ # Test paths (outside main package)
41
+ test_path = os.path.join(os.path.dirname(PROJECT_ROOT), 'test')
42
+ test_input_path = os.path.join(test_path, 'input')
43
+ test_output_path = os.path.join(test_path, 'output')
44
+ test_log_path = os.path.join(test_path, 'log')
45
+
46
+ @classmethod
47
+ def ensure_directories(cls) -> None:
48
+ """Create all directories if they don't exist."""
49
+ directories = [
50
+ cls.log_path,
51
+ cls.input_path,
52
+ cls.output_path,
53
+ cls.test_path,
54
+ cls.test_input_path,
55
+ cls.test_output_path,
56
+ cls.test_log_path,
57
+ ]
58
+ for directory in directories:
59
+ os.makedirs(directory, exist_ok=True)
@@ -0,0 +1,51 @@
1
+ """
2
+ SimASM core module.
3
+
4
+ Contains fundamental ASM constructs:
5
+ - types: Domain and type hierarchy
6
+ - state: ASM state representation
7
+ - update: Update and UpdateSet
8
+ - terms: Term/expression evaluation
9
+ - rules: Rule evaluation
10
+ """
11
+
12
+ from .types import Domain, TypeRegistry, BUILTIN_TYPES
13
+ from .state import UNDEF, Undefined, ASMObject, Location, ASMState
14
+ from .update import Update, UpdateConflictError, UpdateSet
15
+ from .terms import (
16
+ Environment,
17
+ Term, LiteralTerm, VariableTerm, LocationTerm,
18
+ BinaryOpTerm, UnaryOpTerm, ListTerm, TupleTerm, NewTerm,
19
+ LibCallTerm, RndCallTerm, ConditionalTerm,
20
+ TermEvaluator, TermEvaluationError,
21
+ )
22
+ from .rules import (
23
+ Stmt, SkipStmt, UpdateStmt, SeqStmt, IfStmt,
24
+ WhileStmt, ForallStmt, LetStmt, RuleCallStmt, PrintStmt,
25
+ ChooseStmt, ParStmt, LibCallStmt, RndCallStmt,
26
+ RuleDefinition, RuleRegistry,
27
+ RuleEvaluator, RuleEvaluatorConfig,
28
+ RuleEvaluationError, InfiniteLoopError, MaxRecursionError,
29
+ )
30
+
31
+ __all__ = [
32
+ # types
33
+ 'Domain', 'TypeRegistry', 'BUILTIN_TYPES',
34
+ # state
35
+ 'UNDEF', 'Undefined', 'ASMObject', 'Location', 'ASMState',
36
+ # update
37
+ 'Update', 'UpdateConflictError', 'UpdateSet',
38
+ # terms
39
+ 'Environment',
40
+ 'Term', 'LiteralTerm', 'VariableTerm', 'LocationTerm',
41
+ 'BinaryOpTerm', 'UnaryOpTerm', 'ListTerm', 'TupleTerm', 'NewTerm',
42
+ 'LibCallTerm', 'RndCallTerm', 'ConditionalTerm',
43
+ 'TermEvaluator', 'TermEvaluationError',
44
+ # rules
45
+ 'Stmt', 'SkipStmt', 'UpdateStmt', 'SeqStmt', 'IfStmt',
46
+ 'WhileStmt', 'ForallStmt', 'LetStmt', 'RuleCallStmt', 'PrintStmt',
47
+ 'ChooseStmt', 'ParStmt', 'LibCallStmt', 'RndCallStmt',
48
+ 'RuleDefinition', 'RuleRegistry',
49
+ 'RuleEvaluator', 'RuleEvaluatorConfig',
50
+ 'RuleEvaluationError', 'InfiniteLoopError', 'MaxRecursionError',
51
+ ]