Zulip Chat Archive
Stream: new members
Topic: modify constant by modifying Environment
Asei Inoue (Oct 21 2025 at 15:52):
Can we modify declared constant value by modifying Environment?
Asei Inoue (Oct 21 2025 at 15:52):
for example, can we get hoge = 42 even if it is declared by def hoge := 1, by modifying Environment?
Henrik Böving (Oct 21 2025 at 15:59):
There are certain hacks that you can do to mutate an Environment in this fashion but this is not something that is generally supported as part of the whole Lean framework no
Henrik Böving (Oct 21 2025 at 16:00):
In particular changing the definition of a function can make other parts of the env not type check anymore so you can easily get yourself in trouble
Asei Inoue (Oct 21 2025 at 16:07):
Thank you. so this is possible?
how? (I want to see it for only curiosity)
Henrik Böving (Oct 21 2025 at 16:23):
It's a bit more difficult with the async Environment etc. now so I don't actually know how to put in into action from the top of my head but the main thing you have to do is modify the kernel environment contained in that thing and then touch the constants map in docs#Lean.Kernel.Environment to do the change you want.
Last updated: Dec 20 2025 at 21:32 UTC