Skip to content

Commit ac390d1

Browse files
test(kr-7): generator-index must be positive (no sigma 0, no negative index) (#25)
KR-7 from PROOF-NARRATIVE.md §3: `sigma N`, `sigma_inv N`, `cup N`, `cap N` must be accepted iff N >= 1. The canonical parser in `KRLAdapter.jl` raises a "zero index" error for `sigma 0` etc., and negative indices are outside the lexer's positive-Int recognition. The smoke test now asserts that no committed example contains such a pattern. Added check 4b in tests/smoke/grammar_smoke.sh: - Grep examples for `<gen> 0` — fail if present. - Grep examples for `<gen> -<digits>` — fail if present. - Report pass for examples with no violation. This is a positive smoke check, not a parser-correctness proof; full KR-7 discharge requires a parser-level property test (deferred to follow-up — see PROOF-NEEDS.md TG-K3 entry). The smoke version catches accidental commits of malformed examples and stays in the existing lexical-level CI lane. Verified locally: - Original 4 examples: 20 passing checks (was 16; added 1 KR-7 pass per file × 4 files). - Synthetic example `let bad = (sigma 0); close bad;` correctly fails with "generator with zero index violates KR-7 (sigma 0)". Cross-references: - PROOF-NARRATIVE.md KR-7 (added in PR #23) - ASSUMPTIONS.md A-KR-2.1 - TEST-NEEDS.md TG-K3 (added in PR #23) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 5759584 commit ac390d1

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

tests/smoke/grammar_smoke.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,26 @@ for file in "${EXAMPLE_FILES[@]}"; do
118118
fi
119119
done
120120

121+
# 4b. KR-7: generator indices must be POSITIVE (N >= 1).
122+
# The canonical parser in KRLAdapter.jl raises a "zero index" error
123+
# for `sigma 0`, `sigma_inv 0`, etc., and negative indices are
124+
# outside the lexer's positive-Int recognition. The smoke test
125+
# asserts that no committed example contains such a pattern.
126+
#
127+
# See PROOF-NARRATIVE.md KR-7 and ASSUMPTIONS.md A-KR-2.1.
128+
# NB: grep returns 1 when nothing matches; under `set -e` we
129+
# capture into a variable with `|| true` to avoid exiting.
130+
zero_violations=$(grep -oE '\b(sigma|sigma_inv|cup|cap)\b[[:space:]]+0\b' <<< "$stripped" || true)
131+
if [[ -n "$zero_violations" ]]; then
132+
report_fail "$name: generator with zero index violates KR-7 ($zero_violations)"
133+
else
134+
report_pass "$name: no generator-with-zero-index (KR-7 ok)"
135+
fi
136+
neg_violations=$(grep -oE '\b(sigma|sigma_inv|cup|cap)\b[[:space:]]+-[0-9]+' <<< "$stripped" || true)
137+
if [[ -n "$neg_violations" ]]; then
138+
report_fail "$name: generator with negative index violates KR-7 ($neg_violations)"
139+
fi
140+
121141
# 5. File must mention at least one operation family
122142
found_family=""
123143
grep -qE '\bsigma\b|\bsigma_inv\b|\bcup\b|\bcap\b' <<< "$stripped" && found_family="${found_family} CONSTRUCT"

0 commit comments

Comments
 (0)