axiom-developer
[Top][All Lists]

## [Axiom-developer] Design Thoughts on Semantic Latex (SELATEX)

 From: Tim Daly Subject: [Axiom-developer] Design Thoughts on Semantic Latex (SELATEX) Date: Wed, 17 Aug 2016 08:41:42 -0400

The design goal of semantic latex markup would be to decorate
existing formulas with type information. This would greatly benefit
computational mathematics. A single formula would be explicit
about its domain and range. Indeed, a single formula might have
more general form over C than over R, for example. Semantic
markup would result in multiple versions of the same formula.

Assumptions, such as branch cuts, could be made explicit and
available to the community. This might not set a standard but it might
encourage machinery to handle different decisions explicitly.

Provisos, such as limitations on the range (x in [1,2]), would be made
available for things like cylindrical algebraic decomposition (CAD)
algorithms.

The CRC and NIST collections with semantic markup would create
a "computer algebra test suite" (CATS) that all of the systems could
use as a reference.

Pattern matching systems, such as Albert Rich's RUBI matcher or
which to base patterns.

============
Consideration 0: Where are semantics inserted?

A search of the TeX package name space shows that selatex is unused.
This allows \usepackage{selatex} without conflict.

Axiom has 1177 categories/domains/packages (hereafter just called 'types'
except when being more specific).

A zero-th attempt at selatex markup amounts to a file (selatex.sty) that
contains a \newcommand for each type, for instance,

\newcommand{\INT}[1]{#1}

which would allow 'raw' markup anywhere since latex simply ends up
removing all the type decorations, as in

\INT{3}  becomes just 3

============
Consideration 1: Where are semantics processed?

These markups are essentially invisible to tex so they could be inserted
anywhere. The associated semantics would be given by a program that
reads the tex. This makes it possible to mark up formulas from the NIST
and CRC books without any change to the result.

Axiom 'pamphlet' files are just raw latex files. There is no "weave" step
which Knuth used to extract latex. This is a feature we want to be
careful to preserve. Only a "tangle" program exists and it only extracts
a named chunk so it is trivial.

If a formula is in a named chunk it can be extracted as raw text so that

\begin{chunk}{formula1}
\INT{3}
\end{chunk}

when given the command "tangle formula.file formula1" we would see

\INT{3}

on standard output.

This implies that all semantic processing is done by an external program.

============
Consideration 2: Some latex semantics might help

The INT type has only a single argument but many types have more than
one. We could modify selatex.sty to include multiple "required" arguments
where they are appropriate, as in,

\newcommand{\SQMATRIX}[2] ...

so that we could requires the correct number of arguments. This could
eliminate trivial errors.

============
Consideration 3: More latex semantics might help?

The first argument of SQMATRIX is a non-negative integer. The second
is anything of category Ring so we would see
SQMATRIX(3,INT)
SQMATRIX(3,COMPLEX(FLOAT))

It might be possible to let latex check that the second argument is in
the correct category. It is not clear how to encode such information
(or whether it is a good idea) in selatex. Some experiments need to
be done.

Ideas? Considerations? Suggestions?

Tim