Duplicate rules and sentences in compiled output
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Domain
- compilers
Research direction
Start with the supplied test.k definition and run kompile test.k, then inspect test-kompiled/compiled.txt and compare the repeated isK sentence across imported modules such as KSEQ and KSEQ-SYMBOLIC. Trace where imported sentences and sort predicates enter the compiled output; done means duplicate predicates are reduced without changing the resulting definitions.
Written by the indexing model from the issue text.
Description
Using the following definition:
module TEST
imports BOOL
imports INT
configuration <k> $PGM:Pgm </k>
syntax Pgm ::= Bool | Int
endmodule
module TEST-SYMBOLIC [kore, symbolic]
imports TEST
rule A andBool B => B andBool A [simplification]
endmodule
module TEST-LLVM [symbolic]
imports TEST-SYMBOLIC
endmodule
I call kompile test.k, to get output test-kompiled/compiled.txt.
Then I search for a rule that looks like this (the isK sort predicate):
rule isK(K)=>#token("true","Bool") requires #token("true","Bool") ensures #token("true","Bool") [UNIQUE_ID(16ff77cff0ef50026a8b3f4614b87bda465701918596b7ad2280baffff56f847)]
And find that there are 50 occurrences of the same rule! This is not the only sort predicate with many duplicate occurrences.
Can we eliminate these duplicates by:
- Having the compiler do something about it? Like factor out the sort predicates into their own module that is imported where it's needed?
- Refactoring our prelude/import structure a bit so that commonly duplicated sorts like
KandKItemandListare declared early so their sort predicates only occur once? - Note that we have an instance where module
KSEQdeclares theisKpredicate, and moduleKSEQ-SYMBOLICimportsKSEQbut still also redeclares this sort predicate! So maybe there is a way to minimize the number of sentences directly already by not regenerating sort predicates if they already exist in imported modules.
Example from compiled.txt (snipped):
module KSEQ
imports KAST
imports K-TOP-SORT
syntax {Sort} Sort ::= "(" Sort ")" [applyPriority(1), bracket, bracketLabel((_)_KSEQ_Sort_Sort{Sort}), defaultBracket]
syntax associativity left #KSequence [org.kframework.attributes.Location(Location(104,3,104,25)), org.kframework.attributes.Source(Source(/nix/store/hdn1n6x3lclacnv59xc8wzmgravia6jw-k-6.1.77-18ce58892d77b05f8aa5
syntax associativity left #KSequence
syntax K ::= K "~>" K [assoc, klabel(#KSequence), left, symbol, unit(#EmptyK)]
syntax K ::= ".K" [klabel(#EmptyK), symbol, unparseAvoid]
syntax K ::= ".::K" [klabel(#EmptyK), symbol, unparseAvoid]
syntax K ::= "." [klabel(#EmptyK), symbol]
...
rule isK(K)=>#token("true","Bool") requires #token("true","Bool") ensures #token("true","Bool") [UNIQUE_ID(16ff77cff0ef50026a8b3f4614b87bda465701918596b7ad2280baffff56f847)]
...
endmodule
module KSEQ-SYMBOLIC
imports ML-SYNTAX
imports KVARIABLE-SYNTAX
imports KSEQ
syntax KConfigVar ::= r"(?<![A-Za-z0-9_\\$!\\?@])(\\$)([A-Z][A-Za-z0-9'_]*)" [token]
syntax KBott ::= KConfigVar
syntax KBott ::= #KVariable
syntax #KVariable ::= r"(?<![A-Za-z0-9_\\$!\\?@])(\\!|\\?|@)?([A-Z][A-Za-z0-9'_]*|_|_[A-Z][A-Za-z0-9'_]*)" [prec(1), token]
syntax #KVariable ::= #UpperId [token]
...
rule isK(K)=>#token("true","Bool") requires #token("true","Bool") ensures #token("true","Bool") [UNIQUE_ID(16ff77cff0ef50026a8b3f4614b87bda465701918596b7ad2280baffff56f847)]
...
endmodule
- Dominant language
- Python
- Stars
- 591
- Forks
- 163
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from runtimeverification/k
-
runtimeverification/k#4939 · 1 assignee ·
-
Concolic Explorer Open
Difficulty 5/5 Over a week Newbie friendliness 32/100
runtimeverification/k#4937 ·
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
runtimeverification/k#4936 ·
-
type:epic
runtimeverification/k#4934 · 4 comments · 1 assignee ·
-
runtimeverification/k#4924 · 1 assignee ·
All issues in runtimeverification/k
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bancolombia/sentinel#23 ·
-
test md OpenCI
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100