About
LurchMath is an easy-to-write markup language for mathematics.
It extends a proper subset of AsciiMath, $\LaTeX$, and CAS software in natural ways.
It is currently under development, and more features will be added in the future.
Features
LurchMath currently supports a small subset of AsciiMath, $\LaTeX$, and notation found in CAS software. Many symbols can be displayed using a TeX command but a preceeding backslash is not required.
Symbols can be more than one character long, are case sensitive, contain only letters and digits, cannot start with a digit, and cannot be a reserved term. Multiplication must be explicitly entered with ⋅
, cdot
or *
.
English phrases such as Given
or declare
are case sensitive and will produce LaTeX with the same phrase in the same case. Spaces within an expression are usually ignored and can be used for legibility. The main exception is that there cannot be any spaces between a function and the parentheses containing its arguments in a function application expression.
A comma separated sequence preceeded by one of the Given
keywords has the same effect as saying that each of them is a Given
individually. The shortcut declaration Let x in A
has the same meaning as Let x be such that x in A
. The shortcut declaration P(x) for some x in A
has the same meaning as P(x) and x in A for some x
.
To declared the set operator $\{\ \}$ as a global constant use Declare set
. To declare the ordered pair, triple, or tuple operator $\langle\ \rangle$ as a constant use Declare tuple
.
Examples
If you type any of these | it renders as this |
---|---|
Logic | |
P and Q P∧Q |
$P\text{ and }Q$ |
P or Q P∨Q |
$P\text{ or }Q$ |
not P ¬P |
$\text{not } P$ |
P implies Q P⇒Q |
$P\Rightarrow Q$ |
P iff Q P⇔Q |
$P\Leftrightarrow Q$ |
contradiction →← |
$\rightarrow\leftarrow$ |
Quantifiers and bindings | |
forall x.x leq x+1 for all x.x leq x+1 ∀x.x leq x+1 |
$\forall x.\, x\leq x+1$ |
exists x.x=2 cdot x ∃x.x=2⋅x |
$\exists x.\, x=2\cdot x$ |
exists unique x.x=2*x ∃!x.x=2⋅x |
$\exists! x.\, x=2\cdot x$ |
x.x+2 x mapsto x+2 x↦x+2 |
$x.\, x+2$ |
Algebraic expressions | |
(x) | $\left(x\right)$ |
x+y | $x+y$ |
2+x+y | $2+x+y$ |
-x | $-x$ |
1-x | $1-x$ |
x*y x cdot y x⋅y |
$x\cdot y$ |
2*x*y 2 cdot x cdot y 2⋅x⋅y |
$2\cdot x\cdot y$ |
2*3*x 2 cdot 3 cdot x 2⋅3⋅x |
$2\cdot 3\cdot x$ |
1/x | $\frac{1}{x}$ |
2*1/x*y | $2\cdot \frac{1}{x}\cdot y$ |
(2*1)/(x*y) | $\frac{2\cdot 1}{x\cdot y}$ |
x^2 | ${x}^{2}$ |
x factorial x! |
$x!$ |
(n+1) choose (k-1) | $\binom{n+1}{k-1}$ |
multinomial(m,n) | $\left(m,n\right)$ |
sum k=0 to n of k^2 sum k from 0 to n of k^2 sum k to n of k^2 sum of k^2 as k goes from 0 to n sum k^2 as k goes from 0 to n sum k^2 as k from 0 to n sum k^2 for k from 0 to n sum k^2 for k to n sum of k^2 as k to n sum of k^2 for k to n sum( k^2 , k , 0 , n ) sum(k^2,k,0,n) sum(k^2,k,n) |
$\displaystyle\sum_{k=0}^{n} {k}^{2}$ |
Fib_(n+2) | $F_{n+2}$ |
Set Theory | |
x in A x∈A |
$x\in A$ |
x notin A x∉A |
$x\notin A$ |
{a,b,c} set(a,b,c) |
$\left\{\,a,b,c\,\right\}$ |
{ p:p is prime} set(p:p is prime) |
$\left\{\,p:\,p\text{ is }\text{prime}\right\}$ |
A subset B A subseteq B A⊆B |
$A\subseteq B$ |
A cup B A union B A∪B |
$A\cup B$ |
A cap B A intersect B A∩B |
$A\cap B$ |
A setminus B A∖B |
$A\setminus B$ |
A' A complement A° |
${A}'$ |
powerset(A) 𝒫(A) |
$\mathscr{P}\left(A\right)$ |
f:A to B f:A→B |
$f\colon A\to B$ |
f(x) | $f\left(x\right)$ |
f_(x) | $f_{x}$ |
f_(0)(x)_(n+1) | $f_{0}\left(x\right)_{n+1}$ |
g circ f g comp f g∘f |
$g\circ f$ |
A times B A cross B A×B |
$A\times B$ |
infty infinity |
$\infty$ |
[x,y] pair(x,y) tuple(x,y) ⟨x,y⟩ |
$\left\langle{x,y}\right\rangle$ |
[x,y,z] triple(x,y,z) tuple(x,y,z) ⟨x,y,z⟩ |
$\left\langle{x,y,z}\right\rangle$ |
[w,x,y,z] tuple(w,x,y,z) ⟨w,x,y,z⟩ |
$\left\langle{w,x,y,z}\right\rangle$ |
[[1,2],[3,4]] | $\left[\begin{matrix} 1 & 2 \\ 3 & 4 \end{matrix}\right]$ |
Union i in I of A_(i) Union of A_(i) for i in I Union(A_(i),i,I) Cup i in I of A_(i) bigcup i in I of A_(i) |
$\displaystyle\bigcup_{i\in I} A_{i}$ |
Intersect i in I of A_(i) Intersect of A_(i) for i in I Intersect(A_(i),i,I) Cap i in I of A_(i) bigcap i in I of A_(i) |
$\displaystyle\bigcap_{i\in I} A_{i}$ |
Relations | |
x lt 0 x < 0 |
$x\lt 0$ |
x leq 0 x ≤ 0 |
$x\leq 0$ |
x neq 0 x ne 0 x≠0 |
$x\neq 0$ |
m | n m divides n |
$m\mid n$ |
a cong b mod m a cong mod m to b |
$a\underset{m}{\equiv}b$ |
x~y | $x\sim y$ |
x~y~z | $x\sim y\sim z$ |
x=y | $x=y$ |
x=y=z | $x=y=z$ |
X loves Y | $X\text{ loves }Y$ |
X is Y X is an Y X is a Y X are Y |
$X\text{ is }Y$ |
P is a partition of A | $P\text{ is a partition of }A$ |
'~' is an equivalence relation | $\sim\text{ is an }\text{equivalence relation}$ |
class(a) | $\left[a\right]$ |
class(a,~) | $\left[a\right]_{\sim}$ |
'~' is a strict partial order | $\sim\text{ is a }\text{strict partial order}$ |
'~' is a partial order | $\sim\text{ is a }\text{partial order}$ |
'~' is a total order | $\sim\text{ is a }\text{total order}$ |
Assumptions and Declarations (case insensitive, phrase is echoed) | |
Assume P Given P From P Suppose P If P Define P :P |
$\text{Assume } P$ |
Let x | $\text{Let }x$ |
Let x in A | $\text{Let }x\in A$ |
Let x be such that x in RR Let x such that x in RR |
$\text{Let }x\text{ be such that } x\in \mathbb{R}$ |
f(c)=0 for some c | $f\left(c\right)=0\text{ for some }c$ |
f(c)=0 for some c in A | $f\left(c\right)=0\text{ for some }c\in A$ |
Declare is, 0, +, cos | $\text{Declare } \text{is}\text{, }0\text{, }+\text{, and }\text{cos}$ |
Miscellaneous | |
x^- x⁻ |
${x}^{-}$ |
@P(k) λP(k) |
$\mathcal{P}\left(k\right)$ |
Precedence
The precedence of operations from highest to lowest are given in the following table. There are a few fine points to be aware of.
- Exponentiation has higher precedence than function application. That is normally what is expected for something like $f^2(x)$ or $f^\text{inv}(S)$ but might not be what is expected for something like $z^{\sigma(n)}$. The first two can be typed as you would expect
f^2(S)
andf^inv(x)
while the latter would be entered asz^(sigma(x))
. - Summation has precedence higher than addition but lower than multiplication. Thus,
sum k to n f(k) + 2
is interpreted as $\left(\sum_{k=0}^n f(k)\right)+2$, whereassum k to n (f(k) + 2)
is interpreted as $\sum_{k=0}^n \left(f(k)+2\right)$.
Precedence (high to low) |
---|
parentheses $(~~)$, tuples $\langle~~\rangle$, equivalence classes $[~~]$, symbols, numbers |
exponentials $\left(x^2\right)$ |
function application $\left(f_0(x,y)(z)\right)$ |
postfix ($n!$, $f'$) |
negation ($-x$), reciprocal ($1/2$) |
product ($2\cdot x$) |
summation $\left(\sum_{k=0}^n f(k)\right)$ |
indexed union and intersection $\left(\bigcup_{i \in \mathbb{N}} A_{i}\right)$ |
sum ($x+y-1$) |
choose $\binom{m+n}{m}$ |
composition $\left(g\circ f\right)$ |
intersection ($A\cap B$) |
union ($A\cup B$) |
cartesian product ($A\times B$) |
relative complement ($A\setminus B$) |
relations ($f:A\to B$, $\underset{m}{\equiv}$, $\subseteq$, $\in$, $\notin$, $\mid$, $\leq$, $\lt$, $=$, $\neq$, $\sim$, 'is', 'loves') |
not ($\neg$) |
and ($\wedge$) |
or ($\vee$) |
implies ($\Rightarrow$) |
iff ($\Leftrightarrow$) |
binding ($x.P(x)$) |
quantified ($\forall x.P(x)$) |
declarations ('Declare', 'Let', 'for some') |
environment $\{~\}$ |