Generalize KAST-to-KORE conversion for KSequence#4874
Merged
automergerpr-permission-manager[bot] merged 5 commits intodevelopfrom Oct 30, 2025
Merged
Generalize KAST-to-KORE conversion for KSequence#4874automergerpr-permission-manager[bot] merged 5 commits intodevelopfrom
KSequence#4874automergerpr-permission-manager[bot] merged 5 commits intodevelopfrom
Conversation
As opposed to the results of `kast_to_kore`, which might be faulty.
tothtamas28
commented
Oct 29, 2025
Comment on lines
+7
to
+9
| kseq-with-k-head | ||
| kseq-with-k-middle | ||
| kseq-with-multiple-ks |
Contributor
Author
There was a problem hiding this comment.
Unfortunately, these need to be excluded from kast tests (similarly to other KSequence tests), because for some reason when converting from json to kore, the result is wrapped in an inj into SortKItem:
% kast --definition /tmp/pytest-of-ttoth/pytest-current/kompiled0/simple-proofs-llvm-0 --input json --output kore --expression '{"format": "KAST", "version": 3, "term": {"node": "KSequence", "items": [{"node": "KToken", "token": "1", "sort": {"node": "KSort", "name": "Int"}}, {"node": "KVariable", "name": "X1", "sort": {"node": "KSort", "name": "K"}}, {"node": "KVariable", "name": "X2", "sort": {"node": "KSort", "name": "K"}}, {"node": "KVariable", "name": "X3", "sort": {"node": "KSort", "name": "K"}}, {"node": "KToken", "token": "2", "sort": {"node": "KSort", "name": "Int"}}, {"node": "KVariable", "name": "X4", "sort": {"node": "KSort", "name": "K"}}], "arity": 6}}' --sort K
inj{SortK{}, SortKItem{}}(kseq{}(inj{SortInt{}, SortKItem{}}(\dv{SortInt{}}("1")),append{}(VarX1:SortK{},append{}(VarX2:SortK{},append{}(VarX3:SortK{},kseq{}(inj{SortInt{}, SortKItem{}}(\dv{SortInt{}}("2")),VarX4:SortK{}))))))Funnily enough, kast is happy to inject the result into any sort (including undefined ones), except for K:
% kast --definition /tmp/pytest-of-ttoth/pytest-current/kompiled0/simple-proofs-llvm-0 --input json --output kore --expression '{"format": "KAST", "version": 3, "term": "..."}' --sort Whatever
inj{SortK{}, SortWhatever{}}(...)For conversion from rule syntax, kast works as expected:
$ kast --definition /tmp/pytest-of-ttoth/pytest-current/kompiled0/simple-proofs-llvm-0 --input rule --output kore --expression '1 ~> X1:K ~> X2:K ~> X3:K ~> 2 ~> X4:K' --sort K
kseq{}(inj{SortInt{}, SortKItem{}}(\dv{SortInt{}}("1")),append{}(VarX1:SortK{},append{}(VarX2:SortK{},append{}(VarX3:SortK{},kseq{}(inj{SortInt{}, SortKItem{}}(\dv{SortInt{}}("2")),VarX4:SortK{})))))%
jberthold
approved these changes
Oct 29, 2025
Member
jberthold
left a comment
There was a problem hiding this comment.
LGTM. Funny behaviour with the KItem injection, though.
660b841
into
develop
20 checks passed
automergerpr-permission-manager bot
pushed a commit
to runtimeverification/mir-semantics
that referenced
this pull request
Oct 30, 2025
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.
Kto appear at any position within aKSequence, not just at the end. During_kast_to_kore, an application ofappendis generated in such cases._kore_to_kast, generate aKSequencefor eachappend.KVariablesort inference so that it does not override declared sorts ofKSequenceitems.test_kast_to_kore_frontendto compare the Frontend’s result against expected outputs, rather thanpyk's results. This makes it easier to add new tests based on the Frontend’s output.