Skip to content

Hotfix: canonicalizeSpotTrace corrupts traces with OR operators#149

Merged
sidprasad merged 1 commit intomainfrom
fix/canonicalize-or-traces
Mar 11, 2026
Merged

Hotfix: canonicalizeSpotTrace corrupts traces with OR operators#149
sidprasad merged 1 commit intomainfrom
fix/canonicalize-or-traces

Conversation

@sidprasad
Copy link
Copy Markdown
Contributor

Bug

Trace satisfaction Y/N questions were showing the wrong correct answer for formulas like s <-> v. A question with trace !s & v; cycle{s & !v} against formula (s <-> v) was displaying Yes as the correct answer when it should have been No.

Root Cause

Introduced in v1.9.10 (commit 4cc9cd4, PR #146).

canonicalizeSpotTrace calls _canonicalize_state directly on raw SPOT trace output. However, _canonicalize_state only understands &-separated literals — it has no awareness of | (OR) operators.

SPOT generates trace states that can contain ORs, e.g.:

The canonicalizer was:

Splitting on & → tokens like (s, v) | (!s, !v)
Stripping parentheses → s, v | !s, !v (garbled)
Reordering alphabetically → s & !v & v | !s (nonsensical)
This destroyed the OR structure, producing traces that no longer satisfied (or rejected) the original formula. Since the correctness label (Yes/No) was determined before canonicalization, but the displayed trace was the corrupted one, students saw wrong answers.

Fix

Added _resolve_ors_in_state() which calls choosePathFromWord (the existing OR-resolver via the LTL parser) on each trace state before canonicalizing. This is the same OR-resolution that NodeRepr.init already performs — canonicalizeSpotTrace was simply bypassing it.

Verification

Ran a 100-iteration simulation of question generation for s <-> v: 0 bugs (previously ~40% failure rate)
3 new regression tests added for OR-containing traces
Full test suite passes (4 pre-existing English translation failures unrelated to this change)
Changes
exerciseprocessor.py — added _resolve_ors_in_state, integrated into canonicalizeSpotTrace
test_trace_canonicalization.py — 3 new regression tests
version.html — bumped to 1.9.12
CHANGELOG.md — added bugfix entry

@sidprasad sidprasad merged commit d171bbd into main Mar 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant