Skip to content

Claude/hopeful fermi i xnba - #107

Merged
hyperpolymath merged 5 commits into
mainfrom
claude/hopeful-fermi-iXnba
Jul 29, 2026
Merged

Claude/hopeful fermi i xnba#107
hyperpolymath merged 5 commits into
mainfrom
claude/hopeful-fermi-iXnba

Conversation

@hyperpolymath

@hyperpolymath hyperpolymath commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #

Type of change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (would change existing behaviour)
  • 🕳️ Soundness fix (fixes a checker/proof false-negative)
  • 📖 Documentation
  • 🧹 Refactor / tech debt (behaviour-preserving)
  • ⚡ Performance
  • 🔧 Build / CI / tooling

How has this been verified?

Checklist

  • My commits are signed (git commit -S).
  • I ran the project's own checks/tests locally and they pass.
  • New files carry the correct SPDX-License-Identifier (code/config MPL-2.0,
    prose CC-BY-SA-4.0); I did not relicense existing files.
  • Docs are updated, and no public claim now overstates what the code does.
  • I have not introduced a soundness hole (or I have flagged where I might have).

Notes for reviewers


Summary by Gitar

  • Echo and product types:
    • Integrated echo types and product types into the OCaml typechecker, AST, evaluator, lexer, parser, and pretty printer
    • Added runtime evaluation, surface parser support, and exhaustiveness gap patches for echo and product forms
  • Documentation:
    • Added TangleIR residue-threading cross-repo contract documentation in docs/spec/ECHO-TANGLEIR-THREADING.md

This will update automatically on new commits.

claude and others added 4 commits June 14, 2026 03:24
Mirrors the Lean spec (proofs/Tangle.lean) into the OCaml checker so echo
types are a feature of the actual typechecker, not only the metatheory.

- typecheck.ml: `ty` gains `TProd of ty*ty` and `TEcho of ty*ty`; `pp_ty` is
  now `let rec` and prints them; `infer_expr` gains the eight typing rules
  [T-Echo-Close]/[T-Lower]/[T-Residue]/[T-Pair]/[T-Fst]/[T-Snd]/[T-Echo-Add]/
  [T-Echo-Eq], matching the HasType rules.
- ast.ml: `expr` gains EchoClose/Lower/Residue/Pair/Fst/Snd/EchoAdd/EchoEq.
- pretty.ml: pp_expr prints the new forms (kept exhaustive).
- eval.ml: eval_expr gets an explicit "not yet implemented" arm for the echo
  forms (runtime evaluation is a scoped follow-on; the typechecker is the
  deliverable). Stays exhaustive.

Scope: the typechecker. Surface parser syntax + runtime eval are follow-ons.

NOTE: no OCaml toolchain or OCaml CI exists in this environment, so this was
NOT compiled here — it is a careful by-hand integration (exhaustiveness audited
via the Ast-only `Twist` probe: pretty/eval/typecheck are the only exhaustive
Ast.expr matchers; compositional's of_ast_expr has a catch-all; repl matches no
expr). Verify with `dune build` in compiler/.

https://claude.ai/code/session_01PgHpCFzwYB7Qy9L6kmR8CE
Specifies how echoClose's residue (the pre-closure braid) threads through
TangleIR to QuandleDB's quandle_presentation. TangleIR itself lives in
KRLAdapter.jl (Julia, out of scope), so this is the coordination contract from
the semantics owner (tangle), not an IR code change.

https://claude.ai/code/session_01PgHpCFzwYB7Qy9L6kmR8CE
Implements the two follow-ons to the echo typechecker integration:

PART 1 — eval.ml runtime evaluation
- Add value forms VEcho (residue, result) and VPair (a, b), mirroring
  echoVal / pair in proofs/Tangle.lean.
- Replace the not-yet-implemented stub arm with real eval_expr arms for
  EchoClose / Lower / Residue / Pair / Fst / Snd / EchoAdd / EchoEq,
  following the Lean small-step Step rules (echoCloseWord, lowerVal,
  residueVal, fstPair, sndPair, echoAddNums, echoEqNums). echoAdd/echoEq
  reuse eval_binop Add / Eq for the result component.
- Extend pp_value (now recursive) with echo(...) / (...) rendering.

