% !TeX program = lualatex
% =====================================================================
%  math-language.tex
%  The language of mathematics, the way a teacher introduces it in one
%  chapter: the inline mini-language (fractions, powers, roots, Greek,
%  interpolation, the abs/norm/vec helpers), then the vocabulary needed
%  to *state* things — quantifiers and connectives, negation with a
%  single !, number sets, set relations, the integer part, and the
%  overline. lang=en keeps the decimal point; lang=fr gives a comma.
% =====================================================================
\documentclass[
  margins=18,
  font=Latin Modern Roman,
  size=12,
  linespread=1.4,
  lang=en
]{scholatex}
\begin{document}

let title = <Red b 18pt c>
let h1    = <Navy b section>

<title>scholatex — the language of mathematics

% =====================================================================
<h1>Products, comparisons, sums
% =====================================================================

Wrap maths in $...$. A few rewrites keep it light: * is a
product, +- a plus-or-minus, and the three comparisons are written
<<=, >>= and != inside a formula.

<box line:Navy fill:AliceBlue radius:3>{
	$a * b$, $x +- y$, $a <= b$, $c >= d$, $e != f$
}

% =====================================================================
<h1>Fractions, powers and indices
% =====================================================================

Fractions use / and chain left to right, powers use ^,
indices use _:

<box line:Navy fill:AliceBlue radius:3>{
	$1/2$, $a/b/c$, $x^2 + y^2 = r^2$, $x_1 + x_2$
}

Powers and indices bind tighter than division, as in ordinary reading: a
script attaches to the atom right next to it (its base), never to the whole
fraction. So the same four letters give four different readings, no
parentheses needed except to lift a script onto the fraction itself:

<box line:Navy fill:AliceBlue radius:3>{
	$a^2/b$ — the power stays on $a$ (numerator)
	$a/b^2$ — the power stays on $b$ (denominator), so this is $a/(b^2)$
	$a^2/b^2$ — both in place
	$(a/b)^2$ — parentheses lift the power onto the whole fraction
}

% =====================================================================
<h1>Roots and Greek names
% =====================================================================

Roots and Greek names need no backslashes:

<box line:Navy fill:AliceBlue radius:3>{
	$sqrt(2)$, $sqrt(x^2 + y^2)$, $alpha + beta != gamma$, $pi >= 3$
}

% =====================================================================
<h1>Interpolation inside maths
% =====================================================================

A value computed with ##{{...}} or ##name drops straight into
a formula, and the boundary is exact: a letter touching the value is never
swallowed into it, so a coefficient glued to a variable reads just as written.
The value also follows the lang option, so a typed and a computed
number always match.

let n = 7

<box line:Teal fill:MintCream radius:3>{
	$n = #n$, so $n^2 = #{n*n}$ and $n/2 = #{n/2}$
}

<box line:Teal fill:MintCream radius:3 title:{Values touching symbols}>{
	$#{n}x$ is seven times $x$, and $#{n}x^2$ keeps its power.
	Two values at once: $#{n} + #{n*n} = #{n + n*n}$.
	A half two ways: $1/2 = #{1/2}$, alongside the literal $3.5$.
}

% =====================================================================
<h1>Helpers: abs, norm, vec
% =====================================================================

In the spirit of sqrt(), three helpers wrap their argument:
abs(x) gives $abs(x)$, norm(v) gives $norm(v)$, and
vec(AB) draws a vector $vec(AB)$.

<box line:Teal fill:MintCream radius:3 title:{Vectors fall out for free}>{
	Chasles' relation $vec(AB) + vec(BC) = vec(AC)$, and the norm of a
	vector $norm(vec(AB))$, need nothing extra.
}

% =====================================================================
<h1>Number sets
% =====================================================================

A doubled capital is a blackboard-bold set, the way it is written on a
board. Doubling keeps it clear of any one-letter variable: $NN$, $ZZ$,
$DD$, $QQ$, $RR$, $CC$.

