Skip to content

test spliced instances in Nat and Int recursion - #1

Merged
frangio merged 2 commits into
frangio:masterfrom
agostbiro:test-spliced-instance-recursion
Sep 25, 2026
Merged

frangio merged 2 commits into
frangio:masterfrom
agostbiro:test-spliced-instance-recursion

Conversation

@agostbiro

Copy link
Copy Markdown
Contributor

The existing spliced instance tests only cover non-recursive code, so add staged power functions that get *, 1 and / from spliced Mul, OfNat 1 and Div instances:

  • npowCode: structural recursion on Nat
  • zpowRecCode: well-founded recursion on Int

The guards splice concrete instances (Int.instMul, instOfNat, Int.instDiv) rather than inferInstance, so the generated code has no inferInstance wrappers and can be checked with =ₛ instead of =~.

zpowRecCode needs @[semireducible] because the coherence check compares generated code to its denotation at default transparency, which does not unfold well-founded definitions.

agostbiro and others added 2 commits September 24, 2026 17:10
The existing spliced instance tests only cover non-recursive code, so
add staged power functions that get `*`, `1` and `/` from spliced
`Mul`, `OfNat 1` and `Div` instances:

- `npowCode`: structural recursion on `Nat`
- `zpowRecCode`: well-founded recursion on `Int`

The guards splice concrete instances (`Int.instMul`, `instOfNat`,
`Int.instDiv`) rather than `inferInstance`, so the generated code has no
`inferInstance` wrappers and can be checked with `=ₛ` instead of `=~`.

`zpowRecCode` needs `@[semireducible]` because the coherence check
compares generated code to its denotation at default transparency, which
does not unfold well-founded definitions.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@frangio

frangio commented Sep 25, 2026

Copy link
Copy Markdown
Owner

Thanks!

@frangio
frangio merged commit f6932d1 into frangio:master Sep 25, 2026
frangio added a commit that referenced this pull request Sep 25, 2026
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: Francisco Giordano <fg@frang.io>
frangio added a commit that referenced this pull request Sep 25, 2026
Co-authored-by: Francisco Giordano <fg@frang.io>
@agostbiro
agostbiro deleted the test-spliced-instance-recursion branch September 25, 2026 20:09
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.

2 participants