Repository navigation
Domains
satex runs TeX's machine over values that stand for sets of what a real run could hold.
Each domain below says what it abstracts and how it joins, narrows and widens.
When those happen is in SEMANTICS § 14.
This chapter builds on what TeX does. The formal model states both in Lean.
One invariant holds everywhere: a construct is followed exactly, or its result is over-approximated and a diagnostic says so. satex never guesses one outcome.
-
Valueand the set liftOneOf - Character codes, colors, meaning sets
- Modes and boxes, unknown text, category sets, argument types
- Files written in the run, names from unknown text, call summaries
- The join, precision limits, known limits, the soundness invariant
src/engine/value.rs: every kind has an exact value, a hull, a bounded set of either, and a top.
| Kind | Exact | Hull | Top |
|---|---|---|---|
count (\count, \numexpr) |
Int(i64) |
Num { lo, hi } |
the word [-2^31, 2^31-1]
|
dimension (\dimen, \dimexpr) |
Dimen(Scaled) |
Num, in sp |
the word [-2^31, 2^31-1] stored (Dim::ANY): box sums and \advance pass \maxdimen (tex.web §§ 656, 1238), [-MAX_DIMEN, MAX_DIMEN] scanned (tex.web § 461) |
glue, muglue (\skip, \muskip) |
Glue |
GlueHull: one Num per component (tex.web § 150) |
GlueHull::full() |
token list (\toks) |
Toks |
common start and end around one typed unknown token | Unknown |
color (\color@⟨name⟩) |
Color, every component a point |
Colors, one Num per component |
the model's full range |
The bounded set is OneOf for every kind (below). Code that does not inspect the abstract value reads a hull or set as Unknown (Env::value).
-
Numbers through text.
\the,\numberof a bounded number give one token of typed digits that carries itsNum. A later scan reads theNumback, so a bound survives text and a recursion over it ends. - Typed digits stay inside the interval their name spells, even after a widening join.
-
One token of typed digits is one number on a path.
\ifxcalls two macros equal when they hold the same tokens and all they hold of unknown is typed digits. Other unknown text may differ between copies. -
Tests.
\ifnumand\ifdimdecide by the interval,\ifpdfabsnumby the interval of the absolute values. -
Not zero. An interval around 0 may exclude 0 (
Num::nz, a reduced product with the sign). A failed test against 0 sets it, and a join or widening keeps it only where both sides exclude 0. So[-6,-1]joined with[1,6]is never 0 for\ifnum ...=0, and a number told apart from 0 has no one-digit arm0. -
Digits then typed digits (
9then digits in 331..350) read as one number in an interval: appending the digits ofdgrows withd, so the ends give 9331..9350. supp-pdf's register loop compares such a number. -
Digits then typed digits of either sign part by sign there. A
-ends the digits, so1\xis 1 and then-and the magnitude on one path, and more digits on the other (part_sign).\numexpr 1\xmay be below 0. -
Past the largest number the scan's interval stops at 2147483647, as TeX reads on at it (tex.web § 445):
1then any digits is 11 or more. -
Digits then one whole typed number, printed by
\number, are those tokens again, not a fresh number of their hull. TeX prints what it read, leading zeros dropped (§ 65). Where the value may pass the largest number, only typed digits a macro read whole to put them back together print so. So l3fp's\int_value:w 1 \token_to_str:N #1keeps the1that1 #1takes off again. -
Typed digits of any length read as one argument part as TeX reads them, one token per parameter (tex.web § 392): a path where TeX reads
-and then the magnitude, one where it reads0(part_signs), then digits 1 to 9 first by length as bounded ones (digit_arms). Pastlimits.digit_lengthslengths the longer ones are one arm, its length open. A read of that open rest parts the same way from its place (rest_arms): it is that one place, or the place and a rest that is never empty. Each arm narrows the number, and its slices scanned in order are the number again, so its bound survives. Only where no more paths may part by sign is the number one argument, under the assumptiondigits-read-as-one-token. A macro that only puts the argument back together with a delimited one after it (#1#2\sep) or tests its first character (\if #1-) reads it whole: that is the text TeX gives, and the test narrows the sign (rejoined_params). l3dim's\__dim_to_decimal_aux:wis such a macro. A rest of typed text that may be empty parts into an empty path and a path where it is not (split_rest). Where no more paths may part, the argument covers the text's first token and the argument after the text, which is TeX's on the empty text (tex.web § 392). The rest and that next argument stay in the input: nothing behind the text is gobbled, and on the empty text the next argument is read a second time (rest-or-next-argument, an assumption). -
A register of an interval number (
\newcountwhile\count10is an interval) keeps the interval for\meaning, which prints it as typed digits.\meaningof a macro holding typed digits gives them back as they are, like\string: they are category 12 (tex.web § 465). So a spec sanitized with\meaning(xcolor's\XC@edef) keeps its bound. -
Typed digits then a one-of (
\strip@pt's fraction): a scan splits the one-of per text where each is read in full or ends the digits. Other unknown text after them may be more digits, so the number reads on and is unknown. - Token lists past the set keep their frame: pgfmath's operand stacks with different tops join to one stack whose top is typed digits, so a delimited pop still finds its braces.
Value::OneOf is the one set lift Set_k(D) for every kind: a few values, each exact or a hull. {[0pt,10pt], [100pt,110pt]} stays two ranges, not [0pt,110pt].
| Operation | What it does |
|---|---|
| join | union of the members. Overlapping or touching intervals merge. At most limits.value_set (8) exact members, limits.interval_set (4) with an interval among them. |
| widening | past k, or with an Unknown side: the hull of all members (Value::join_hulls). Only the gaps are lost. |
| test |
\ifnum/\ifdim decide member by member. When members disagree, each arm keeps the narrowed part that passes (Num::narrow). The arms rejoin at \fi. A test of an expression that is one register plus a constant (\numexpr\count1-10) narrows that register by the bound minus the constant, in \ifnum and in each \ifcase arm. |
| arithmetic |
Num::lift on the hull: exact at a point, else the interval's corners (cut at zero). An overflow clips, a 32-bit wraparound (tex.web § 1238) widens to the whole word range. |
Macro bodies use the same lift as meaning sets (limits.meaning_set).
Every character has one of TeX's sixteen category codes (The TeXbook, chapter 7). Pages here link each "category N" to its row.
A character whose category is not pinned keeps the set of categories it may have, one bit each (CatcodeTable::unknown, tex.web § 232). A join unions the sets, the save stack restores them (per group, only the first save of a slot on each path joins: it is what the group's end leaves), and \the\catcode reads them as a set of numbers. Callers ask cats or is_unknown before trusting get.
The table a LaTeX format hands to the document is the kernel run's own for ASCII: latex.ltx's loops make ^^@ invalid (15), the control characters 1-31 active, tab a space, ^^J other and ^^L active. The format cache stores these codes. Codes 128-255 stay letters, a named limit: satex reads characters, where utf8.def makes the bytes active.
Code table entries (\lccode, \uccode, \sfcode, \mathcode, \delcode, tex.web § 1232) hold a Value, joined like registers.
- A ⟨number⟩ that is one of several characters reads as their hull plus the exact set (
abs_exact,src/engine/scan.rs). - A set with an invalid member, or any set for
\mathcode, becomesUnknown. -
\lowercase/\uppercase(tex.web § 1288) turn a character with a few possible codes into one token for the shifted characters, categories kept. An unknown code gives unknown text.
An xcolor color is Color { model, components }, one Num per component in xcolor's units. A binding holds Colors, a component-wise hull.
-
Join: the hull per component. Two models never join: converting would invent a value xcolor never stored, so the binding widens to
Unknown. - A few exact colors are a
OneOf, as for every kind.
After a join of paths that disagree, a Binding (src/engine/env.rs) keeps the possible meanings in may (at most limits.meaning_set). Code that does not look at the set reads the meaning as unknown.
| Operation | What it does |
|---|---|
\ifx, \ifdefined
|
decided when every member agrees |
| execute | splits the run into one path per meaning, limits.meaning_splits levels deep. Deeper, or inside an \edef, the meaning is unknown. |
\ifx against one meaning |
splits by answer, each side keeping the members that give it |
\if, \ifcat
|
each member gives its operand, behind \noexpand too: a character its code and category, any other meaning a control sequence (tex.web § 506). Decided when every member agrees. Without \noexpand an expandable member leaves the operand unknown. |
expand (\expandafter, \edef) |
a set of meanings none of which expands (fonts, \relax, registers) keeps the token as it is |
\let |
copies the whole set |
| format cache | stores the set with the meaning: installed without it, a kernel name such as LuaLaTeX's para/end hook would be unknown, and a maybe-undefined one certainly defined |
| widening | only where a later pass runs from the join, see the list below |
-
Only "undefined" added: a set that gained no defined meaning over what the head had (a name defined on one pass, not yet on another) stays the join, in either reach. It cannot grow further, so it is its own widening, and code in it (pgfmath's dispatch macros) is still run as code (
defined_grows). -
Where structure is kept (
Reach::Joined): a loop head's join, and a loop summary's join when the body runs once more from it. The members are every text a reaching path holds. A pass that writes another text reaches the loop again and widens further. -
Lists of names (texts of known control sequences only, such as LaTeX's float queues
\@elt\bx@A…) keep their set while it fitslimits.meaning_set, even when it grows. A float moves between lists, and its box stays a box. Past the limit they become one typed text that may hold their names in any order and number (names_hull, at mostlimits.text_namesnames). Running it runs\@elton those boxes, never unknown code. -
Texts with the same operators (
+,.) between runs at the same places keep them, with one typed token per run, before digit runs are merged.12+1and345+1widen to a printed integer,+,1. A-that begins a run is its sign. Runs alike in all texts stay as they are. -
Printed integers (
0, or no leading zero, after a-or not) widen to a printed integer of the most digits, after one unknown sign character where one may be negative (printed_hull). They never widen to digits that may read08. -
Texts of other shapes that differ only in digit runs become texts with typed digits, up to the set's bound. Slices of one printed number count as that number (
unslice). -
Everywhere else (
Reach::Havoc: a summary toward the loop's entry, a summary cut short, a call summarized by its effect, a group end not followed) an unseen write may be any text of its kind. Macros with the same prefixes become one macro of unknown text of their classes, length-bounded when all are (macro_hull), unless all members are one text. A set with "undefined" keeps it. Anything else is an unknown meaning.
A widened macro whose members all hold a token holds one too, so \ifx can still tell it from a primitive, a character or a macro with parameters. Typed text that may be empty does not count as a token, and a token for one of several texts joins by the class of those texts.
Example: after \ifx\a\b \let\next\foo \else \let\next\bar \fi, \next may be \foo or \bar. \ifx\next\relax is undecided. Executing \next splits into two paths that join again later.
Modes (src/engine/mode.rs) is the set of TeX's six modes the run may be in (tex.web § 211). \ifvmode, \ifhmode, \ifmmode and \ifinner are decided when every mode agrees. Paths join by union.
Dim { lo, hi } is one length: box sizes, added up as hpack (tex.web § 649) and vpack (tex.web § 668) do. An item satex cannot follow widens the size to Dim::ANY. It is never left out.
-
Join. Each length joins to its hull. A word still being set on one path keeps its last character pending (it may kern or form a ligature with the next one, § 1034). If the paths differ there, each pending character is settled first: its box plus every kern the font may put after it, from any character or the boundary (
settled_for_join). One that may form a ligature cannot be settled, and the sizes widen. - Unknown digits. A digit the run wrote as unknown is a box from the narrowest to the widest of its candidates, plus every kern the font may put on either side. One that may form a ligature is unmetered.
The list's tail (Last) is what \lastskip, \lastkern, \lastpenalty and \lastnodetype read:
| Tail item | Kept |
|---|---|
| glue | width as Dim, specification as GlueHull, whether it is mu glue (tex.web § 424) |
| character | its box, and whether it is a ligature (exact where the font's lig/kern program was followed, §§ 1034–1040) |
| rule, insert, adjust, whatsit, math, noad | its \lastnodetype (3, 4, 6, 9, 10, 15) |
| box | hbox or vbox where the packing tells it, which \lastbox takes back (tex.web § 1080), also after \unvbox. A paragraph's last line is an hbox unless a mark, insertion or \vadjust may follow it (tex.web § 655). A box of unknown kind, or an item that may be a box, is never read as no box. |
| mixed kinds |
Last::Unknown, still holding the join of each reading (zero where of another kind) |
Where the tail is not known at all, an engine quantity is still in its own range, never any word: \lastnodetype from -1, \badness 0..1000000, \currentifbranch -1..1, a glue order 0..4, each bound wide enough for every engine's codes (last_item_range).
A list also counts the items it holds at least, so an internal vertical list with items left never reads -1 (tex.web §§ 1080, 1105).
The tail is a window of the last four items. A box before another on a vertical list brings its interline glue (tex.web § 679). A box register keeps the window too: the last item, and the glue, kerns and penalties right under it (an inexact glue keeps its kind and hull). \unvbox and \unhbox put the window back, \box and \copy carry it, and \box255 takes the main list's at a break. So \unskip, \unkern, \unpenalty and \lastbox after an \unvbox see what TeX uncovers (tex.web §§ 1105, 1110).
Each item of a vertical list's window can hold the list's size before it. Glue and kerns appended to the list have it. So have the items of a recorded list that \unvbox put on. Taking such an item off restores that size exactly (tex.web § 668). Glue or a kern over glue or a kern takes its width alone, the depth under it being zero. Any other removal leaves the size unknown.
A box register holds width, height and depth as Dims, read by \wd, \ht, \dp.
| Material | How its size is followed |
|---|---|
| characters | TFM width, height, depth, kerns and ligatures. A font without metrics widens. |
| native characters | XeTeX and LuaTeX (luaotfload) fonts by file ([file]:features). See the list below the table. |
hpack / vpack
|
height, depth (resp. width) start at zero (tex.web §§ 649, 668). vpack moves depth past \boxmaxdepth into the height. \vtop (tex.web § 1087), \vcenter (tex.web § 736). |
| inline math | characters, \mathchardef atoms, italic corrections, class spacing (tex.web §§ 752–766), \mathsurround (tex.web § 1196). Operators on the axis, with scripts or limits (§§ 749–751), \left…\right with delimiters sized by var_delimiter and extensible recipes (§§ 706–714, 760–762), math accents (§ 738), groups as boxes a script sits on (§ 1186). Delimiters around a list of unknown height hull every variant a height in its interval picks. A delimiter or accent that paths join apart, \middle, and lost groups widen. |
| display math | the paragraph's lines before it (tex.web § 1145), then the penalties, skips and the formula's box in display style (§§ 1199–1205), \prevgraf plus three. \predisplaysize is not followed: each skip is the join of the normal and the short one. A number beside the formula joins with one on its own line unless it surely fits. Display style takes an operator's successor and limits, sup1, \mathchoice's first list. A display-style fraction widens. |
\unhbox, \unvbox
|
the natural size recorded at packing (tex.web § 1110), the tail kept, an hbox's recorded items go back onto the list, so a paragraph breaks them |
\write, \openout, \closeout
|
nothing when \immediate, else a whatsit (tex.web §§ 1352, 1375) |
\pdfextension |
a whatsit or nothing, of no size (LuaTeX manual, "PDF extensions") |
\discretionary |
its unbroken text (tex.web §§ 651, 1119) |
| unknown box |
Dim::ANY for all sizes |
-
Native characters. XeTeX and LuaTeX (luaotfload) fonts by file (
[file]:features): advances,GPOSpair kerns andligaligatures of the features certainly on (the engine's defaults and the name's), glyph bounding boxes. XeTeX rounds a word's width once in single precision, LuaTeX each glyph and kern. A glyph another lookup or a TECkit mapping may change is the font's hull: every advance, kern and glyph it may become. A font with contextual lookups, AAT tables or variations is all hull. luaotfload's\fontdimens are intervals over the choicesfontloader-font-otl.luamakes. -
Recorded lists. An hbox records its items for
\unhbox. A vertical list records its items (boxes, rules, interline glue, glue, kerns, penalties, whatsits, marks). With a record,\vsplitrunsvert_breakexactly (tex.web §§ 968–977). Without one, the split part is packed to the asked height and the rest is bounded. -
The page's list. At a forced break
\box255gets the page's record as its list: without the break's penalty, with the\topskipglue before its first box or rule (tex.web §§ 1001, 1017). Only a record that adds up to the page's natural size counts. A page with a paragraph on it has no record: paragraphs are kept as a line count and sizes. -
Forced breaks. A vbox register knows whether it may hold one.
\vsplitto\maxdimenof a list without one takes it whole (tex.web §§ 972–974). -
What the output routine leaves. Its list goes before what waits, and the page builder goes on over it (tex.web § 1026). A recorded list with a forced break in it goes item by item: glue, kerns and penalties on an empty page are dropped (§ 1000), and a forced penalty on a page that holds a box fires the routine again (§ 1005). What follows that penalty waits for the routine's end, ahead of what it leaves in turn. So LaTeX's
\vbox{}\clearpagein the second column ships the page. A list without a record counts as a whole, as before: a forced break in it is not fired (a known limit). -
\vadjustbreaks. A paragraph keeps the forced breaks its\vadjustmaterial carries, in order, each with whether a box came before it. Repeats share one run: any number of floats in one paragraph is one pair counted (up to 7 runs, past that the last run stands for the rest, a known limit). After the paragraph's lines they reach the page builder as that material (tex.web § 889). The page builder decides whether one finds the page empty (tex.web § 1000). -
Main vertical list. Tracked from the empty page (tex.web § 991): discardables on an empty page drop (tex.web § 1000), the first box or line takes
\topskipglue (tex.web § 1001),\pagetotalis the length moved so far, without the glue and kerns still waiting (tex.web §§ 1003, 1004), page dimensions read back until material arrives (tex.web §§ 1004, 1245). A page whose first box follows a whatsit can break at its\topskip(tex.web § 973), which LaTeX's\clearpagerelies on. -
\badnessof a box packed to a size comes from its glue orders (tex.web §§ 658–667).
Marks are exact where the lists are recorded: \topmarks, \firstmarks, \botmarks per class from the page lists, the split marks from the part \vsplit took (tex.web §§ 979, 1012–1014). Otherwise a class holds a OneOf of the texts given so far or empty. A mark of a class satex cannot name makes every class unknown.
A paragraph in a vertical box is broken as line_break does it (tex.web §§ 813–890). Para holds the range of lines made so far.
| Case | Result |
|---|---|
| forced breaks (penalty ≤ -10000) | exact (tex.web §§ 851, 879) |
| all items known, plain parameters | Knuth-Plass in all three passes (tex.web § 863, src/engine/linebreak.rs): line count, sizes and \prevgraf exact |
| fits with infinite stretch, or badness bound low enough | one line (tex.web §§ 817, 851–859) |
| otherwise | one line up to one per breakpoint, that bound rounded up to a power of two, sizes between zero and the text's. The rounding keeps the bound, and the page's length with it, as it was when a word is typed into the line: the run after the edit meets the last one past the paragraph |
- Line width is
\hsize. With\parshapeor\hangindentit is unknown (tex.web §§ 847–848), except a\parshapewhose lines are all alike. -
\parshapereads every line its count names (tex.web § 1248) but keeps only the firstlimits.parshape_lines. A later line reads back unknown (\parshapelength). A count the budgets stop before its last line leaves the whole shape unknown. - At
\par: final glue dropped,\parfillskipadded (tex.web § 816). Interline glue from\baselineskipor\lineskip(tex.web § 679), both joined when either may apply.\prevdepth(tex.web § 219),\parskip(tex.web § 1091). -
\prevgrafis the vertical list's own (tex.web §§ 216, 1244): a vertical list of its own (\vbox, an insertion, an alignment, the output routine) starts at 0 and gives the enclosing list's count back at its end. -
Hyphenation (tex.web §§ 919–965) uses the format's own
\patternsand\hyphenation(src/engine/hyph.rs). Each found gap is a may-hyphen (·in the typeset view). A one-line paragraph gets none (tex.web § 902). An unknown language or\lccodemarks every gap. A ligature hyphenates by its letters (tex.web § 898). Inside it the discretionary breaks to its first letters and the hyphen, then the rest (tex.web §§ 913–916). - Line parameters are read at
\par. If they changed after a line was set, the sizes widen.
Unknown text has a class: the set of token kinds it may hold (src/engine/tex.rs). Classes are ordered by inclusion.
| Kind | Letter | Tokens |
|---|---|---|
DIGIT |
d |
0–9, category 12 |
SIGN |
s |
+ - . ,, category 12 |
LETTER |
l |
category 11 |
OTHER |
o |
other characters that open no group |
SPACE |
_ |
category 10 |
BRACE |
b |
balanced braces |
CS |
c |
control sequences and active characters: anything |
HEX |
h |
a restriction: its letters and other characters are 0–9, A–F, a–f
|
unknown text all kinds (top)
cs-free text d s l o _ b
dimension text d s l
number text d s
typed digits d, with an interval [lo, hi]
-
Named control sequences. Typed text may also name the control sequences it may hold (at most
limits.text_names, past themc). With no class besides, it is a list of names: any sequence of them, perhaps empty. A join of more lists thanlimits.meaning_setis one such text, and a one-of token of lists of names spells their names too, so a later join keeps them. A join unions the names, so a widening of such lists ends. Executed, it runs its names asmay_rundoes. A\defthrough it may define each of its names, since its first token is one of them. It is never a name built around a gap, though its names follow gap markers. An argument scan takes one token of it and leaves the rest typed with the same names. -
Why it matters. A scan delimited by
}finds nothing in text withoutb. One delimited by a space finds nothing without_.\ifxagainst a letter cannot match withoutl. Nothing withoutcis a control sequence. -
Delimited scans. Text holds a whole delimiter only where its kinds give every token of it (braces in typed text are balanced, so they never match). Text that gives only part of it can only straddle it: the scan reads on and ends past the text where the delimiter's tail follows (
hides_delimiter,straddles). A one-of whose texts all end in the delimiter's start ends there without a fork. -
Own rests. A call site that ended an argument inside typed text puts the rest back. When the same site gets that rest again (a recursion that peels it), its fork is keyed by the site and the rest, so the levels are passes of one loop head and forced convergence ends them. Both arms stay (
Scratch::split_rests). -
Typed digits carry their
Num:\ifnum,\numexprand\csnameread the interval back. -
Hex.
his kept only withloroand withoutc. A join keeps it where both sides are hex (digits-only text is).\detokenizekeeps it unless braces or names print. One character ofhtext has a code in0–f, so`#1<"80is decided. -
Cover. Text that covers several texts has the union of their kinds and names. A one-of token in them counts as what covers each of its texts, so the control sequences they hold stay in the cover: the rest put back after an argument ended inside a one-of may hold the delimiter again. Its length is not kept, so a join of loop passes does not grow with every pass. A one-of text that holds its own token adds nothing new (the least fixpoint), and past
limits.meaning_setnested one-of tokens there is no cover: the text is unknown. Every walk into one-of texts goes through one guard (one_of_nested): a repetitiontext*holds its own token by construction, so the length bound, the first meanings,\detokenizeand the tagging values end the same way: a token the walk is inside of adds nothing or is unbounded, a nesting past the bound is any text of its class. Texts may name the one-of below them many times, so the walk is a tree far larger than the texts. Each one-of it opens counts againstlimits.walk_textsper step, and past it a token is nested too deep. Walks through macro bodies (closing,signs_only) pay the same budget, so every walk inside one step is bounded and its work counts against the line. - Join is the union of kinds. The text is non-empty only if both are. A run of unknown tokens collapses into one token of the run's class. Widening moves up and stops at the top.
-
Printing.
\detokenizeand\stringgive the printed class (tex.web § 464). - One constructor makes all unknown text:
Machine::unknown_text.
Stubs name these elements: nothing, number / { number: [lo, hi] }, dimen, { text: digits | number | dimension | cs-free | any }, box / { box: { width, height, depth } }.
| Character | May be |
|---|---|
UNKNOWN_CHAR |
a digit or - (the first character \the prints for a number) |
UNKNOWN_DIGIT |
0–9
|
UNKNOWN_NONZERO |
1–9
|
UNKNOWN_HEX_OTHER |
0–9, A–F, a–f, category 12 |
UNKNOWN_HEX_LETTER |
A–F, a–f, category 11 |
\the never prints an integer with a leading zero (tex.web § 65). Reading the first digit of an unknown number splits into - (digits follow), 0 (nothing follows) and 1–9 (one digit fewer may follow), so a digit-stripping loop ends.
-
\romannumeralof an unknown number is typed text of classo. In a small interval it is one of its numerals. - At the end of a ⟨number⟩ scan, paths that differ only in numbers join to typed digits over the hull.
- A number starting with a known digit has no sign: it lies in 0 to 2³¹-1 (tex.web § 445). A known last digit decides
\ifodd. -
\theof a dimension, glue or muglue prints typed digits of its integer part, a point, at most five digits and its unit (printed_dimen). Without an interval the integer part is any of ±16383 (§ 103). A value that may be negative may print-0.5pt: its integer part roundsloaway from zero, and a read's-arm includes the magnitude 0. Scanned back, it is an interval (§§ 448–458), so bounds survive\pgf@sys@tonumberand pgfmath'sround,floor,int. The fraction's token names its print: the magnitude's interval in sp and the typed number its integer digits are (fraction_of). A scan that reads that number whole, a point and that fraction alone reads the print's own interval, in any unit, met with what a test left of the integer digits. So\theof a dimension in 0pt to 9pt read back is never past 9pt. After other digits it is any fraction. -
Fractions a dimension scan reads hold their bound: typed digits of one width spell their interval's ends at their places, so
.then digits in 8..9 is 0.8pt to 0.9pt and the digits after. Past other unknown text the least ends with the digits before it, the most takes 9s, as many as the text may hold and for all digits after it (17 kept, § 452). So.99999and one digit more may round to1pt. -
\theof an unknown glue prints its width, then a one-of token for the parts that may be nonzero: nothing,plus ⟨d⟩⟨unit⟩,minus ⟨d⟩⟨unit⟩or both (tex.web § 178). A glue scan'splusandminuskeywords split it per text, so\vskip\the\skip@never leaves part of it as typeset text.
A one-of token stands for one of a few texts (a joined \@currenvir, v plus a or b).
- A read that splits it (
\ifx,\csname, a scan, a keyword) narrows it on each path to the texts that path took (split_one_of_groups,src/analysis/machine.rs). Every copy on that path, in a macro, an argument or a name being built, then holds those texts. - A
\csnamewhose paths join inside the name keeps per name what each path took, and narrows again when it parts per name. - A token read from a macro a join left one of several texts (
\exp_after:wNon a joined\g_x_prop) remembers that macro while every make of it read it unchanged (Carried::owners). When its texts differ in the control sequences they run, not only in data, a split narrows the macro too, and a delimited scan that would cut every text into a part before and after the delimiter parts per text instead, since two separate tokens lose which part goes with which. So a property list tested flat on a path is flat when the put reads it again. Texts that differ only in data (pgfmath's digits) stay joined. - A delimited argument never ends in a known text without the delimiter (tex.web § 392). So a delimited scan over a one-of token with such a text next to others parts by kind: texts with unknown text that may hold the delimiter, known texts without it, known texts with it (
scan_one_of). The last end the argument at their own delimiter, each with its own rest. Where the scan still ends in the token as unknown text, the argument takes each text up to its first delimiter, never a text with its delimiter (split_prefix). - A
\csnamethat may not part again keeps a one-of token of characters as one of the names it spells. That name holds one of their meanings, an undefined one\relax. A definition of it may give each of those names its meaning. - At a join, a copy narrowed to one text is that text, so arms that took different texts join as texts.
- Two paths joined while both read on in one token list get a one-of for the text before that list's common end, and the end stays that list itself (
keep_list,src/analysis/machine/explore.rs). A later call read from it is then no pass of a loop entered in it. - A literal of a library macro's parameter text met at a one-of token where no path may part (
literal_rests) takes the texts after it as one one-of. Texts that cannot begin with it, and an empty text when the next token is another, would raise "doesn't match its definition" in library code, so they are dropped (assume_compiles). Unknown text before such a literal begins with it the same way, without a fork. - An argument that is one such token, used more than once in its macro, is one choice: its uses share a mark, and a read that takes a text narrows the marked copies still waiting in that call to that text. A token made from the same texts elsewhere is another choice and stays.
- Only a token made once is narrowed. Made again, or once passes of a loop were joined since, its copies may stand for different choices.
Typed text may carry a maximum token count (LEN_MARK, at most 20).
| Source | Bound |
|---|---|
\the/\number of a count |
11 (tex.web § 65) |
\the of a dimension |
14 (tex.web § 103) |
| a value in an interval | the digits of its larger end |
| the rest after reading one token | one less, 0 is no text |
| a join | the larger bound, a collapsed run sums them |
A loop pass that has strictly less left to read is not counted against limits.widen_after (pass_bound), so such loops run exactly to their end. Less means fewer lines left in the open \read streams, or as many and less pending bounded input. Typed text counts by its bound, one of several texts by its longest text. So a loop that peels records off a list joined from lists of several lengths (l3str's c \s__str N \s__str records of a string of unknown length) reads every record exactly, and no pass widens the list to text that lost its separators. A loop over a file satex wrote (scrlayer-notecolumn's .slnc read-back) thus reads each line exactly, and no join of its passes turns a line's text into code. A loop summary widens what its passes wrote against the loop's start: bounds no pass moved stay, moved ones go to the end of their range, and a widened token list keeps its frame.
Wild (src/analysis/machine.rs) holds the families of names a definition of a partly unknown name may have made (tex.web § 372): the known text around the unknown part, as in \csname MT@inh@\x\endcsname.
- A name of such a family may be undefined,
\relax(a\csnamemay have made it), or one of up to 8 meanings the family's writes gave. A write that leaves two or more parameterless macros keeps their hull, one macro of typed text: a text appended to per record read (a note per line of a file) would grow the set with the input. Families join by union. Past 1024 they widen to what they share. - A name read from partly unknown text is
\relaxor one of the meanings its family's writes and its defined names of that shape hold, up tolimits.meaning_set. More are any meaning. Run, it parts a path per meaning, the family's writes among them (any meaning parts none), so a conditional saved under\romannumeralof an unknown depth (xkeyval) still opens the level its\ficloses. - A call by such a name may reach a macro of more parameters than it was written for. The list that holds its arguments ends them: parameters past it are unknown text, and the code behind the list stays code (pgf's
\pgf@colmarshal). - A name around one number's typed digits is that number's own name:
\tl_map_inline:nndefines and calls the same__tl_map_⟨n⟩:wexactly. Another definition that may hit the same name joins into it (a weak update). - A number in a small interval spells a name per value, a path each. That split narrows the count register the digits were printed from, when it was not written since, and the name scan remembers it. Paths that join after defining one name each then stay paired with the register, so the call at the depth the map runs at finds its own definition.
- A definition may reach every name with a meaning that its unknown part can spell: the known text around it, characters of the part's class, as many as its length allows. Each such name may now mean the new meaning too (a weak update). Past
limits.text_namessuch names none is touched, and the name is assumed to redefine none of them (unknown-name-defines-fresh, an assumption). - A name of wholly unknown text adds no family. It is assumed fresh (
unknown-name-defines-fresh, an assumption): it defines no undefined name. Otherwise one such definition would make every\ifcsnameundecided. The rest of the run rests on that assumption: an error after it is a possible one (When a finding is certain). Its text must have a bounded length to reach names with a meaning.
src/analysis/roles.rs types each argument of a command by what TeX read it as. The record numbers them by their place in the usage line, optional ones counted.
A type stands for the texts an argument may hold, so a type is below another when every text it admits the other admits too.
The order follows tex.web's scanners: scan_int (tex.web § 440), scan_dimen (tex.web § 448), scan_glue (tex.web § 461), a register an assignment names (tex.web § 1224), a box number (tex.web § 1079), get_r_token (tex.web § 1215).
A register's name is text of its value's kind, because a scanner reads the register's value there (tex.web § 413). A dimension is glue without stretch.
flowchart LR
t0["any"]:::top
t1["quantity"]:::quantity
t2["number"]:::quantity
t3["dimen"]:::quantity
t4["glue"]:::quantity
t5["muglue"]:::quantity
t6["box"]:::quantity
t7["register"]:::register
t8["control sequence"]:::cs
t9["conditional"]:::cs
t10["options"]:::key
t11["date, at least"]:::text
t12["text"]:::text
t13["name"]:::text
t14["definition body"]:::text
t15["overlay specification"]:::text
t16["tl variable"]:::expl3
t17["str variable"]:::expl3
t18["clist variable"]:::expl3
t19["seq variable"]:::expl3
t20["prop variable"]:::expl3
t21["fp variable"]:::expl3
t22["bool variable"]:::expl3
t23["regex variable"]:::expl3
t24["coffin variable"]:::expl3
t25["flag variable"]:::expl3
t26["intarray variable"]:::expl3
t27["cctab variable"]:::expl3
t28["count register"]:::register
t29["dimen register"]:::register
t30["skip register"]:::register
t31["muskip register"]:::register
t32["toks register"]:::register
t33["box register"]:::register
t34["read register"]:::register
t35["write register"]:::register
t36["counter"]:::register
t37["dimen name"]:::register
t38["skip name"]:::register
t39["muskip name"]:::register
t40["toks name"]:::register
t41["box name"]:::register
t42["read name"]:::register
t43["write name"]:::register
t44["key"]:::key
t45["label"]:::key
t46["citation key"]:::key
t47["option key"]:::key
t48["pgf key"]:::key
t49["environment name"]:::key
t50["declared key"]:::key
t51["index entry"]:::key
t52["color name"]:::key
t53["code language"]:::key
t54["file"]:::file
t55["TeX file (.tex)"]:::file
t56["package (.sty)"]:::file
t57["class (.cls)"]:::file
t58["bibliography database (.bib)"]:::file
t59["bibliography style (.bst)"]:::file
t60["biblatex bibliography style (.bbx)"]:::file
t61["biblatex citation style (.cbx)"]:::file
t62["theme (.sty)"]:::file
t63["graphic file"]:::file
subgraph g0_register[" "]
direction LR
t7
t32
t33
t34
t35
end
t0 --> g0_register
subgraph g8_expl3[" "]
direction LR
t19
t20
t21
t22
t23
t24
t25
t26
t27
end
t8 --> g8_expl3
subgraph g12_text[" "]
direction LR
t11
t14
t15
end
t12 --> g12_text
subgraph g13_register[" "]
direction LR
t36
t37
t38
t39
t40
t41
t42
t43
end
t13 --> g13_register
subgraph g44_key[" "]
direction LR
t45
t46
t47
t48
t49
t50
t51
t52
t53
end
t44 --> g44_key
subgraph g54_file[" "]
direction LR
t55
t56
t57
t58
t59
t60
t61
t62
t63
end
t54 --> g54_file
t0 --> t1
t1 --> t2
t4 --> t3
t1 --> t4
t1 --> t5
t2 --> t6
t0 --> t8
t8 --> t9
t0 --> t10
t0 --> t12
t12 --> t13
t8 --> t16
t16 --> t17
t16 --> t18
t2 --> t28
t3 --> t29
t4 --> t30
t5 --> t31
t13 --> t44
t13 --> t54
classDef top fill:#eef0f2,stroke:#8a8f98,color:#1f2328
classDef quantity fill:#dbeafe,stroke:#3b82f6,color:#1f2328
classDef register fill:#ffedd5,stroke:#f97316,color:#1f2328
classDef key fill:#ede9fe,stroke:#8b5cf6,color:#1f2328
classDef file fill:#ccfbf1,stroke:#14b8a6,color:#1f2328
classDef cs fill:#fee2e2,stroke:#ef4444,color:#1f2328
classDef expl3 fill:#fef9c3,stroke:#ca8a04,color:#1f2328
classDef text fill:#dcfce7,stroke:#22c55e,color:#1f2328
The diagram follows Ty::parent, one colour per family: the top any (grey), quantities (blue), registers (orange), keys and options (purple), files (teal), control sequences (red), expl3 variables (yellow) and text (green). Each type is its own node. Three or more types below one parent, with none below them, stand in one stacked cluster. nothing is below every type and left out. The labels are the ones signatures and hovers show. In each example the ⟨…⟩ part has the type. The table names the type above only where the label does not show it.
| Label | Meaning | Example |
|---|---|---|
any |
no information, the join of unrelated types | |
quantity |
a number, dimen, glue or muglue |
\numexpr1+⟨\dimexpr 1pt\relax⟩ is read as a quantity |
number |
⟨number⟩, read by scan_int
|
\penalty⟨100⟩ |
dimen |
⟨dimen⟩, read by scan_dimen, below glue
|
\kern⟨2pt⟩ |
glue |
⟨glue⟩, a dimen with optional stretch and shrink | \hskip⟨1pt plus 1fil⟩ |
muglue |
⟨mudimen⟩ or ⟨muglue⟩ | \mskip⟨3mu⟩ |
count register |
a count register an assignment names, below number
|
\advance⟨\count@⟩ by 1 |
box |
a box register's number, below number
|
\setbox⟨0⟩\hbox{} |
dimen register |
a dimen register an assignment names, below dimen
|
\advance⟨\parindent⟩ by 1pt |
skip register |
a skip register an assignment names, below glue
|
\advance⟨\parskip⟩ by 1pt |
muskip register |
a muskip register an assignment names, below muglue
|
\advance⟨\medmuskip⟩ by 1mu |
toks register, read register, write register
|
the other registers an assignment names | ⟨\toks@⟩={a} |
register |
a register of a kind the text does not fix, what a body assigns #1 to |
\def\x#1#2{\advance⟨#1⟩ by #2} |
text |
balanced text of any kind | \textbf{⟨a name or code⟩} |
name |
characters forming a name, below text
|
\csname ⟨foo⟩\endcsname |
counter |
the name of a LaTeX counter, c@⟨counter⟩, below name
|
\setcounter{⟨section⟩}{1} |
⟨kind⟩ name |
the name of a register of that kind a \csname forms |
\csname dimen⟨foo⟩\endcsname |
key |
a key of no known kind, below name
|
\mykey{⟨x⟩} of unknown role |
label |
a label a command defines or references, below key
|
\ref{⟨sec:intro⟩} |
citation key |
a bibliography entry's key | \cite{⟨knuth84⟩} |
option key |
an option or key a key list names | \usepackage[⟨draft⟩]{x} |
pgf key |
a key pgfkeys stores under its family's path, below option key
|
\draw[⟨thick⟩] is /tikz/thick
|
environment name |
an environment's name, below key
|
\begin{⟨itemize⟩} |
declared key |
a key a document command declares and others read by its name, below key
|
\gls{⟨graph⟩} after \newglossaryentry{graph}
|
index entry |
a term an index or glossary program sorts, below key
|
\index{⟨source⟩} |
file |
a file of no known kind, below name
|
\input{⟨a⟩} read as .bib and .tex
|
TeX file (.tex) |
a file read as TeX source | \input{⟨chapter1⟩} |
package (.sty) |
a package | \usepackage{⟨amsmath⟩} |
class (.cls) |
a document class | \documentclass{⟨article⟩} |
bibliography database (.bib) |
a BibTeX database | \bibliography{⟨refs⟩} |
bibliography style (.bst) |
a BibTeX style | \bibliographystyle{⟨plain⟩} |
biblatex bibliography style (.bbx) |
a biblatex bibliography style | \usepackage[style=⟨authoryear⟩]{biblatex} |
biblatex citation style (.cbx) |
a biblatex citation style | \usepackage[citestyle=⟨numeric⟩]{biblatex} |
theme (.sty) |
a package the code names by a prefix around the text, below file
|
\usetheme{⟨Madrid⟩} |
graphic file |
a figure, its extension decided by the run | \includegraphics{⟨fig⟩} |
control sequence |
a control sequence an assignment defines | \def⟨\foo⟩{} |
conditional |
a conditional \newif defines, \if⟨name⟩, below control sequence
|
\newif⟨\ifdraft⟩ |
tl variable, seq variable, prop variable, fp variable, bool variable, regex variable, coffin variable, flag variable, intarray variable, cctab variable
|
an expl3 variable, by the module of the function that made or set it in the run (\tl_set:Nn, \seq_new:N) |
\tl_set:Nn⟨\l_my_tl⟩{x} |
str variable, clist variable
|
a string or comma list, which expl3 keeps as token lists, below tl variable
|
\str_set:Nn⟨\l_my_str⟩{x} |
options |
the key list a load takes in its optional argument | \usepackage⟨[a,b]⟩{x} |
overlay specification |
text a command reads between < and >, beamer's overlay specification, below text
|
\only<⟨2-⟩>{x} |
definition body |
a definition's replacement text, code, below text
|
\def\x{⟨\kern1pt⟩} |
nothing |
no text, below every type |
-
Join: the nearest type above both (
Ty::join). A dimen and a skip register giveglue, a label and a citation key givekey, a.biband a.texuse givefile. The lattice is a tree, so disagreeing uses never stay a set. -
expl3 variables. A name a definition reads (
get_r_token) while a module function of a variable kind runs (\tl_…:N…,\seq_…:c…) is a variable of that kind: what the run did, not the name's suffix. Register-backed kinds (int,dim,skip,muskip,box,ior/iow) are registers of their kind. -
Where types come from. A scanner's read of the argument (
Facts::types, joined per place). Else its role (a label is akey, a load afile,\bibdataa.bib). Else its macro's body (roles::assigned, tex.web §§ 1057, 1224):#1after\penaltyis a number,#1heading an assignment aregister,#1inside\csnameaname. -
Overlays and themes. Text a macro's parameter text reads between literal
<and>(\def\a<#1>) is anoverlay specification, so beamer's\only<2->is typed by its code, not by its name. A package a load names behind a prefix of the code's own (beamertheme⟨name⟩.sty) is atheme. - Wrappers inherit the types of arguments they hand on whole.
- Use. Types order what an editor offers. They add no narrowing to the run: the scanners already read into the value domains.
satex writes nothing to disk. A run's written files live per path in Outputs (src/analysis/machine.rs).
| State | How it arises |
|---|---|
| known text |
\immediate\openout empties it, each \write appends a line. An \immediate \write token for one of several texts parts the path per text, so each writes it exactly. Other unknown parts are written as one character per class, which reads back as that class. \scantokens reads its text back the same way: it is a file the run wrote. |
| deferred | a \write, \openout or \closeout without \immediate is a whatsit (Whatsit): its stream is read now, its text kept unexpanded (tex.web § 1352). \shipout, a page without output routine (tex.web § 1023) and the end of the run (tex.web § 1054) run the whatsits in order, a text expanded in the environment then (tex.web §§ 1370, 1374), after the shipout hooks ran. A token for one of several texts writes each text, the files joined. |
| unknown text | a \write to a stream number not pinned adds a line of unknown text to every open file |
| any file, text outside the run | a \write18 program whose command line names no output (-o, --outfile) may write any file (ANY_OUTPUT): from then on any file name may exist, its text unknown. An \input of it is not followed, and the path is marked read_outside: no later error on it is certain. |
| a set of texts | paths that wrote it differently: texts whose lines pair one by one join line by line (join_written), so each differing line keeps its values and the file is not kept once per combination of them. Texts that set different things stay apart, up to limits.meaning_set. A read parts the path per text. Past an \input of such a file every path has the same source progress (the file's length), so the paths join where they meet again. |
-
Whatsits join as a set of lists, one per alternative (
join_pending). At shipout each list runs from the same files, and the files join. Pastlimits.meaning_setlists, oneLostwhatsit: every open file may get any lines, and the opens and closes the lists held may happen. -
Join past the bound (
either_text): pastlimits.meaning_settexts, the nearest two join (join_written): two sharing the most lines (nearness). Texts of another shape stay apart. Lines align on what they set (command and first argument, a longest common subsequence). Equal lines stay. Paired lines keep their common start and end around one unknown character. Digits apart in as many places join digit by digit (a nonzero or any digit per place), so a page number keeps its length. Read back, such a digit is a digit (category 12), whatever its code's category. Lines that differ on both sides of a brace, with the same braces, keep them: each part between braces joins on its own (a label's page and value,{2}{\z@}against{3}{\@ne}, stay two braced parts). A stretch between of unequal length is one unknown line. An unknown line absorbs the one before it, so joins settle. -
The build's files (
.aux,.toc,.bbl, …) belong to the run and are kept in an overlay. The build reruns until they stop changing (challenge 11,limits.build_runs). A changed file sends the build round again only when the run read or looked for it. Every file a run wrote goes to the overlay, as TeX leaves it on disk, so the next run reads a part.auxthe main.auxfirst names, not a missing file. The first run reads none of them, so the second run changing lines is expected. One file it may make itself: the bibliography tool's.bbl, when it first looks for it, from what it cited so far (bib.early, on). The build compares it with the file made from the whole run, so a later citation changes it and the build goes round again. A file in which a run afterlimits.build_widen_after(2) changed an existing line again is widened: each text a later run writes joins into its nearest (widen_text,nearness), so the number of texts does not grow. A text an earlier run wrote too (the runs cycle, a page that flips) keeps its digits place by place. A new one (the runs grow, a counter written back) widens them to any digits, so the build settles a run sooner. Files an engine left on disk are read only withload.build_files. - Reads see the run's files first (tex.web § 537), then the disk. A file neither written nor on disk is absent (tex.web § 1275).
-
\openinstreams hold the texts each may read and where in each it stands, an interval of lines. A join keeps both sides' texts and the hull of their places. Widened, a place that moved may be anywhere up to the text's end.\ifeofand\readpart the path per place, each exact. Pastlimits.value_setplaces the stream is unknown. An unknown line stands for any number of lines, none too:\readof it gives unknown text and leaves the stream on it, after it, or one line further (closed past the end), and before unknown lines only\ifeofis undecided. A stream number in an interval parts the path per stream (tex.web § 435).
src/analysis/machine/calls.rs summarizes a call by its effect, so parsers that read unknown text one token at a time (pgfmath, l3fp, calc, listings) converge after two runs.
| Step | Rule |
|---|---|
| key | the macro's definition, the call site, the control sequences in its arguments |
| record | the first limits.call_summary_after (2) runs over unknown operands run the real body and record the names written and read. Runs over known operands are not recorded. Calls a scan expands are not recorded either. |
| apply | from the third call, if an operand is unknown text or a meaning set: the recorded writes are joined, widened (widen_slot) and assigned. The body is skipped. One call-summarized imprecision per key. A name a run read but did not write, with a precise value then, must hold that value now for at least one run, else the call runs. Any name counts, not only count registers. |
| relate | a name every run left as the same text of its own arguments' typed numbers (slices spelling one whole count as it) gets that text of this call's numbers, not the widened join. \pgfmath@bgroup@strip of a new number thus keeps it whole and typed. |
| own | the key ignores characters, so \cnt+1 and max(\cnt,10) share one. A write that holds tokens of its run's arguments, where this call's arguments differ, describes no other call: the call runs. |
| never | runs that read on in the file, change a catcode, leave a group, conditional or mode, add to a list, write different names, accumulate (x then x…), update a macro or token list they read before writing it (a stack push or pop: what it held below differs per call, and runs that agree say nothing of it. A register they update is no reason: its joined value widens to its range), or leave code rather than data. Such a key always runs the real body. |
A macro that peels unknown text at a delimiter puts the rest back and splits it again on the next level. Past limits.rest_splits (8) splits of one rest at one site, that rest counts as having no more delimiters, so the loop ends.
A parser that reads an unknown number forks at each digit, and no digit model ends that. Its runs on other values already show what it leaves, and each is a run of the real code. So a run of a definition that keeps forking stops there and leaves what those runs left. A call whose operands are known forks nowhere, so it always runs for real. An unknown operand reached through a register, a macro or \the is found where it first decides something, with no look at the arguments.
| Step | Rule |
|---|---|
| key | the definition's code, not its name or site: \let copies share it |
| learn | every run the main loop expands is recorded until limits.call_learn_after (2) runs on different arguments have ended. A run may close the group around its call, and may end in \ignorespaces. A run that forked counts too, each arm that ends it apart, or their join: the arms decided on different values. A run with a loop summary inside counts as well (a soft record): the summary over-approximates the loop, so the run over-approximates the call. Such a run only teaches its definition, it is never a site summary. |
| writes | the names a run left changed at its end. A local write made deeper than the groups open at the end was undone by a group end (tex.web § 283), whatever stamp a resume gave the name. Groups merged by a widening move their writes down with them. The writes are read from a log. A token read from a file starts it over, and past limits.write_log entries it is folded to each name's first write and every later one made less deep: a run that began before either teaches nothing, a loop met again widens every name in it. |
| refuse | a run that teaches nothing, for good. See the list below the table. |
| cut | at the limits.call_learn_forksth (2) undecided choice of a run: the outermost running call with a learned effect ends there (learned_cut). Its text goes, what it opened closes, what it wrote in the closed groups goes back. |
| apply | number text becomes a printed number (printed_dimen), a register any value, a flag the runs disagree on either meaning. What all runs left the same stays. |
-
Refuse. A run that reads on, changes a catcode, leaves a conditional or the mode, adds to a list, writes a name it was handed or nothing at all, or runs that disagree on the names or the group. Runs teach only what has a type to widen to: each name holds a number or a flag, or stayed the same, and one holds a number (in some run, if the others left it vague). Runs that forked or hold a summary may disagree on the names and on untyped values: the lesson takes every name any of them wrote, and a name they disagree on, where one run already left it vague (joined or unknown), that every run wrote before reading it, or that some run left alone (state such as pgfmath's seed, joined with what it holds at the call), becomes the join of the runs, widened. A name written first is an output (
\toks0,\pgfmath@temp): its value at the call did not matter. A read logs the stamp of the binding it saw, so a read of a binding from before the run marks the name as state. Precise state texts that differ were chosen from data and still refuse. The soft run's unknown rest may have been typeset: the lesson keeps that, so its cut forgets the list's size.
This is the named assumption call-learned-effect (analysis.assume_call_learned_effect): the call writes what its runs wrote, and raises nothing on the unknown value. If no run has taught it anything, the call runs as before. Sampling the type's values instead would need a machine snapshot and a run per sample at each call. The runs a document makes anyway cost nothing.
A drawing calls the same producers again and again: a key handler, a point computation, a loop over the same list. A run on known values is a function of what it read. So a main-loop call that ran limits.call_memo_steps steps (200 by default) keeps its effect, and a later call of the same code on the same arguments, while every name the run read holds what it held, makes the run's assignments instead of running. Nothing is approximated: a replay leaves the state the run would leave.
| Step | Rule |
|---|---|
| where | the document's body, by LaTeX's own test (\@nodocument is \relax), so the front matter counts and the preamble does not: its facts go into package caches, which a replay must not tell apart from a read. Plain TeX is all body. Only a call the main loop expands itself: one that \expandafter or a scan expands runs its text later or never, so its effect does not stand where it is called. |
| key | the code and the argument tokens. A token of the user's own file matches only at its own place, since the kept values may carry it. |
| record | every name the run read, raw slot reads included, with what it held before the run's first write to it. |
| keep | a run that ended whole, met no choice, named no unknown value of its own and changed only names. See the list below the table. |
| replay where | the mode, the lists, the categories, the pending prefixes and the certainty are as the run met them. The conditionals open around the call and its group's \aftergroup tokens are not compared: a run cannot read them (\currentiflevel is a side effect that keeps nothing), only a run that closes the group needs its tokens. The brace count is compared inside an alignment cell, where it is read against the cell's. |
| end its caller's group | a run that closes the group its caller opened (pgfmath's \pgfmathparse opens it, its parser ends it with \endgroup and hands the result out) keeps its effect up to that \endgroup, when the group held no box or \aftergroup tokens, nothing below its text was read, and its text has only tokens left. Only global writes outlive the group. A replay makes them, closes the group and reads the tokens left. |
| apply | each name the run left written is assigned again, global if the run wrote it only globally, local if only locally. A name written locally and then globally is assigned globally: the global value holds at every level (tex.web § 283). A local write after a global one would need both values and is refused. The records around the call see the reads the run gave them, no more: a run reads some names only for its own key (raw slots, the analysis's own looks), and a summary that saw those would take the run for one over unknown values. A kept occurrence holds only where the call raises it at the same place and it is still said just before. The build-cost findings count the steps a replay stands for. |
| verify |
limits.call_memo_verify runs each call a kept effect stands for and prints where the run's writes, read log or steps differ. |
| bound |
limits.call_memo_variants (4) states per key, the oldest giving way, limits.call_memo_bytes (256 MiB) in all, all dropped at once past it. A definition whose first limits.call_memo_probes (8) runs all were short or unclean is no longer recorded. |
-
Keep. A run that ended whole on one path and in the group it began, read nothing past its text, left the lists, conditionals, categories, pending prefixes and
\aftergrouptokens as it found them, and made no report, new occurrence, file, output, stream, box text or user-file fact. An occurrence it said again (one said just before, at the same place) is kept with the place it was raised from. It must not read the clock, the generator, the input line or the lists' tail, must meet no undecided choice, since those are decided by what the line met before, and must change no slot other than by an assignment. It may read a value it could not know (an unknown register, a joined meaning, unknown text): with no choice met, what it wrote holds for every value that read stands for, and a replay compares the read as it compares any other. But it must not have given an unknown value a name of its own (the digits\theprints of an interval, a rest of unknown text,Machine::mints): a name is one value, a test narrows it alone, and a replay would give another call's value the same name. It runs where definitions are as certain as where it ran.
Inside a package that is cached, nothing is kept: a replayed load runs no calls, so a cold and a warm run see the same.
A package cache stores a load in segments. Each segment is a function of the state it found. Three kinds of dependence, from weak to strong:
| The load | Stored as | Served where |
|---|---|---|
passes a value on: a count set from another, \advance/\multiply/\divide on it, \the of it or an engine text (\jobname, \pdfcreationdate) inside an \edef
|
an expression over the values found (its leaves), or a hole in the text | everywhere the expression has a value. It is computed again there |
tests such a value with \ifnum
|
the relation and its outcome (a guard) | where the guard comes out the same |
looks at it any other way (a macro argument, a name built from it, \ifx) |
the exact value (a digest) | where the value is the same |
- The run itself stays concrete: a value is never made unknown for the cache. The expression is kept beside the slot, in the read log.
- Any plain read of such a slot turns its expression into exact reads of its leaves. So does a write that a group end or a rewound path may undo, and a write to a leaf. A missed case costs reuse, never soundness.
- Expressions use TeX's arithmetic (tex.web §§ 1238–1240). A segment whose expression overflows where it is served is read instead.
- The clock (
\year,\month,\day,\time), the job's start date and the job name are values the load finds, like any binding. One cache file serves every date and every job.
One check bounds every run, whatever the precision: Machine::check_budget charges every step (token read, driver pass, replay) to the source line being read, summed over all paths. A replayed package charges no line.
| Overrun of the line's budget | Effect |
|---|---|
| first | the expansion unwinds, what it wrote widens to typed unknowns, an unknown token stands for its output, the line reads on (line-budget-cut) |
| later | the rest of the line is skipped (stalled-line-skipped), and the run goes on with the next line |
| later, no line to skip to | the run stops (budget-exhausted) |
A line's budget is limits.line_steps in the preamble, where a line loads a package, and at most limits.text_line_steps in the body, where it typesets. A file holds finitely many lines, so a run spends a bounded amount per line read, plus a constant. Every bound is a fixed count, never a share of the total budget, so cuts land in the same places.
A widened expl3 variable keeps the shape of its kind. Its name gives the kind (\l_x_fp is an fp). The ends that all the kind's constants share (\c_zero_fp, \c_nan_fp, ...) stay, around typed text of the classes between them. So an fp stays \s__fp \__fp_chk:w … ;, and the module's parsers find their delimiters. This is the named assumption variable-kind-shape (analysis.assume_variable_kind_shape): only the module's functions write such a variable. A kind whose constants share no end (tl) widens as before.
A float of unknown height parts the output routine at every \ifdim that tries to place it. Followed, the routine ran once per arm of every float, tens of paths stood side by side inside one shipout, and a thesis never ended. Widening there was no better: it made what the routine wrote unknown, fonts and file lists included.
So where floats and page parts land is assumed, not followed. Past limits.output_forks choices in a run (0 by default), a choice undecided inside an output routine, or in the text of a \clearpage around one, takes its first arm and parts no path: a float fits where it is tried, a loop around a page clear ends (analysis.assume_page_one_arm, reported as page-one-arm). What the other arms would do is not followed, so an error only they raise is not reported. The arm taken learns no value from its test (no path took the other arm): a page count compared with the last page's number stays the interval it was, where it had become that number and was written to the .aux as such.
Calls nested deeper than limits.call_rec_depth are neither learned from nor summarized: the record stack is shared between paths, so its length is the cost of a call. A choice inside a value scan counts against limits.site_forks times limits.scan_site_factor: a scan's arms join where it ends, but a walker over unknown text forks per token.
Rules that keep cuts sound and convergent:
-
Paths. A path parked before a cut takes the same cut later. A
\csnamesite that partedlimits.meaning_settimes on one line keeps the names as one family on one path. That name may mean\relaxor any meaning of its family, never\relaxalone. - Loop entries. A summary unwinds only to where its loop was entered. A head met after the entry's caller read on is a new entry, so a summary never closes its caller's groups. So is one met at another place of a copy of the caller's text: an enclosing loop's next pass replays it (beamer's slides of one frame).
- Page loops. A head met again after an output routine fired, while an enclosing loop passed since, is a new entry of that loop's next pass. It is not counted, and its heads from earlier pages are dropped. Only the outermost loop joins and summarizes passes that ship pages, so the output routine's own tests are never summarized per page.
-
What a pass wrote is compared against the fork's binding, so a name set back (
\thepagearound\protected@write) is not widened. The body runs once more from the widened state before the cut, so names it opens arrive as a family. - Paths a summary covers are widened toward its state, except code: a path that carries the summary, stands in no more groups than the loop head and wrote a macro after the summary keeps that macro. The head's code belongs to another point of the program.
-
Loop exits in a scan (
\edef,\expanded): the cut continues on a path that already left the loop with the same text. Without one it reads one unknown token and skips to the scan's}. A cut that drops no expansion in flight keeps the braces and characters the scan copies before its first expandable token, so\expanded{ {…} }cut at its start still gives one group. A}the scan's own text lacks comes from code below it (\if_false: { \fi: },\iow_wrap:nnnN): the lists below are skipped to the first call whose text closes a group it never opened, its arguments unknown, and its text after that}runs. Never source. Scan cuts are per path. -
Endless loops (
limits.cycle_after) end a path only when another path covers it. Else it is summarized and goes on. A call in a loop's body repeats with the loop, so the cut goes to the loop: the outermost expansion opened since the call's last round. A\writerun at shipout counts as a change no slot holds: the file it writes grows. -
Loops over unknown text (
limits.widen_after) need not fork: a delimited argument split off unknown text puts its rest back as a fresh rest with a new serial, so no round meets the last one's state exactly, and a round that writes nothing leaves no call summary. A call whose arguments hold such rests, met again in its last round's state but for its rests (by class, a run of them as one), is such a loop. Afterwiden_afterrounds in a row it is cut like a recursion: what it wrote since it was met again may hold anything, its expansion is unknown text. It is never reported as an endless loop, since TeX may end it. - Unwinding drops token lists and closes the conditionals and groups their text opened (tex.web §§ 281–283), widening values a group restores. Levels left open become stacks as intervals.
- The output routine is a unit: an open output group (tex.web § 989), flushed with its conditionals when it ends (tex.web § 1100).
An edit reruns little. The run resumes at the last saved state whose input is unchanged. It stops where its state meets the last run's again: from there the last run's rest is this run's. Nothing is approximated, the result is the full run's.
| Step | Rule |
|---|---|
| resume | at the last saved state that read nothing changed. A file it has open must begin as it did. A project file's size is one unknown number per file, 1 to 2³¹-1, or 0 for an empty one: \IfFileExists and \include ask for it before they open the file (l3file's \file_full_name:n), and an edit must not change what they read. Two reads of one file are one token, so the test of name against name.tex is decided. |
| place | the first edit at a place finds no state of the last run nearby. The old text is run again from the state before it, only to save states: one at the edit's line, limits.checkpoints_after_edit on the first lines past it between paragraphs. It is the last run again, checked by the files it reads. It looks at most limits.checkpoint_meet_steps steps past the edit, and no further than the last run's next state between paragraphs (one inside a paragraph cannot be met). The language server does this ahead, while idle, for the line of the last request at the caret (a code action, a highlight, a completion): the edit that follows finds its states placed (placedSteps 0 in satex/runInfo). The run stops for any message. |
| meet | at a line start between paragraphs where the last run saved a state with the same text left to read. Modes, lists, conditionals, groups, saves, files written and held, names, facts and the graph must be equal. Counts that are absolute (source read, assignments, groups) compare by how long ago when made since the runs parted. |
| delta | bindings may differ. Per name the run keeps the step of its last read or write. A name the last run's rest never touched keeps this run's binding to the end. One it touched ends the reuse, and the run goes on. |
| lists | a recorded list (a paragraph's items, a page's boxes) is named by where it was made. The run begins with every list the last run made, each under its name, so one list has one name in both and its own new lists come after. Without that the runs do not meet. |
| names | a name is numbered at its first use. The run begins with the last run's names too, so a name both runs use has one number and a name only this run makes comes after. A name is only ever asked for its meaning (tex.web § 259), so more names change nothing. Typed digits are still named by the step they were made at, so an edit before them renames them and that stretch runs again. |
| records | what the run keeps outside its analysis for its end (lines written, names read, names defined from keys) is spliced like the fact rows. A row raised in a package's file by a call on an edited line is that line's. The places the run keeps of what it read last must stand off the edited lines. The splice works on a copy of the last run's end: where a row does not splice at one line, a later line may still meet. |
| rest | reused only when every file the last run read after the meeting line still holds. An edit the rest has yet to read is run. |
| splice | the last run's records after the meeting line follow this run's. Character offsets move by the edit's length: the characters set alike before and after the edited ones align. Rows and graph vertices on the edited lines are this run's. |
| bound |
limits.checkpoints, limits.checkpoint_steps, limits.checkpoint_body_share, limits.checkpoint_memory. They change how far a rerun resumes, never a result. |
An edit that adds a fact row or a graph vertex (a new \label, a typed command) does not meet: later rows are numbered by position. The run then goes on to the end. The page that holds the edited paragraph meets once it has shipped.
Every domain joins the same way: hull plus bounded union. Keep the exact members while they fit the limit, else take the hull. Never fail.
-
Undecided splits (a conditional, a meaning set, a mode test) run each arm separately, then join the environments, globals included. With
arm_joins(default), arms inside an\edefbody join where they meet in the body: twelve tests are twelve splits, not 4096 runs. -
What a join keeps. A name one arm defined is that definition or undefined. It runs with the definition, and each run is a possible "Undefined control sequence", hung on the conditionals its definitions hang on (tex.web § 370). A test of it (
\ifx,\ifdefined,\ifcsname) parts the arms by its answer. Registers join their values. A group's end restores what either path saved there. Only a path that saved nothing there leaves its current value in the join (tex.web § 283). Paths in different groups join in the groups of the path that goes on. A summary goes on in the groups of its last pass. A group only the other path stood in leaves its writes at the joined level. Differing catcodes or pending\afterassignment/\aftergrouptokens keep paths apart, up to two per place. Differing pending prefixes (\global,\long,\protectedon one path only) keep them apart until the assignment took them. -
Scheduling. The path furthest behind runs next, so paths that can meet do. Paths at a join point (
analysis.join_paths_at, the end of an output routine) wait there until the running path has passed them: further on, between two commands, in their mode, so their texts meet. Then they join and run on as paths behind. A path at an output routine's end inside a command waits on, since the command may fire the routine again (a\clearpageloop). No path is dropped: the end state joins every path that ended (one gap remains, see Known limits). Ends that wait to run different code still join their effects, never pick one. - Text given back. A scan that gives up (an argument taken to end in unknown text) gives back the document text it read by moving the file back, not by holding the tokens. The path then stands where one that never read the text does, so both meet where the statement ends. Held tokens would count as read, and the path would stay ahead of the others to the end of the file.
-
Definition facts. A definition site several paths ran records the text each path last gave it: one text, or a one-of token of them (past
limits.meaning_set, or with differing parameters, unknown text). Hover andexplainlist them. A path running the site again replaces only its own text. Each run of a command past its first is a new path. - Overfull facts. A line or box packed too wide (tex.web § 666) is recorded at the user's call that ended it. Visits of one call join to the most an exact visit (no undecided conditional, one path, every width known) was too wide. A visit that is not exact, or whose width is not known, makes the call unsure, and the layout lints skip it. A visit that fits changes nothing: an exact run's visits all happen.
-
Loops reach a fixpoint: each round joins into the head's state, and the head reruns while it grows. The list being built counts as state: a join whose list length (the list's, or a paragraph's lines') differs from the head's grows. Widened, a length that differs becomes any. One pass then runs from the widened state, and its exit covers the passes not run. After
limits.widen_aftergrowing rounds the state widens (meaning sets to unknown, intervals to the 32-bit range, others toUnknown), so every loop ends withinwiden_after + 2rounds (undecided-loopotherwise). A head that still grows is summarized after2 × widen_afterwidened rounds.
A join that is not widened keeps its arms paired (Corr, src/engine/env.rs): per arm, the bindings of the names that differ. pgfmath's operation stack and its top differ together. Joined apart, a later split pairs neg with a stack that never held it (a false missing number).
- Learning one paired name narrows the others to the arms that allow it. An undecided test of a joined switch teaches each arm the switch's value (
\iftruewhere it holds), so the names paired with it follow. - An expanding scan (
\edef,\expanded) that expands paired names settles them at its end: when every arm gives the same text, with each name's text in its place, that text is the result (two float lists copied together hold the float once). Each expanded on its own, the copies would pair arms no run has. Arms that differ keep one token per name: a common start and end around one token for either middle would cut a macro's argument apart. - A name written after the join leaves the pairing. Past
limits.join_armsarms, the name with the most bindings leaves first. - Arms only remove combinations no arm had, so the join stays sound.
A group or conditional frame may stand for any number of copies (many). A loop that opens a group per pass would otherwise never meet itself: [G] and [G, G] widen to [G, G*].
- Only plain groups opened since the paths parted, with the same
\aftergrouptokens, are widened. - The many frame goes where the stacks differ, not on top. Innermost groups both paths opened at the same place (a macro's own group, met by sibling paths in different depths) stay above it:
[A, B]and[A, A, B]widen to[A, A*, B], soB's\endgroupstill restores what was set inB. -
\currentgroupleveland\currentiflevelread an interval while amanyframe is open. - A closer meeting a
manyframe parts two paths: a copy closes (saved names widened), or none is left and the closer acts below.
Arms of an undecided conditional that reach its \fi go on as one path (fi_mark, partner in src/analysis/machine/explore.rs). The conditional is identified by its \if… and the stack depth below it (tex.web §§ 489, 498).
- Data becomes an interval or set, differing macros a meaning set, a one-arm macro "that body or undefined". All definitions stay recorded as facts.
- Arms that leave another way (
\expandafter\@firstoftwo) join at the next common place. - A read of typed digits splits them into a path per sign, one digit and each longer length.
- A literal of a parameter text meets them the same way (
\def\a-#1). - Where no path may part, a required
-takes them negative and their magnitude follows. - Arms that learned different values of one such number stay apart until as many paths wait at the place as the split made, or the statement ends.
- Joined earlier, pgfmath's digit loop pairs one arm with another a pass behind it.
- Paths whose stack of braced groups differs in depth stay apart as well (
stack_depth): pgfmath's operation stack holds{neg}on a negative number's path only, and joined, a pop would take one path's top with the other's rest. -
\futureletkeeps bounded typed digits that begin with a digit whole, so the read after it parts them. - Digits that may begin with
-part at the\futureletin a path for the-and one for the digits alone, so its token is never both. - Digits of any 32-bit length (a lower bound under ten, no upper bound), on each side of zero they have, are not split:
\futureletsees their first digit and the rest as untyped digits. - Where no more paths may part, a read takes their longest spelling, one place per read (
digits-read-longest), so a macro never holds many digits as one character.
- A literal of a parameter text meets them the same way (
- The one-digit arm is a one-place slice of the number: a join brings back the whole token's interval, which no longer spells one digit.
- Typed digits spell
-?[0-9]+. A delimiter of two tokens or more without a digit neither lies in them nor begins in them (--), so a scan passes them. A later place, a fraction or a rest is digits only: only a whole number that may be negative holds-. - A test whose interval straddles its constant splits it:
\ifdim [0pt,345pt] > 100ptgives[100.00002pt,345pt]and[0pt,100pt], joined back at\fi.
| Limit | Past it |
|---|---|
limits.choices per command |
the conditional is widened: both arms skipped, one unknown token in their place (undecided-condition) |
limits.choices inside an expanding scan of text (\edef, \expanded) |
the scan ends as a whole: its pending expansions go, what it opened is closed, and the rest of its text is one unknown token for all its paths (undecided-condition). An expanding scan assigns nothing, so the token covers every arm. Skipping only the conditional would let the code after \fi (l3fp's parser) run on text no arm made |
limits.alike waiting paths at one place |
paths whose input differs only in text join |
limits.paths |
the two furthest back are cut to their shared input levels and joined |
| fork backstop at a hot site | no new arm, except for paths a look-ahead parted that cannot be joined (other input): they get their arms, since following one would be unsound. Under a cut one is followed and the cut summarizes the region |
| fork backstop at an argument end | a delimited argument that may end at a place or read on. For the call's last parameter one path reads on: the argument from that place is unknown text covering both ends, and what the other end leaves to run, its delimiter too, may run (unforked-argument-end). Before another parameter, and at a literal of the parameter text, the arms leave the input at different places, which no path covers: the hot site does not refuse that fork, a one-of split there either. A one-of whose split is refused at the call's last parameter is read on like unknown text, its end covered alike |
Paths join between two commands where they stand alike: same input, conditionals, groups and scans (absorb). Measured on a TikZ node with unknown height, limits.alike 8 takes 2.8k forks, 16 takes 5.1k.
Joining pending code into unknown text keeps what it may do (may_run):
-
Undefined names after
\def/\letthere may now be defined, as fresh names. -
Registers it assigns may hold any value: count, dimen, skip, muskip, toks, and every one of a kind when its number is not known. So may the parameters, catcodes and code table entries it sets.
-
A register it only reads keeps its value: the operand of
\the,\number, a test or an expression, and the value after a target (\escapechar\m@ne). -
Havocking those made LaTeX's
\m@neunknown. -
A name
\csnamebuilds of characters is that name, one of more is a name of unknown text around the known characters. -
A defined name that code gives a new meaning holds the join of both.
-
\letto a known name joins that name's meaning, so\let\if@tempswa\iffalseleaves the switch undecided. -
Any other definition joins an unknown meaning.
-
A definition or setting inside a group the code opens and closes is left out, a
\globalone,\gdefor\xdefis not. -
Reached macros are followed
limits.may_run_depth(3) levels deep, and a report says when more were reached. -
Reported as
joined-code-may-define. -
A name of unknown meaning that runs does the same over the macros a join left it one of.
-
One of no known shape is reported (
unknown-text-run). -
Differing input joins as shared text around one token for either part. Each part must be whole: balanced braces, conditionals closed (
whole). -
Only data joins that way. Paths whose pending code differs never join until a common point. Code differs only between passes of one loop.
-
The same code is not the same when the paths bind its names apart. Two paths of one parser whose
\pgfmath@parse@nextreads the next token in two of its states stand at different points: pastlimits.alikethey wait on, not joined (reads_alike). Joined, the token and the text it reads lost their pairing, and the parse read a+as a number. -
A path raising an error with an exact cause (a certainly undefined name) is dropped: the document is assumed to compile. Library code that redefines
\fidrops its path too. One rule decides every such refutation (may_refute): only a fault library code opened, never during a probe or once no path compiles (errors kept). A dropped path waits in case no path compiles. It is settled once the running path, alone, closed the file the fault stood in or reads on in a later line of it (settle_closed): kept longer, it held the fork open and no later line of a package was a checkpoint for its cache. -
A scan library code opened that runs past the main file's end on a path that is kept says the analysis ended early (
analysis-ended-early), not that the document lacks its end. A chapter's end, or a refuted path, hides nomissing-end. -
A cut keeps the lists holding the document's own text, and one in an output routine ends only the routine (tex.web § 1100). The list the cut command was reading goes in any case: it stands mid-command, and a loop body copied into
\iteratewould otherwise run on, the conditional it opened still open. -
A call dropped in text a cut left takes its arguments with it. A
\fithere of a conditional open below may have been TeX's, so that level becomesmany: closed or still open (unbalanced-conditional, an assumption). -
A conditional widened past
limits.choicesreads the tokens its arms' last macros take past its\fionly when they are whole on every text they stand for. A one-of token with a member that closes a conditional (a\fian argument read took from a rest that may be empty) stays in the input and runs, a path per member, so no\fiis lost in data. -
A conditional's level ends with the file it began in. A skip of it that reaches that end past an approximation ends there too, with the levels its skipped text opened (
unbalanced-conditional, an assumption). Without an approximation the skip reads on as TeX does (tex.web § 336). Whether one came is counted per open conditional, by its level on the stack and its\if…, so a recursive call of the same code never vouches for the outer one. No count: unsure.
The limits: settings in satex.yaml trade precision for a bounded search (src/project/config.rs, details in Configuration). Past each, the value moves up the lattice and a diagnostic says so. Time, memory and thread limits never coarsen a result: they only stop a run.
| setting | default | what it bounds |
|---|---|---|
limits.choices |
8 | How many undecided \if one command may split into paths. Past them the command's result is unknown text, reported as an assumption. Higher keeps more combinations apart and costs time. |
limits.site_forks |
64 | How many paths one place in a source line may start, counted over all paths. Past them an \if there is no longer followed both ways: the run takes the effects either branch may have (site-forks-widened). Lower finishes a \foreach with unknown bounds sooner but knows less. 0 turns it off. |
limits.digit_lengths |
3 | How many digit counts a number of unknown digits is read apart into, one path each, when TeX reads it digit by digit (\the\count of 0..214: one, two, three digits). Past them the longer counts are one path whose count stays open. Higher is more precise where code compares or prints the count, and forks more for wide ranges (\int_rand:n {16777215}). |
limits.parshape_lines |
64 | How many lines of a \parshape satex keeps, each its indent and length. TeX reads every line the count names (tex.web § 1248). The lines past these are read but unknown. A count no budget reads to its end leaves the shape unknown. Higher keeps long shapes. |
limits.paths |
16 | How many alternative paths satex keeps at once. Past them the two oldest at one place are merged into one. Higher is more precise, slower and takes more memory. |
limits.meaning_splits |
4 | How often one command may split the run per meaning of a name that has several, such as \x defined differently in two branches. Past them, and with 0, the name reads as unknown. |
limits.widen_after |
3 | How many rounds a loop is followed exactly before values that still change become ranges (SEMANTICS § 14). A \loop counting to an unknown bound has its counter as a range after these rounds. |
limits.recursion_depth |
100 | How deep a macro that calls itself while an \if is undecided is followed before the recursion is assumed to end there. |
limits.loop_heads |
512 | How many loops one run remembers with their merged states. Past them the oldest is forgotten, and summarized when it comes back. |
limits.call_summary_after |
2 | After this many runs of one call at one place, a call with unknown arguments reuses their merged result instead of running again. \pgfmathparse{\x} with an unknown \x is then one step. 0 never does. |
limits.rest_splits |
8 | How often a macro that peels unknown text may split one rest it put back at a delimiter before the rest counts as holding no more. |
limits.call_learn_after |
2 | How many runs on different arguments teach what a definition's calls leave, with analysis.assume_call_learned_effect. 0 never. |
limits.call_learn_forks |
2 | How many undecided choices a run of a definition that was taught may meet before it ends with the learned effect. |
limits.meaning_set |
8 | How many possible meanings a name keeps after branches merge. Past them its meaning is unknown. |
limits.value_set |
8 | How many exact values a count or length keeps after branches merge. Past them only its range is kept, so {1, 5} becomes 1..5. Also the places an \openin stream keeps apart (texts and their lines) before it is unknown. |
A write through an index not pinned to one number (\count#1=…) must hold for every register it may name (weaken_registers, src/engine/exec.rs):
- A narrow interval (at most
limits.value_setregisters): each is joined with the value. - Otherwise every register of the kind is weakened, and unseen ones read as their kind's top (
register_top): a count the whole 32-bit word, a dimen ±\maxdimen(every dimension scan clamps there, tex.web §§ 448, 460), no longer as zero.
A \catcode, \lccode, \uccode, \sfcode, \mathcode or \delcode write through an unknown character (tex.web § 1232) leaves every entry it may name at {old, new}.
-
Categories: the table keeps the hull of the codes reached (
reach) and the categories written (reach_cats). A character of a structural category (neither letter nor other) keeps it when the hull is too wide to list: the named assumptionunknown-char-catcode(analysis.assume_unknown_char_catcode,keep_structural). A listed interval, or the assumption off, reaches them too. Reading a character whose set holds a structural category splits the path per category (split_catcode, at mostSPLIT_CATS), once per path. A letter-or-other character is a one-of token. -
Codes: the written values join in one slot per table (
family_value). An entry reads its own code joined with it. -
\lowercase/\uppercasesplit per code where the category is structural, else give a one-of of the characters.
Where satex does not yet reach the invariant:
| Limit | What can be missed |
|---|---|
| executing a character of unknown category | only an active character runs code (tex.web §§ 232, 344), and only its bindings are joined in. Groups, modes, files and \writes it would make are not. A name built from unknown text (\csname) may be any control sequence. Executing it is reported as unknown-text-run, assumed to change no state. |
| a recursion cut at its bound | assignments are widened. A category the region changed is its old or its new one. Groups the region opened stand for any number of them (many), or are closed if they differ in kind (region-groups). Lines the rest would write to open files are assumed not written (region-writes): their top, unknown text in every open file, would make each later read of it unknown |
| a file the run wrote with unknown text that is also on disk | read as on disk |
| the category of a control character, or of one from 128 to 255 under pdfTeX | a LaTeX format's table is a fixed one: \the\catcode0 reads INITEX's 9 and ^^L 12, where latex.ltx sets 15 and 13 (control characters active or invalid). Text is read as characters, not as the bytes utf8.def makes active: \the\catcode128 reads 12 where pdfLaTeX gives 13 |
| loops spanning call sites | met again only through an undecided conditional, otherwise left to the stall limit |
paths in different modes joined at \fi
|
a vertical-mode and a horizontal-mode path join their lists as one, so text set after the join may be lost on both. Red test differential::text_past_a_par_ending_a_paragraph_on_one_path_is_set_on_every_path. |
| a definition site first run before the document starts or in a cached load | counted as the first path's: a later run on that path replaces the text another path gave it there. |
a list of names widened where no pass is checked (Reach::Havoc) |
holds only the names seen, as the class hull holds only the classes seen: a pass not run that adds another name is not covered |
Every domain answers exactly or with an over-approximation that contains every real outcome. A construct satex cannot follow moves up the lattice and records why. It is never skipped or guessed. So a finding can be a false alarm at a stated limit, but nothing is silently missed.
An error is certain only if every run of the document has it. One mechanism decides that for every rule.
-
Facts carry it. The run records three kinds of fact a finding stands on: an occurrence (
certain), an engine error's row (severitywarningwhen exact) and an undefined name (no undecided conditional around it). A fact is certain when no undecided conditional or parted path encloses it and the mode is one mode (exact). -
Rows the run rests on. A gap (
unsupported: a limit, a cut, an engine error on an approximated path) and an assumption about lost state (unknown-text-run,region-catcodes,unknown-name-defines-fresh, ...) hold for everything after them in run order.Diagnostic::restis the one place that says which rows do. It marks the path as approximated too. -
Premises do not. Assumptions about the run's surroundings that
satex.yamlsets are premises: the clock, a stub, forced page breaks, that library code compiles (PREMISES). Findings are stated under them. -
One gate. A rule reports an error at a place. The linter looks up the facts at that place (
Index::unsure). If one is not certain, the error becomes a possible one and says why. A certain error fact at the place backs every finding there.
| the facts at the place | the finding | its note |
|---|---|---|
| all certain, no row before | error | |
| on an undecided path | warning | "on a path the run could not decide: TeX may raise it" |
| after an assumption | warning | "holds if the assumption at ... holds" |
| after a gap | info | "may follow from the analysis gap at ...: check that first" |
Why rows hold for the whole rest of the run: the path's approximated mark is cleared once the run is alone at top level, since unknown values mark their own reads. An assumption leaves no unknown value behind. Unknown text that ran as a no-op may have defined a name or ended the job. So the row itself is the mark, and it never clears.
The document's end follows the same rule. A missing \end{document} after such a row is the analysis' end (analysis-ended-early), not a certain missing-end.