2 ms·
TeX is a typesetting system and not interested in semantics; AM is similar but simpler format meant for more casual use and to be quite readable even when not t
by forgotpwd16 11mo ago
TeX is a typesetting system and not interested in semantics; AM is similar but simpler format meant for more casual use and to be quite readable even when not typesetted. What you're describing is essentially a computer algebra system. There's some overlap but they're different things.
That said, your system kinda exists already (and has been for decades). Mathematica can be written fully in M-Expressions (given any expression can recover the M-Exp with `FullForm[HoldForm[...]]`) and can convert to TeX (given any expression with `TeXForm[HoldForm[...]]`) for each if you want.
| TeX | M-Expression |
|--------------+-----------------------------------|
| 1 + 2 | Plus[1, 2] |
| 1 - 2 | Plus[-1, 2] |
| 1 \times 2 | Times[1, 2] |
| frac{1}{2} | Times[2, Power[2, -1]] |
| a_i | Map[a, Range[0, n]] | (* or better: a[i] *)
| \sum_i a_i | Apply[Plus, Map[a, Range[0, n]]] | (* or better: Sum[a[i], i] *)
| \int x^2, dx | Integrate[Power[x, 2], x]]] |
Interestingly (didn't know it myself either) internally notation is even simpler than your described system as you can see by minus/frac examples. Note that `a_i` examples can exist in indefinite form, which is why the commented forms are more correct given no other context.
There's also Emmy which is a vastly expanded port of scmutils (from SICM) embedded in Clojure but haven't used it much. Being embedded in Clojure, uses sexps and, when used in Clerk environment, can render to TeX.
- noosphr 11mo agoWhile you're right about Tex, that was more a critique of LaTeX, which is the only language that understands how to typeset everything after the '- in the table. As for m-expressions they also came from lisp, but were abandoned because s-expressions had so much more expressional power, since they were composable as expressions and as code.