Skip to content

Commit 45a0205

Browse files
authored
Added TLC models for all viable specs (#110)
Signed-off-by: Andrew Helwer <[email protected]>
1 parent adccef9 commit 45a0205

File tree

76 files changed

+1321
-100
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+1321
-100
lines changed

.github/scripts/check_markdown_table.py

+2
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ def from_json(spec):
180180
for path, json, md in different_tlc_flag:
181181
print(f'Spec {path} ' + ('incorrectly has' if md else 'is missing') + ' a TLC Model flag in README.md table')
182182

183+
'''
183184
# Ensure Apalache flag is correct
184185
different_apalache_flag = [
185186
(manifest_spec.path, manifest_spec.apalache, table_spec.apalache)
@@ -191,6 +192,7 @@ def from_json(spec):
191192
print('ERROR: Apalache Model flags in README.md table differ from model records in manifest.json:')
192193
for path, json, md in different_tlc_flag:
193194
print(f'Spec {path} ' + ('incorrectly has' if md else 'is missing') + ' an Apalache Model flag in README.md table')
195+
'''
194196

195197
if success:
196198
print('SUCCESS: manifest.json concords with README.md table')

.github/scripts/check_small_models.py

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
parser.add_argument('--community_modules_jar_path', help='Path to the CommunityModules-deps.jar file', required=True)
1818
parser.add_argument('--manifest_path', help='Path to the tlaplus/examples manifest.json file', required=True)
1919
parser.add_argument('--skip', nargs='+', help='Space-separated list of models to skip checking', required=False, default=[])
20+
parser.add_argument('--only', nargs='+', help='If provided, only check models in this space-separated list', required=False, default=[])
2021
args = parser.parse_args()
2122

2223
logging.basicConfig(level=logging.INFO)
@@ -27,6 +28,7 @@
2728
manifest_path = normpath(args.manifest_path)
2829
examples_root = dirname(manifest_path)
2930
skip_models = [normpath(path) for path in args.skip]
31+
only_models = [normpath(path) for path in args.only]
3032

3133
def check_model(module_path, model, expected_runtime):
3234
module_path = tla_utils.from_cwd(examples_root, module_path)
@@ -72,6 +74,7 @@ def check_model(module_path, model, expected_runtime):
7274
for model in module['models']
7375
if model['size'] == 'small'
7476
and normpath(model['path']) not in skip_models
77+
and (only_models == [] or normpath(model['path']) in only_models)
7578
],
7679
key = lambda m: m[2],
7780
reverse=True

.github/scripts/format_markdown_table.py

+15-9
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
parser.add_argument('--readme_path', help='Path to the tlaplus/examples README.md file', required=True)
1717
args = parser.parse_args()
1818

19-
readme = None
20-
with open(normpath(args.readme_path), 'r', encoding='utf-8') as readme_file:
21-
readme = mistletoe.Document(readme_file)
22-
2319
columns = ['name', 'authors', 'beginner', 'proof', 'tlc', 'pcal', 'apalache']
2420

2521
def get_column(row, index):
@@ -64,11 +60,21 @@ def format_table(table):
6460
'''
6561
return
6662

67-
table = next((child for child in readme.children if isinstance(child, Table)))
68-
format_table(table)
63+
def format_document(document):
64+
'''
65+
All document transformations should go here.
66+
'''
67+
# Gets table of local specs
68+
table = next((child for child in document.children if isinstance(child, Table)))
69+
format_table(table)
6970

70-
# Write formatted markdown to README.md
71-
with open(normpath(args.readme_path), 'w', encoding='utf-8') as readme_file:
72-
with MarkdownRenderer() as renderer:
71+
# Read, format, write
72+
# Need to both parse & render within same MarkdownRenderer context to preserve other formatting
73+
with MarkdownRenderer() as renderer:
74+
readme = None
75+
with open(normpath(args.readme_path), 'r', encoding='utf-8') as readme_file:
76+
readme = mistletoe.Document(readme_file)
77+
format_document(readme)
78+
with open(normpath(args.readme_path), 'w', encoding='utf-8') as readme_file:
7379
readme_file.write(renderer.render(readme))
7480

.github/scripts/generate_manifest.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,20 @@ def get_cfg_files(examples_root, tla_path):
5252
Assume a .cfg file in the same directory as the .tla file and with the
5353
same name is a model of that .tla file; also assume this of any .cfg
5454
files where the .tla file name is only a prefix of the .cfg file name,
55-
unless there are other .tla file names in the directory that exactly
56-
match the .cfg file name.
55+
unless there are other .tla file names in the directory that are longer
56+
prefixes of the .cfg file name.
5757
"""
5858
parent_dir = dirname(tla_path)
5959
module_name, _ = splitext(basename(tla_path))
6060
other_module_names = [other for other in get_module_names_in_dir(examples_root, parent_dir) if other != module_name]
6161
return [
62-
path for path in glob.glob(f'{join(parent_dir, module_name)}*.cfg', root_dir=examples_root)
63-
if splitext(basename(path))[0] not in other_module_names
62+
path
63+
for path in glob.glob(f'{join(parent_dir, module_name)}*.cfg', root_dir=examples_root)
64+
if not any([
65+
splitext(basename(path))[0].startswith(other_module_name)
66+
for other_module_name in other_module_names
67+
if len(other_module_name) > len(module_name)
68+
])
6469
]
6570

6671
def generate_new_manifest(examples_root, ignored_dirs, parser, queries):

.github/scripts/tla_utils.py

+1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ def resolve_tlc_exit_code(code):
108108
"""
109109
tlc_exit_codes = {
110110
0 : 'success',
111+
10 : 'assumption failure',
111112
11 : 'deadlock failure',
112113
12 : 'safety failure',
113114
13 : 'liveness failure'

.github/workflows/CI.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ jobs:
2828
shell: bash
2929
steps:
3030
- name: Clone repo
31-
uses: actions/checkout@v3
31+
uses: actions/checkout@v4
3232
- name: Install python
33-
uses: actions/setup-python@v4
33+
uses: actions/setup-python@v5
3434
with:
3535
python-version: '3.11'
3636
- name: Install Java
37-
uses: actions/setup-java@v3
37+
uses: actions/setup-java@v4
3838
with:
3939
distribution: adopt
4040
java-version: 17

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ pyvenv.cfg
3838

3939
## Ignore directories used for local CI testing
4040
deps/
41+
tree-sitter-tlaplus/
4142

4243
# Ignore TTrace specs
4344
*_TTrace_*.tla
4445

4546
## Blacklist tools/ folder created by .devcontainer.json
4647
tools/
48+

0 commit comments

Comments
 (0)