Consolidate special collection attributes

Open
#3,933 1 comment 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
Refactor
Clarity
Needs clarification
Activity status
Stale
Tech stack
java
Domain
compilers

Research direction

Read kernel/src/main/java/org/kframework/backend/kore/ModuleToKORE.java at the special-sort handling and attribute extraction, then compare the corresponding declarations in k-distribution/include/kframework/builtin/domains.md. Decide on a single representation for collection attributes and ensure generated KORE declarations include the required concat, element, unit, and hook metadata exactly for special collection sorts.

Written by the indexing model from the issue text.

Description

Module-to-KORE conversion defines a few special collection sorts:

SET.Set
MAP.Map
LIST.List
ARRAY.Array
RANGEMAP.RangeMap

When generating the KORE declarations for these sorts, a few special attributes are included:

hooked-sort SortSet{} [
  concat{}(Lbl'Unds'Set'Unds'{}()),
  element{}(LblSetItem{}()), hook{}("SET.Set"),
  unit{}(Lbl'Stop'Set{}()),
  ...
]

The source of these attributes is the corresponding concat production: https://github.com/runtimeverification/k/blob/7d5882aa7a28139cb733bfadedf36794a360a60b/k-distribution/include/kframework/builtin/domains.md?plain=1#L721

In particular, concat is taken from the klabel, whereas element and unit are taken from the respective K attribute (source).


There are two approaches this for improving on this.

  1. A single multiary attribute on the concat production
syntax Set ::= Set Set [concat(SetItem, .Set)]
  1. A family of nullary attributes, each on the corresponding production
syntax Set [collection]  // When this is defined, the corresponding productions are checked for existence and well-sortedness
syntax Set ::= Set Set        [concat]
syntax Set ::= SetItem(KItem) [element]
syntax Set ::= ".Set"         [unit]

If collections require special handling on the backend, then it should also be ensured that the corresponding attributes are included exactly on the special collection sorts.

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.