Zulip Chat Archive
Stream: lean4 dev
Topic: Unsafe prohibition flag in `Elab.Term.Context`
Leni Aniva (Jul 01 2025 at 23:45):
Is it possible to have a flag in Elab.Term.Context, when enabled, prevents all instances of the unsafe term elaborator from running?
This way, we can prevent the execution of arbitrary code during type checking, and it doesn't seem to be very hard to implement.
Leni Aniva (Jul 02 2025 at 00:51):
e.g. https://github.com/lenianiva/lean4/commit/50ebee39e2a0fa09b1b1bb9e983384c6d7df124c
Leni Aniva (Jul 02 2025 at 00:51):
This will not prevent arbitrary codes in top-level declarations, but it can prevent such behaviour during type checking of proofs.
Eric Wieser (Jul 02 2025 at 01:02):
What meaning of "unsafe" do you intend here?
Leni Aniva (Jul 02 2025 at 01:03):
Eric Wieser said:
What meaning of "unsafe" do you intend here?
I want to prohibit the execution of arbitrary code including the unsafe elaborator, evalTerm, and any other cases where a tactic author sees fit.
Eric Wieser (Jul 02 2025 at 01:04):
So evalExpr as well?
Leni Aniva (Jul 02 2025 at 01:05):
Yes, and this would be optional. Existing code will not be affected.
Eric Wieser (Jul 02 2025 at 01:05):
Ultimately I think yo uonly need to attempt to ban evalConst
Eric Wieser (Jul 02 2025 at 01:05):
But what about a tactic that uses eval on a controlled type like a natural number expression?
Leni Aniva (Jul 02 2025 at 01:06):
If the tactic author sees that its safe, then there would not be a check for the prohibit unsafe flag.
Leni Aniva (Jul 02 2025 at 01:07):
The trust is on the tactics and elaborators, rather than whatever thing wrote a proof.
Eric Wieser (Jul 02 2025 at 01:07):
It's not clear to me why you'd care about banning the unsafe keyword.
Eric Wieser (Jul 02 2025 at 01:07):
It sounds like the meaning you want this flag to have is not really related to the meaning of that keyword
Eric Wieser (Jul 02 2025 at 01:08):
(maybe I'm reading too much into your code example)
Leni Aniva (Jul 02 2025 at 01:08):
I call it prohibitUnsafe because my starting point is run_tac, which uses the unsafe keyword. A better terminology is possible.
Leni Aniva (Jul 02 2025 at 01:55):
The PR is here: https://github.com/leanprover/lean4/pull/9148
Kim Morrison (Jul 02 2025 at 02:43):
@Leni Aniva, you would need to write a much more detailed RFC to get traction here.
Leni Aniva (Jul 02 2025 at 03:57):
Kim Morrison said:
Leni Aniva, you would need to write a much more detailed RFC to get traction here.
let me discuss with amazon people on this matter...
Leni Aniva (Jul 02 2025 at 17:13):
https://github.com/leanprover/lean4/issues/9160
Last updated: Dec 20 2025 at 21:32 UTC