Parametric rules

Open
#1,415 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
haskell
Domain
compilers

Research direction

Read the parametric productions section in pending-documentation.md and inspect the examples in k-distribution/include/kframework/builtin/domains.k. Then trace how the Haskell backend applies the existing equations and determine where parametric rule support belongs. Done means parametric rules work across sort parameters without requiring separate sort-specific rules.

Written by the indexing model from the issue text.

Description

feature parametricity

K supports parametric productions such as this one from domains.k

  syntax {Sort} Sort ::= "#if" Bool "#then" Sort "#else" Sort "#fi"   [function, functional, smt-hook(ite), hook(KEQUAL.ite)]

There is no corresponding way to write parametric rules for parametric productions, so we have rules such as these:

  rule #if C:Bool #then B1::K #else _ #fi => B1 requires C
  rule #if C:Bool #then _ #else B2::K #fi => B2 requires notBool C

which restrict the sort parameter to K. These equations can only be applied by the Haskell backend when the #then and #else expressions are explicitly of sort K.

As a workaround, we can add specific rules for any sort which needs support, for example:

  rule #if C:Bool #then B1::Int #else _ #fi => B1 requires C
  rule #if C:Bool #then _ #else B2::Int #fi => B2 requires notBool C

This workaround quickly becomes tedious, though.

Dominant language
Python
Stars
591
Forks
163
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from runtimeverification/k

All issues in runtimeverification/k

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.