<box line:Navy fill:AliceBlue radius:3 title:{The usual chain}>{
	$NN subset ZZ subset DD subset QQ subset RR subset CC$
}

The advanced sets are there too — $PP$ for the primes, $KK$ for a field,
$HH$ for the quaternions, $FF$ for a finite field.

% =====================================================================
<h1>Quantifiers and connectives
% =====================================================================

The quantifiers are forall ($forall$) and exists ($exists$); the
connectives are and ($and$), or ($or$) and lnot ($lnot$). They
read as written, no backslashes.

<box line:Teal fill:MintCream radius:3 title:{A statement, set out in words}>{
	$forall x in RR, exists y in RR, y > x$

	$(P and Q) or lnot P$
}

% =====================================================================
<h1>Implication and equivalence
% =====================================================================

Implication and equivalence come both as words and as ASCII arrows, so you
write whichever reads better in place: => or implies gives $=>$,
and <<=>> or iff gives $<=>$.

<box line:Teal fill:MintCream radius:3>{
	$x = y => x^2 = y^2$

	$x^2 = y^2 <=> abs(x) = abs(y)$
}

The longer arrow always wins over the comparison it contains, so a chain of
inequalities and an equivalence sit on one line without parentheses:

<box line:Teal fill:MintCream radius:3 title:{A bounded-interval equivalence}>{
	$abs(x) <= 1 <=> -1 <= x <= 1$
}

% =====================================================================
<h1>Negation with a single !
% =====================================================================

One rule covers every negation: put ! in front of a relation or a
quantifier and it takes its struck-through form. So !in gives $!in$,
!exists gives $!exists$, !subset gives $!subset$, !subseteq
gives $!subseteq$, !equiv gives $!equiv$. The familiar != stays
"not equal", $!=$.

<box line:Indigo fill:Lavender radius:3 title:{Stating an irrational}>{
	$sqrt(2) in RR$ and $sqrt(2) !in QQ$
}

<box line:Indigo fill:Lavender radius:3 title:{No greatest integer}>{
	$!exists N in NN, forall n in NN, n <= N$
}

% =====================================================================
<h1>Set relations and operations
% =====================================================================

Membership and inclusion: in ($in$), subset ($subset$), supset
($supset$), subseteq ($subseteq$), supseteq ($supseteq$). Operations:
cup ($cup$), cap ($cap$), setminus ($setminus$), and the empty set
emptyset ($emptyset$). Negate any of them with !.

<box line:DarkGreen fill:Honeydew radius:3 title:{De Morgan, as a one-liner}>{
	$not(A cup B) = not(A) cap not(B)$
}

<box line:DarkGreen fill:Honeydew radius:3>{
	$A cap B subseteq A$ <3tab> $A subseteq A cup B$ <3tab> $A setminus A = emptyset$
}

% =====================================================================
<h1>The integer part
% =====================================================================

floor(x) and ceil(x) are the floor and ceiling, written with the
proper brackets; round(x) mixes the two. They wrap their argument like
abs, so a fraction inside behaves.

<box line:Crimson fill:MistyRose radius:3 title:{Floor and ceiling}>{
	$floor(3.7) = 3$ <3tab> $ceil(3.2) = 4$ <3tab> $floor(n/2)$
}

% =====================================================================
<h1>The overline: conjugate, mean, closure, negation
% =====================================================================

One overline, named by what it means. bar(...) is the generic bar — a
complex conjugate, a sample mean, the closure of a set — and not(...) is
the same bar read as logical negation.

<box line:DarkOrange fill:OldLace radius:3 title:{Four readings of one bar}>{
	Conjugate: $bar(z) = a - i*b$ when $z = a + i*b$.
	Mean: $bar(x) = 1/n sum(k=1, n) x_k$.
	Closure: $bar(A)$ is the smallest closed set containing $A$.
	Negation: $not(A cup B)$ is the complement of $A cup B$.
}

\end{document}
