Skip to content

Dedup view-law formula and check helpers (refs #813) - #1149

Merged
jsiek merged 1 commit into
mainfrom
routine/20260728-030202
Aug 7, 2026
Merged

Dedup view-law formula and check helpers (refs #813)#1149
jsiek merged 1 commit into
mainfrom
routine/20260728-030202

Conversation

@jsiek

@jsiek jsiek commented Jul 28, 2026

Copy link
Copy Markdown
Owner

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_formula built
    all <tps>. all v:T. outer(inner(v)) = v with (T, inner, outer) set to
    (target, out, into) and (source, into, out) respectively.
  • _check_view_roundtrip / _check_view_inverse type-checked the built
    formula 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 shared
    formula builder.
  • _check_view_composition(loc, env, label, proof_name, formula) — the shared
    check-and-diagnose step, parameterized by the label word and proof name.
  • _check_view_proofs(loc, view, env) — the dispatcher that runs the mandatory
    roundtrip 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_bad
and should-error/view_inverse_bad fixtures still match byte-for-byte.

Tests

python3 test-deduce.py --passable --errors — all pass (view validate/error
fixtures included). LALR parity spot-checked on view_inverse_decl.pf. No
parser/AST changes, so --equiv is unaffected. mypy/ruff are not installed
in this container; the change is type-clean by inspection (str names for
into/out, Type for target/source, inverse guarded 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

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>
@jsiek
jsiek merged commit 0a09115 into main Aug 7, 2026
15 checks passed
@jsiek
jsiek deleted the routine/20260728-030202 branch August 7, 2026 21:25
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