Handle sort parameters correctly in JSON Kast format#4913
Merged
Conversation
…_{kast,manip}: bump KAST version 3→4, emit structured KSort params
KSort nodes previously encoded sort parameters in the name string
(e.g. "MInt{Width}"), requiring Outer.parseSort on the Java side to
reconstruct the structured Sort. Now ToJson emits a separate "params"
array alongside the base "name", matching the Scala Sort ADT directly.
JsonParser.toSort gains a legacy fallback for v3 JSON (no "params" key).
Python KSort gains a params field; KSort.from_dict and AnyType._freeze
both handle the old encoded-name format for backward compatibility when
reading pre-v4 JSON (e.g. the prelude-modules.json fixture).
prelude-modules.json is regenerated with the new structured format.
test_kast and test_manip are updated to reflect the new KSort repr.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…Kore emission, un-skip test
sort_decl_to_kore now emits canonical sort variables (SortS0, SortS1, ...)
for sorts with parameters (e.g. syntax MInt{Width} → hooked-sort SortMInt{SortS0}).
_sort_app now recursively converts sort params, threading the production context
so that sort variables (params in production.params) correctly become SortVar
in sort applications (e.g. SortMInt{SortWidth} in a symbol with {Width} param).
_no_junk_axioms skips parameterized sorts — Java does not generate no-junk
axioms for them.
All 7 test_module_to_kore cases now pass; @pytest.mark.skip removed.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…migrate fixtures to KAST v4 The v3-format backward compat paths in KSort.from_dict, AnyType._freeze, and JsonParser.toSort are not reachable in normal use: both Python (kast_term) and Java (JsonParser.parse) reject any JSON whose version field != 4. The only remaining v3 JSON was in the profiling test fixtures, which are now migrated to v4 format via a direct JSON node walk. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ehildenb
commented
Apr 24, 2026
ehildenb
commented
Apr 24, 2026
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
tothtamas28
approved these changes
Apr 27, 2026
Contributor
|
Probably fixes #3477 as well. |
…rt declarations
Instead of generating canonical indexed names (SortS0, SortS1, …) for
sort-declaration variables, use the original names carried in the KAST
params (e.g. SortWidth for MInt{Width}). This aligns the sort-declaration
variable names with those already used in production symbols, whereas the
Java Kore backend inconsistently uses SortS{i} in declarations but the
original names in productions.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
pyk now preserves original K source names (e.g. SortWidth for MInt{Width})
in sort declarations, while the Java backend emits canonical SortS{i} names.
Sort-declaration variable names are locally bound so only arity matters;
normalize both sides to SortS{i} before the text comparison.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
dkcumming
pushed a commit
that referenced
this pull request
Apr 30, 2026
Fixes: #4653 Fixes: #3477 This adds explicit support for sort parameters in the JSON Kast format emitted/read by the Java and Python frontends. In particular: - Update Java and Python KAST JSON (de)serialization to include sort parameters structurally, and bump the KAST format version identifier. - Handle the sort parameters correctly in `_module_to_kore` in Python. - Unskip the `_module_to_kore` test that was skipped because of this. - Update some test output that changes because of hash-mismatches because of the new structure. --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #4653
Fixes: #3477
This adds explicit support for sort parameters in the JSON Kast format emitted/read by the Java and Python frontends. In particular:
_module_to_korein Python._module_to_koretest that was skipped because of this.