Zulip Chat Archive
Stream: new members
Topic: redefining operators
pblpbl (Aug 09 2024 at 17:25):
Hello, is it possible to redefine existing operators? Currently I'm trying to make / always return a real number when called on Nat using
def div (a b : ℝ) : ℝ := a / b
infix:70 "/" => div
but I'm getting ambiguous, possible interpretations when trying to use it.
Kyle Miller (Aug 09 2024 at 17:39):
You could override the interpretation of a pre-existing notation with a macro, like
macro_rules | `($a / $b) => `((HDiv.hDiv ($a : ℝ) ($b : ℝ) : ℝ))
(untested)
Kyle Miller (Aug 09 2024 at 17:40):
This is better than using your div too since all theorems are in terms of HDiv.hDiv
Edward van de Meent (Aug 09 2024 at 17:41):
i think the preferable method would be to define a different notation, for example something like "/r"
Michal Wallace (tangentstorm) (Aug 10 2024 at 17:00):
÷?
Last updated: May 02 2025 at 03:31 UTC