Skip to content

Axiom set hashing is order-dependent despite docs claiming otherwise #5

@mzargham

Description

@mzargham

Summary

hashing.py (line 10) documents that axiom set hashes are produced "regardless of construction order," but the implementation preserves axiom tuple order, meaning two logically identical axiom sets constructed in different order will hash differently.

Problem

make_canonical_dict() in serialization.py (line 31) sorts dict keys but does not sort lists (line 33: [_normalize(v) for v in obj]).

AxiomSet.canonical_dict() in models.py (line 165) puts axioms in a list comprehension iterating self.axioms — a tuple whose order depends on construction.

The result: two AxiomSet objects with the same axioms in different order produce different canonical dicts and different hashes. This violates the documented guarantee and undermines deterministic evidence chains.

Note: hash_proof already sorts depends_on (line 84) and imported_bundle_hashes (line 90), showing awareness of this class of problem — the same treatment should apply to the axiom list.

Suggested fix

Sort the axiom list by a stable key (e.g., axiom name) in AxiomSet.canonical_dict() before passing to make_canonical_dict. Add a test constructing two AxiomSets with identical axioms in different order and asserting hash equality.

Files

  • symproof/hashing.py:10 — docstring claim
  • symproof/serialization.py:27-33make_canonical_dict list handling
  • symproof/models.py:160-170AxiomSet.canonical_dict()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions