runtimeverification / k

K Framework Tools 7.0
BSD 3-Clause "New" or "Revised" License
453 stars 150 forks source link

`UNIQUE_ID`s are not unique #4058

Open tothtamas28 opened 9 months ago

tothtamas28 commented 9 months ago

This has multiple causes, including

A pyk script to list duplicate IDs:

from pyk.kast.outer import read_kast_definition

DEFINITION_DIR = 'kompiled/compiled.json'  # set accordingly

defn = read_kast_definition(DEFINITION_DIR)

rules_by_id = {}
for rule in defn.rules:
    unique_id = rule.att['UNIQUE_ID']
    rules_by_id.setdefault(unique_id, set()).add(rule)

for unique_id, rules in rules_by_id.items():
    if len(rules) > 1:
        print(unique_id)

The rules can then be looked up in compiled.txt by ID.

Baltoli commented 8 months ago

We should codify precisely the semantics of the UNIQUE_ID attribute and make sure that we understand it properly.

gtrepta commented 8 months ago

My understanding is that UNIQUE_ID is meant to be a hash of the rule body/requires and any semantics changing attributes it has. So any two rules that are semantically the same, despite being in different source locations, are supposed to have the same id.