Dedup view-law formula and check helpers (refs #813) - #1149
Merged
Conversation
Collapse the near-identical `_view_roundtrip_formula`/`_view_inverse_formula` and `_check_view_roundtrip`/`_check_view_inverse` pairs in checker_pipeline.py into parameterized `_view_composition_formula` and `_check_view_composition` helpers, driven by a small `_check_view_proofs` dispatcher. The pairs differed only in the composition direction (into∘out vs out∘into), value type, diagnostic label, and proof name; error wording and behavior are unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jul 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A slice of the code-duplication umbrella (#813): collapse the near-identical
view-law helpers in
checker_pipeline.py.Two pairs of functions differed only in the composition direction, value type,
diagnostic label, and proof name:
_view_roundtrip_formula/_view_inverse_formulabuiltall <tps>. all v:T. outer(inner(v)) = vwith(T, inner, outer)set to(target, out, into)and(source, into, out)respectively._check_view_roundtrip/_check_view_inversetype-checked the builtformula against the named proof var and raised the same "undefined … proof"
/ "view … proof … proves … but expected …" diagnostics.
These are replaced by three helpers:
_view_composition_formula(loc, view, val_type, inner, outer)— the sharedformula builder.
_check_view_composition(loc, env, label, proof_name, formula)— the sharedcheck-and-diagnose step, parameterized by the label word and proof name.
_check_view_proofs(loc, view, env)— the dispatcher that runs the mandatoryroundtrip check and the optional inverse check, and is the single call site
in
process_declarations.Error wording and behavior are unchanged; the
should-error/view_roundtrip_badand
should-error/view_inverse_badfixtures still match byte-for-byte.Tests
python3 test-deduce.py --passable --errors— all pass (view validate/errorfixtures included). LALR parity spot-checked on
view_inverse_decl.pf. Noparser/AST changes, so
--equivis unaffected.mypy/ruffare not installedin this container; the change is type-clean by inspection (
strnames forinto/out,Typefortarget/source,inverseguarded before use).Refs #813.
Resume this session on ginger:
~/deduce-runner/resume.sh 140dce82-b769-4497-b864-d0fdacd98003 routine/20260728-030202🤖 Generated with Claude Code