simasm 0.1.0__py3-none-any.whl
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.
- simasm/__init__.py +45 -0
- simasm/config/__init__.py +7 -0
- simasm/config/file_config.py +59 -0
- simasm/core/__init__.py +51 -0
- simasm/core/rules.py +1094 -0
- simasm/core/state.py +549 -0
- simasm/core/terms.py +757 -0
- simasm/core/types.py +161 -0
- simasm/core/update.py +262 -0
- simasm/experimenter/__init__.py +92 -0
- simasm/experimenter/ast.py +227 -0
- simasm/experimenter/cli.py +982 -0
- simasm/experimenter/engine.py +1164 -0
- simasm/experimenter/grammar.lark +169 -0
- simasm/experimenter/transformer.py +609 -0
- simasm/input/__init__.py +0 -0
- simasm/jupyter/__init__.py +37 -0
- simasm/jupyter/magic.py +509 -0
- simasm/log/__init__.py +7 -0
- simasm/log/logger.py +218 -0
- simasm/output/__init__.py +0 -0
- simasm/parser/__init__.py +66 -0
- simasm/parser/ast.py +321 -0
- simasm/parser/grammar.lark +247 -0
- simasm/parser/loader.py +414 -0
- simasm/parser/parser.py +175 -0
- simasm/parser/transformer.py +575 -0
- simasm/runtime/__init__.py +39 -0
- simasm/runtime/random.py +543 -0
- simasm/runtime/stdlib.py +483 -0
- simasm/runtime/stepper.py +464 -0
- simasm/simulation/__init__.py +110 -0
- simasm/simulation/collector.py +554 -0
- simasm/simulation/config.py +314 -0
- simasm/simulation/output.py +637 -0
- simasm/simulation/runner.py +699 -0
- simasm/simulation/statistics.py +776 -0
- simasm/verification/__init__.py +157 -0
- simasm/verification/kinduction.py +684 -0
- simasm/verification/label.py +425 -0
- simasm/verification/phase.py +499 -0
- simasm/verification/product.py +780 -0
- simasm/verification/run_verification.py +312 -0
- simasm/verification/trace.py +589 -0
- simasm/verification/ts.py +413 -0
- simasm-0.1.0.dist-info/LICENSE +21 -0
- simasm-0.1.0.dist-info/METADATA +207 -0
- simasm-0.1.0.dist-info/RECORD +50 -0
- simasm-0.1.0.dist-info/WHEEL +5 -0
- simasm-0.1.0.dist-info/top_level.txt +1 -0
simasm/__init__.py
ADDED
|
@@ -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,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)
|
simasm/core/__init__.py
ADDED
|
@@ -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
|
+
]
|