0

This question is somewhat related to function with index

Imagine the definition of the function is

definition myf :: "nat => nat => nat" where
  "myf n a = n * a"

and I want to use a more readable abbreviation

"f<sub>n</sub> a" 

instead of

"myf n a"

I have tried

definition myf :: "nat => nat => nat" **("f<sub>_</sub> _" [90])** where
  "f<sub>n</sub> a = n * a"

and I get the error Head of definition "fn" differs from declaration "myf".

How am I supposed to write the prefix s.t. it gives me what I am looking for?

Thank you in advance

Alicia M.
  • 7
  • 3

1 Answers1

0

Subscripts that span a region of text can be marked up with \<^bsub>...\<^esub> (or, equivalently, ...). Therefore, your definition should be as follows:

definition myf :: "nat => nat => nat" ("f⇘_⇙") where
  "f⇘n⇙ a = n * a"

For further information see Appendix B in The Isabelle/Isar Reference Manual.

Javier Díaz
  • 1,071
  • 4
  • 7
  • Thank you @JavierDiaz - that did solve my immediate issue. I am not sure what "region of text" translates to in this case, I'll dig a bit more to understand the link between an argument as subscript/superscript and this special markup. – Alicia M. Feb 01 '23 at 00:08
  • @AliciaM.: "Region of text" means any valid expression, in your case, any expression of type `nat` that you can pass as argument to your function, e.g., you can write `f⇘Suc (Suc 0)⇙`. This distinction is made since, in addition, there is the markup `⇧` and `⇩` for _fixed_, single-character superscripts and subscripts, respectively. P.S.: Since my answer effectively answered your original question, I kindly ask you to accept it. Thanks. – Javier Díaz Feb 01 '23 at 02:29
  • perfect explanation, thank you... I missed the fact that you can have an expression as the argument, that makes perfect sense, ofc. Thanks, again! – Alicia M. Feb 01 '23 at 15:38