PART 2 — lexer.mll + parser.mly surface syntax
- Add dedicated keyword tokens ECHOCLOSE/LOWER/RESIDUE/PAIR/FST/SND/
  ECHOADD/ECHOEQ (lexer keyword table + parser %token + token.ml mirror),
  following the existing close/mirror/cap/cup mechanism.
- Add unary_expr productions in the same precedence group as close/cap,
  so pretty.ml output round-trips: echoClose(E), lower(E), residue(E),
  pair(E,E), fst(E), snd(E), echoAdd(E,E), echoEq(E,E).

https://claude.ai/code/session_01PgHpCFzwYB7Qy9L6kmR8CE
Two warnings-as-errors surfaced when compiling the echo/product additions
for the first time on a real OCaml toolchain:

  compiler/lib/typecheck.ml — `strand_type_of_ty` had no arms for TProd/TEcho.
  compiler/bin/main.ml     — the debug token printer had no arms for the 8 new
                             echo keyword tokens (ECHOCLOSE LOWER RESIDUE PAIR
                             FST SND ECHOADD ECHOEQ).

Both are straightforward exhaustiveness gaps; the design is preserved.
Both get StrandDefault / print_string "<NAME>" mirroring the nearest
neighbouring cases.

Also extend the TG-4 round-trip corpus in test_roundtrip.ml with one entry
per new echo constructor (echoClose, lower, residue, pair, fst, snd, echoAdd,
echoEq) so the parse/pretty/parse round-trip guarantee is explicitly exercised
for every form added by this PR.

Before: dune build fails; 532 tests (not reached)
After:  dune build succeeds; 548/548 tests pass (16 new TG-4 entries)
Comment thread compiler/lib/lexer.mll
Comment thread compiler/lib/typecheck.ml
@gitar-bot

gitar-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

Note

Automatic reviews are paused because your trial's included automatic processing has been used for this period. Upgrade now, or comment "Gitar review" to run a review anytime.
Learn more

Code Review ✅ Approved 2 resolved / 2 findings

Integrates echo and product types into the OCaml typechecker, parser, and evaluator alongside TangleIR residue-threading contract documentation. Consider checking keyword shadowing for identifiers like lower and pair, and aligning the echoEq type rule with its evaluator operand support.

Auto-approved and auto-merge armed: No blocking issues found.
Please see Auto-approve Docs for details on setting custom approval criteria. — merges when pipeline and required approvals pass.

✅ 2 resolved
Quality: New reserved words shadow plausible user identifiers

📄 compiler/lib/lexer.mll:48-56
The lexer now maps lower, pair, fst, snd, and residue (along with echoClose/echoAdd/echoEq) to keyword tokens, so any existing or future TANGLE source that uses these common names as a def name, parameter, or variable will fail to parse. This is a silent surface-language breaking change. Consider reserving only the less collision-prone camelCase names (echoClose/echoAdd/echoEq) and exposing the projections via a namespaced or contextual form, or at minimum document these as newly reserved words. No existing usage was found in the conformance corpus, so impact is currently low.

Quality: echoEq type rule omits Bool operands that eval supports

📄 compiler/lib/typecheck.ml:431-439 📄 compiler/lib/eval.ml:494-499
infer_expr for EchoEq accepts only Num/Str/Word operands, while the ordinary Eq rule in infer_binop (typecheck.ml:537-544) and eval_binop Eq (eval.ml:579-587) both accept Bool == Bool. As a result echoEq(true, false) is rejected by the type checker even though the runtime eval_binop Eq it delegates to would evaluate it fine. This is a consistency gap, not a soundness hole; add a TBool, TBool -> TEcho (TProd (TBool, TBool), TBool) arm if Bool equality is intended.

Options

Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@gitar-bot

gitar-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

⚠️ Gitar auto-approved this PR but could not enable auto-merge: auto-merge is disabled for this repository — enable "Allow auto-merge" in the repository settings.

@gitar-bot gitar-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gitar has auto-approved this PR and enabled auto-merge (configure)

@gitar-bot gitar-bot Bot added the gitar-approved Added by Gitar label Jul 29, 2026
Signed-off-by: Jonathan D.A. Jewell <6759885+hyperpolymath@users.noreply.github.com>
@hyperpolymath
hyperpolymath merged commit 609a5ca into main Jul 29, 2026
19 of 20 checks passed
@hyperpolymath
hyperpolymath deleted the claude/hopeful-fermi-iXnba branch July 29, 2026 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gitar-approved Added by Gitar

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants