Zulip Chat Archive
Stream: Is there code for X?
Topic: Replacing common subexpression
Ayhon (Aug 18 2024 at 16:02):
If I have a common subexpression which appears in many different places in my proof, how can I substitute it with a common variable? For instance, if I have (a+b)/2 in different areas of my codebase, I would like to do let mid := (a+b)/2 and have all appearances of (a+b)/2 substituted with mid. I have "loogled" for substitute, rename and fold (since it's opposite of unfold), but they don't seem to fit my usecase.
Adomas Baliuka (Aug 18 2024 at 16:04):
Use the tactic set
Ayhon (Aug 18 2024 at 16:06):
I feel like I should have found this sooner. Is there a glosary of tactics or a proper way to search for them? Because I couldn't find it at all, and it now seems to be pretty basic
Ruben Van de Velde (Aug 18 2024 at 16:43):
Not yet
Ayhon (Aug 18 2024 at 17:13):
And what is the opposite of set? Because unfold doesn't seem to be working for me, it says unknown constant 'mid'
Daniel Weber (Aug 18 2024 at 17:24):
You can use unfold_let
Ruben Van de Velde (Aug 18 2024 at 18:13):
Or use set x := .. with hx and rewrite with hx
Last updated: May 02 2025 at 03:31 UTC