Is this possible in Isabelle? Like in Haskell we can write (+) a b = myfun a b and use it as a + b within a local scope.
You can introduce notation with the notation command
notation myfun (infixl "+" 50)
Unlike with Haskell, you even can introduce notation locally, using write.
I should clarify. I often have binary operators that take an additional parameter, e.g.
comb V a b
In the context of a proof, V is fixed, so I would like to write something (in haskell notation)
(+) a b = comb V a b
so that within the local context of the proof, I can use the infix operator + instead of comb V. Is this possible?
I don’t know whether write can handle partial applications. Maybe you have to locally define a new constant that is equal to the partial application and give it the operator notation, something like the following:
define add (infixl …) where add = comb V
However, this means that you have to use the defining equation in proofs to tell Isabelle that add and comb V are the same thing. For proof methods involving the simplifier, this can be done once and for all by prefixing the defining equation with [simp]:.
Wolfgang Jeltsch said:
I don’t know whether
writecan handle partial applications. Maybe you have to locally define a new constant that is equal to the partial application and give it the operator notation, something like the following:define add (infixl …) where add = comb VHowever, this means that you have to use the defining equation in proofs to tell Isabelle that
addandcomb Vare the same thing. For proof methods involving the simplifier, this can be done once and for all by prefixing the defining equation with[simp]:.
Thanks! I'm not completely sure what you mean though. I've tried this in a proof - context and I have an error:
Maybe I have misunderstood what was supposed to go in your ellipses?
Actually a more preferable place to make this definition would be in the statement of the lemma, in a defines. is that possible? Either way would be great though!
You are not using the syntax correctly:
define comb :: ‹nat ⇒ nat ⇒ nat ⇒ nat› where ‹comb = undefined›
define V :: ‹nat› where ‹V = undefined›
define "add" (infixl ‹combV› 55) where "a combV b = comb V a b" for a b
have ‹a combV b = comb V b a› for a b
sorry
I would suggest using bold + (C-e rightarrow for bold) if you need a new operator instead of +
Last updated: Nov 13 2025 at 04:27 UTC