slatex / sTeX

A semantic Extension of TeX/LaTeX
50 stars 9 forks source link

maxval does not work well with precedences #318

Closed kohlhase closed 2 years ago

kohlhase commented 2 years ago
image

In .../MathHub/smglom/arithmetics/source/minmax.en.texwe have

\symdef{bmaxval}[args=bii,prec=100;\neginfprec x\neginfprec x100,op=\text{max}]{\underset{#2}{\comp{\text{max}}\;} #3}

but in MathHub/MiKoMH/AI/source/rational-decisions/mod/Bellman-equation.en.tex we have


<img width="349" alt="Screenshot 2022-06-08 at 15 01 40" src="https://user-images.githubusercontent.com/4037538/172623005-4a0ab481-886b-470d-a3c1-b80a169eb1e9.png">

see the brackets in the argument below the max.
Jazzpirate commented 2 years ago

this looks correct to me - \neginfprec as argument precedence pretty much enforces brackets. You probably meant the opposite, i.e. prec=100;\infprec x\infprec x 100?

Jazzpirate commented 2 years ago

Quote documentation:

STEX decides whether to insert parentheses by comparing operator precedences to a downward precedence p_d with initial value \infprec. When encountering a semantic macro, STEX takes the operator precedence p_op of the notation used and checks whether p_op > p_d. If so, STEX insert parentheses.

Argument precedences are the downwards precedences p_d

kohlhase commented 2 years ago

same difference, mit infprec gibt es auch Klammern.

Jazzpirate commented 2 years ago

ah. Was ist die operator-precedence von dem \in-symbol an der stelle? (Übrigens: Ein ternärer \bmaxval dessen erstes argument in der notation nie auftaucht stellt für MMT ein problem dar - im html landet das dann nämlich auch nicht. idealerweise ein \STEXinvisible{#1} mit in die notation packen)

Jazzpirate commented 2 years ago

...prinzipiell braucht man aber die unterscheidung zwischen dem ersten und dem zweiten argument gar nicht, das könnte also genausogut ein binärer operator sein. Aber das kann man dann beim allgemeinen smglom übersetzen abhaken

kohlhase commented 2 years ago

ah. Was ist die operator-precedence von dem \in-symbol an der stelle?

das sollte ja egal sein bei \(neg)infprec. Das verwirrt mich.

Jazzpirate commented 2 years ago

hmm, true, ich hab mal geguckt, der test ist ein > (i.e. echt größer)... muss ich mir angucken...

kohlhase commented 2 years ago

ich kónnte mir vorstellen, dass das am \underbrace liegt.

kohlhase commented 2 years ago

prinzipiell braucht man aber die unterscheidung zwischen dem ersten und dem zweiten argument gar nicht, das könnte also genausogut ein binärer operator sein. Aber das kann man dann beim allgemeinen smglom übersetzen abhaken

Ich vermute, damit meinst Du den (binären) Operator \maxover, bei \bmaxval sind die beiden ersten Argumente durchaus (z.B. in der Bellman-equation) unterschiedlich.

Jazzpirate commented 2 years ago

möglich, aber auch unklar an der stelle - klammern werden eingefügt wenn ein semantische macro auftaucht - also beim \inset (deswegen wird nie geklammert wenn du in nem argument keine semantischen macros benutzt, übrigens). Das \undersetkönnte höchstens ne tex-gruppe aufmachen, das sollte aber an der stelle auch nichts machen, die downwards-precedence wird ja außerhalb des \underset gesetzt...

Jazzpirate commented 2 years ago

Ich vermute, damit meinst Du den (binären) Operator \maxover, bei \bmaxval sind die beiden ersten Argumente durchaus (z.B. in der Bellman-equation) unterschiedlich.

can you elaborate? Was macht denn das erste argument das eh nicht auftaucht in der notation?

Jazzpirate commented 2 years ago
bellman

...can not reproduce...?

EDIT Ah, nevermind, the pushed version used a different notation. Can reproduce, will investigate

Jazzpirate commented 2 years ago

...fixed and pushed

kohlhase commented 2 years ago

thanks, confirming it works now for me.