runtimeverification / runtimeverification/mir-semantics
Refactor IntrinsicFunction handling to align with stable-mir-json and existing development patterns
Open
@Stevengre is already working on this.
Since Aug 26, 2025.
refactor
- Dominant language
- Python
- Stars
- 52
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
The current implementation of IntrinsicFunction in mono.md deviates from our established patterns for modeling JSON contents in K sorts. This issue tracks the technical debt introduced in PR #659 to enable intrinsic function support, which we're accepting temporarily to unblock development.
Current Issues
- Inconsistent Symbol Naming Convention
- The IntrinsicFunction constructor lacks the MonoItemKind:: prefix that other constructors use
- Current: IntrinsicFunction(Symbol)
- Expected: MonoItemKind::IntrinsicFunction(Symbol) or similar - Deviation from JSON Modeling Pattern
- Previously, all sorts used by kmir-ast.md were directly present in the JSON
- IntrinsicFunction introduces a K-specific constructor that doesn't directly correspond to the JSON structure
- This breaks the 1:1 mapping between stable-mir-json output and K sorts
Proposed Solution
Consider refactoring to use a different sort structure that better separates concerns:
- Create distinct constructors like Function(Symbol, Body) and Intrinsic(Symbol) in the runtime function table. This would maintain the JSON modeling integrity while still supporting intrinsic functions
- Don't tightly couple stable-mir-json and kmir, but rather let stable-mir-json focus on extracting all useful MIR information, while kmir focuses on formal semantics. The connection between stable-mir-json and kmir can also be accomplished through a tool.
Context
- Related PR: #659 (initial intrinsic function support)
- Related stable-mir-json PR: runtimeverification/stable-mir-json#85
- Affected files:
- kmir/src/kmir/kdist/mir-semantics/mono.md:37
- kmir/src/kmir/kmir.py (function map generation)
- kmir/src/kmir/kdist/mir-semantics/kmir.md (intrinsic execution rules)
Notes
This refactoring should be done after:
- The relationship between kmir and stable-mir-json is better defined
- Any broader kmir refactoring efforts are completed
- The stable-mir-json intrinsics PR is merged and stabilized
Contributor guide
No contributing guide indexed for this repository
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.
Assessment
This issue has not been assessed yet.