Skip to content

Handle sort parameters correctly in JSON Kast format#4913

Merged
ehildenb merged 9 commits into
developfrom
sort-params-kast
Apr 27, 2026
Merged

Handle sort parameters correctly in JSON Kast format#4913
ehildenb merged 9 commits into
developfrom
sort-params-kast

Conversation

@ehildenb
Copy link
Copy Markdown
Member

@ehildenb ehildenb commented Apr 24, 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.

ehildenb and others added 3 commits April 24, 2026 15:58
…_{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>
@rv-jenkins rv-jenkins changed the base branch from master to develop April 24, 2026 16:00
ehildenb and others added 2 commits April 24, 2026 16:12
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread pyk/src/tests/unit/kast/test_manip.py
Comment thread pyk/src/pyk/konvert/_module_to_kore.py
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ehildenb ehildenb marked this pull request as ready for review April 27, 2026 03:11
@ehildenb ehildenb requested a review from tothtamas28 April 27, 2026 03:11
Comment thread pyk/src/pyk/konvert/_module_to_kore.py
@tothtamas28
Copy link
Copy Markdown
Contributor

Probably fixes #3477 as well.

ehildenb and others added 3 commits April 27, 2026 12:45
…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>
@ehildenb ehildenb merged commit 79fae65 into develop Apr 27, 2026
20 checks passed
@ehildenb ehildenb deleted the sort-params-kast branch April 27, 2026 18:50
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants