Skip to content

psi: read every generic mathematical body the signature can define - #6311

Merged
Smotto merged 1 commit into
mainfrom
claude/project-thread-1l5d7x
Nov 27, 2026
Merged

Smotto merged 1 commit into
mainfrom
claude/project-thread-1l5d7x

Conversation

@Smotto

@Smotto Smotto commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Requested by Jarod · project thread

After #6301 a few generic mathematical bodies were still refused by name. This reads them instead, so every generic body the signature can define is defined:

  • A generic machine that calls itself at other machines, such as alternate::<Step, Other> recursing as alternate::<Other, Step>. Each branch of a definition by cases already binds the machine parameters, so the recursion passes whichever machines it names. A law's induction hypothesis is the law at those machines, and its premises are owed there.
  • Recursion on fuel. The definition over fuel takes the machine parameters after the fuel and before the formals. A law over fuel counts them among its formals, both in its Fuel formal and in the goal it states over the fuel.
  • A dispatch on a computed value, such as transition (Step(n)). The dispatch is a definition of its own over everything in scope, and a body read for its value now has the machine parameters in scope too.
  • A call of a generic machine with a premise. It owes the premise, stated over the callee's machine parameters and formals, at the machines and arguments it passes (owed_at).
  • A citation of a generic machine that states nothing. It is lowered and read in place, with its machine parameters standing for the machines the citation passes. The callable scope now holds any term, not only a variable.
  • Any other generic body the clause reader cannot read as terms is lowered and read like any other body, which refuses what it cannot read.

Two smaller fixes came with this. A generic machine's own result in its clauses is now its definition at its machine parameters and formals; the formals were applied without them, which the kernel rejected. And a premise owed in a body read for its value is stated over the machine parameters too.

One rule stays as it was. A concrete machine with a premise is still no machine argument, since it is not a total function for the parameter to stand for.

Customers, each a positive case with its negative twin:

  • generic_machine/pass/alternate_keeps_two_fixed_points proves alternate::<succ, id>(2, a) = Succ(a) and the law by induction at swapped machines. fail/alternate_keeps_one_fixed_point gives only Step(a) = a, and the hypothesis is refused.
  • pass/pick_by_a_computed_value dispatches on Step(n). fail/pick_by_a_computed_value_wrong_case claims the other case's value.
  • pass/call_owes_its_premise calls apply_fixed::<id>. fail/call_without_its_premise calls it at succ, whose premise is refused.
  • pass/cited_through_a_generic_helper cites through argue_twice::<id>. fail/cited_through_a_generic_helper_at_succ cites it at succ.
  • Inline over core/nat.omg: gcd_then on fuel proves gcd_then::<succ>(2, 1) = 2, and its twin claims 1. mod_then proves its law over fuel, and its twin drops the bound and stays unproved.

Gate: RC-SOURCE-SEMANTICS | every generic mathematical body the signature can define is read
Spec: wiki/spec/language/generics.md#nested-contracts-and-proof-families, wiki/spec/proofs/foundation.md, wiki/spec/language/termination.md#computed-recursive-arguments-in-proofs
Proof: mbx test -p lowered-program-to-checked-program --lib (1557, including 19 generic_machine); mbx test -p prepared-typed-trees-to-lowered-program (224 + 3); clippy --all-targets --no-deps -D warnings on both crates | clean.

Agent: Claude Code | Model: unavailable | Effort: medium | Tokens: 31.0M in (30.8M cached), 98.2k out | Steps: 171 | Time: 1h48m | Steers: 0


Generated by Claude Code

After #6301 a few generic mathematical bodies were still refused by name. This reads them instead, so every generic body the signature can define is defined:

- **A generic machine that calls itself at other machines**, such as `alternate::<Step, Other>` recursing as `alternate::<Other, Step>`. Each branch of a definition by cases already binds the machine parameters, so the recursion passes whichever machines it names. A law's induction hypothesis is the law at those machines, and its premises are owed there.
- **Recursion on fuel.** The definition over fuel takes the machine parameters after the fuel and before the formals. A law over fuel counts them among its formals, both in its `Fuel` formal and in the goal it states over the fuel.
- **A dispatch on a computed value**, such as `transition (Step(n))`. The dispatch is a definition of its own over everything in scope, and a body read for its value now has the machine parameters in scope too.
- **A call of a generic machine with a premise.** It owes the premise, stated over the callee's machine parameters and formals, at the machines and arguments it passes (`owed_at`).
- **A citation of a generic machine that states nothing.** It is lowered and read in place, with its machine parameters standing for the machines the citation passes. The callable scope now holds any term, not only a variable.
- **Any other generic body** the clause reader cannot read as terms is lowered and read like any other body, which refuses what it cannot read.

Two smaller fixes came with this. A generic machine's own `result` in its clauses is now its definition at its machine parameters and formals; the formals were applied without them, which the kernel rejected. And a premise owed in a body read for its value is stated over the machine parameters too.

One rule stays as it was. A concrete machine with a premise is still no machine argument, since it is not a total function for the parameter to stand for.

Customers, each a positive case with its negative twin:
- `generic_machine/pass/alternate_keeps_two_fixed_points` proves `alternate::<succ, id>(2, a) = Succ(a)` and the law by induction at swapped machines. `fail/alternate_keeps_one_fixed_point` gives only `Step(a) = a`, and the hypothesis is refused.
- `pass/pick_by_a_computed_value` dispatches on `Step(n)`. `fail/pick_by_a_computed_value_wrong_case` claims the other case's value.
- `pass/call_owes_its_premise` calls `apply_fixed::<id>`. `fail/call_without_its_premise` calls it at `succ`, whose premise is refused.
- `pass/cited_through_a_generic_helper` cites through `argue_twice::<id>`. `fail/cited_through_a_generic_helper_at_succ` cites it at `succ`.
- Inline over `core/nat.omg`: `gcd_then` on fuel proves `gcd_then::<succ>(2, 1) = 2`, and its twin claims 1. `mod_then` proves its law over fuel, and its twin drops the bound and stays unproved.

Gate: RC-SOURCE-SEMANTICS | every generic mathematical body the signature can define is read
Spec: wiki/spec/language/generics.md#nested-contracts-and-proof-families, wiki/spec/proofs/foundation.md, wiki/spec/language/termination.md#computed-recursive-arguments-in-proofs
Proof: `mbx test -p lowered-program-to-checked-program --lib` (1557, including 19 `generic_machine`); `mbx test -p prepared-typed-trees-to-lowered-program` (224 + 3); clippy `--all-targets --no-deps -D warnings` on both crates | clean.

Agent: Claude Code | Model: unavailable | Effort: medium | Tokens: 31.0M in (30.8M cached), 98.2k out | Steps: 171 | Time: 1h48m | Steers: 0

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HqP8t5tK2L9aM3g5FQNwtB
@Smotto Smotto self-assigned this Nov 27, 2026
@Smotto
Smotto merged commit f6b9aff into main Nov 27, 2026
1 check passed
@Smotto
Smotto deleted the claude/project-thread-1l5d7x branch November 27, 2026 02:27
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