Skip to content

Introduce an efficient typing rule for let-bindings in Typeops.#21678

Open
ppedrot wants to merge 1 commit intorocq-prover:masterfrom
ppedrot:preserve-let-in-kernel-the-return
Open

Introduce an efficient typing rule for let-bindings in Typeops.#21678
ppedrot wants to merge 1 commit intorocq-prover:masterfrom
ppedrot:preserve-let-in-kernel-the-return

Conversation

@ppedrot
Copy link
Member

@ppedrot ppedrot commented Feb 27, 2026

When the expand_let typing flag is set in the environment, we change the kernel typing rule for let-bindings from

let x := t in u : T{x := t}

to

let x := t in u : let x := t in T.

We cannot do this by default since it may change the inferred type for some expressions, which is returned when the expected type is not provided. To work around this, we statically set the flag in expressions for which the precise inferred type is not relevant. For now there is no user-facing flag that would allow setting this option in a more fine-grained way though, but it is easy to fix.

This is a revival of #13606 and a partial fix of #11838. The latter still suffers from superlinear blowups in unrelated parts of the kernel, namely VM and native compilation.

When the expand_let typing flag is set in the environment, we change
the kernel typing rule for let-bindings from

let x := t in u : T{x := t}

to

let x := t in u : let x := t in T.

We cannot do this by default since it may change the inferred type for
some expressions, which is returned when the expected type is not
provided. To work around this, we statically set the flag in expressions
for which the precise inferred type is not relevant. For now there is
no user-facing flag that would allow setting this option in a more
fine-grained way though, but it is easy to fix.

This is a revival of rocq-prover#13606 and a partial fix of rocq-prover#11838. The latter still
suffers from superlinear blowups in unrelated parts of the kernel, namely
VM and native compilation.
@ppedrot ppedrot added this to the 9.3+rc1 milestone Feb 27, 2026
@ppedrot ppedrot requested a review from a team as a code owner February 27, 2026 14:52
@ppedrot ppedrot added kind: fix This fixes a bug or incorrect documentation. kind: performance Improvements to performance and efficiency. request: full CI Use this label when you want your next push to trigger a full CI. labels Feb 27, 2026
@coqbot-app coqbot-app bot removed the request: full CI Use this label when you want your next push to trigger a full CI. label Feb 27, 2026
@ppedrot
Copy link
Member Author

ppedrot commented Feb 27, 2026

@coqbot bench

@ppedrot
Copy link
Member Author

ppedrot commented Feb 27, 2026

Together with #21679 this fixes #11838, at least the example given in that report.

@SkySkimmer SkySkimmer self-assigned this Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind: fix This fixes a bug or incorrect documentation. kind: performance Improvements to performance and efficiency.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants