--- language: - en tags: - mathematics - formal-verification - symbolic-algebra - theorem-proving - multi-agent-systems - benchmark - calculus - linear-algebra - linear-programming - integer-arithmetic - mental-arithmetic - graph-theory - lattice-basis-reduction - sum-of-squares pretty_name: "LingoLOGOS math topology: seven agents, a verified answer or an explicit UNKNOWN" configs: - config_name: corpus data_files: - split: train path: problems/corpus.jsonl - config_name: shortcuts data_files: - split: train path: problems/shortcuts.jsonl size_categories: - n<1K --- # LingoLOGOS math topology A seven agent topology that solves problems written in a small mathematical language and answers either with a **verified** result or with an explicit **UNKNOWN**. It never guesses. ``` python tools/solve.py "solve x^3 - x >= 0 for x" Problem as understood : solve x^3 - x >= 0 for x Status : VERIFIED (assurance level 3 of 3) Answer : [-1, 0] U [1, +inf) Orchestrator Z3 check : 7 of 7 envelopes confirmed ``` Only the standard library and `z3-solver` are required, and `pytest` for the tests; both are named in `requirements.txt`. This dataset is that folder published as it stands, code and data together: a self contained bundle of 81 files. Every command below is written from inside the folder and works from there whether the folder stands alone or sits inside a LingoLOGOS checkout. Section 8 says how to put it back into a checkout. ## 1. The language | Family | Sentence | Answer | |---|---|---| | arithmetic | `evaluate ` (also with `mod`, `div`) | exact rational or integer | | real logic | `prove ` (variables are real, `forall x in R.`, `exists x in R.`) | `TRUE`, or `FALSE` with a counterexample | | real algebra | `solve for x` (univariate polynomial conditions) | union of intervals and points | | polynomial systems | `solve for x, y, ...` | the real solutions: how many, which are rational | | integers | `prove over Z`, `solve for n over Z` (linear, `mod`, `div`, `k \| t`) | verdict, or the solution set as members plus residue classes | | linear algebra | `det M`, `rank M`, `inverse M`, `nullspace M`, `linsolve M b`, `product A B`, `power M n` with `[[1, 2], [3, 4]]` literals | value, matrix, basis, or a solution with certificate | | optimization | `maximize subject to `, `minimize ...` (constraints joined by `and`) | optimum and point, `infeasible` or `unbounded` | | calculus | `derivative f [wrt x]`, `antiderivative f [wrt x]`, `integral f from a to b [wrt x]` | polynomial or exact value | | networks | `maxflow [[0, 3], [0, 0]] from 1 to 2` (nodes numbered from 1, a zero entry means no arc) | a flow, its value, and the cut that proves it optimal | | lattices | `reduce [[1, 1, 1], [-1, 0, 5], [3, 5, 6]]`, one basis vector per row | a reduced basis of the same lattice, with the change of basis | | quadratic forms | `sos [[2, -4, 1], [-4, 9, -2], [1, -2, 3]]` (symmetric matrix) | weighted squares that add up to it, or one point where it is negative | Terms use `+ - * / ^`, decimals, `mod`, `div`; a column vector is written `[1, 2]` and is only usable inside `dot u v` or `matvec M v`; `-x^2` is `-(x^2)` and `^` is right associative. Formulas use `= != < <= > >= |`, chains such as `0 < x < 1`, `not and or => <=>`, `true`, `false`. Irrational endpoints are written `root(P ; ~approx)`. Reserved words (not usable as variable names): `evaluate prove solve for forall exists in and or not true false derivative antiderivative integral from to wrt maximize minimize subject over mod div det rank inverse nullspace linsolve product power maxflow dot matvec reduce sos`. The kind of the sentence picks the code path: `evaluate`, real `prove`, univariate `solve` go through the original agents in `lingologos_math/agents.py`, every other kind goes through a family module (section 6). A family answer is a small dictionary with its own `kind`, so the checkers, the renderer and the corpus reader all work on the same three verdicts. **Fragment.** Everything outside it ends in UNKNOWN with a reason, never in a guess: exponents are closed integers from 0 to 1000; real `prove`/`solve` divide only by non zero constants; univariate `solve` has no quantifiers; integer atoms are linear (`mod`/`div` need a positive constant divisor); matrices are at most 5 x 5 and powers at most 4 on 4 x 4; polynomial systems have 2 to 4 unknowns, equations only; linear programs have at most 5 variables and 14 rows with non strict constraints; a network has 2 to 7 nodes, capacities that are closed and non negative, and no arc from a node to itself; a lattice sentence has 1 to 4 linearly independent integer vectors of at most 4 coordinates below 10^6, and a quadratic form sentence is a symmetric integer matrix of at most 4 rows with coefficients below 10^6; calculus covers polynomials of one variable. There are no functions such as `sin`, no implicit multiplication (`2 x`), no sets or sequences. The abstract syntax is also given in `nodes/*/grammar.gf`; that file is a specification that has **not** been compiled with the GF toolchain, and the reference parsers are Python. ## 2. The seven agents | Node | Trust | Job | Engine | |---|---|---|---| | `formalizer_a` | trusted | reads the sentence, encodes it as SMT-LIB text | hand written recursive descent parser | | `formalizer_b` | trusted | reads it again, proves the two readings equivalent | string splitting for logic, **CPython `ast`** for arithmetic, z3py emitter | | `solver_a` | untrusted | candidate answer | driven by Z3 (see the table below) | | `solver_b` | untrusted | candidate answer | exact: Fractions, Sturm sequences, Groebner bases, Fourier-Motzkin, Edmonds-Karp, LLL, diagonalization by congruence, window analysis; no Z3 | | `verifier` | trusted | confirms or rejects each candidate | Z3, default configuration | | `adversary` | trusted | tries to refute each candidate | independent exact audit plus Z3 on formalization B | | `arbiter` | trusted | applies the decision rule, restates the problem, renders the answer | pure function `decide` | The solvers are *generate and verify* components: an answer is accepted only after **every checker that is in the dossier confirms it** (section 3), so a wrong or inconclusive solver costs availability, not correctness. What each family uses: | Family | solver_a (Z3 side) | solver_b (exact) | verifier proves | adversary audits | |---|---|---|---|---| | real `solve`/`prove` | Z3 decides truth on exact cells | Sturm cells / sampling | answer equivalent to the formula | cell comparison, sampling | | polynomial systems | Z3 enumerates real solutions | Groebner basis + Hermite trace form counts real roots | enumeration with another configuration | recount, exact substitution | | integers | Z3 point by point | window decision (exact for one unknown) | answer equivalent for all integers (LIA is decidable) | window recomputation | | linear algebra | ground SMT expansions, models with blocking | Gauss-Jordan | minors, products, rank claims over the SMT entries | Laplace expansion, minors, multiplication | | optimization | Z3 optimizer | Fourier-Motzkin with dual / Farkas / ray certificates | no better feasible point, infeasibility, unboundedness | certificate check with plain arithmetic | | calculus | rule based differentiation | expand first; undetermined coefficients; Richardson extrapolation | `F(x+h) - F(x) - h*G(x) = h^2 R(x,h)` over all reals | finite difference functional | | networks | arc variables, blocking search on the value | Edmonds-Karp, then flow and cut are asked to close each other | the delivered flow is admissible and no admissible flow is larger | the cut separates the terminals and has exactly that capacity | | lattices | a bounded search for a change of basis (abstains above rank 2) | LLL, then the delivered certificate | image, unimodularity, reducedness as one ground disjunction | HNF equality, covolume, the two conditions recomputed | | quadratic forms | principal minor criterion, Z3 supplies the point when the form is negative | diagonalization by congruence, which yields the squares or the point | rank by principal minors and the witness identity, all literals | the squares add up to the matrix, or the point really is negative | **Wiring.** `topology.json` is an ordered pipeline. In this orchestrator a sender receives the latest output of its *recipient*, so each edge points at the previous agent (`formalizer_b -> formalizer_a`, ...), and the first agent reads the user problem from the `arbiter` seed. `terminationCondition` is `FIXED_PIPELINE` on purpose: the built in `UNSAT_BREAKER` would stop the session at the first UNSAT, but here UNSAT is the normal way to prove something. `maxTurns` is 7, exactly one round. The orchestrator forwards only the payload, so the growing record (the dossier) travels as JSON after a `@@DOSSIER@@` marker in `payload.naturalLanguage`. Each node ontology fixes `(set-option :timeout 8000)`: without a timeout one hard nonlinear query blocks the session forever (verified: a cubic Diophantine query never returned). **Referee.** Every envelope carries an SMT query and the status its author claims. The orchestrator runs it with Z3 as it does for any node, and `tools/solve.py` checks claimed against actual for all seven. A disagreement turns the verdict into UNKNOWN. The driver also recomputes the arbiter's decision from the transcript and keeps the weaker verdict if the two differ. When both solvers are confirmed the exact solver's answer is shown, because it is reproducible (Z3 may pick other, equally valid witnesses or bases in another process). `tests/test_orchestrator_e2e.py` runs ten problems, one per family area, through seven node processes and compares status and printed answer with the in-memory run; eleven tests, all passing inside this repository. ## 3. What "verified" means (and what it does not) | Status | Assurance | When | |---|---|---| | `VERIFIED` | 3 | formalizations proven equivalent, and an exact (non Z3) check agrees with a Z3 check | | `SINGLE_PROVER` | 2 | everything is consistent but only Z3 decides | | `UNKNOWN` | 0 | any disagreement, timeout, crash, unsupported input or missing confirmation | `VERIFIED` covers evaluation, univariate real `prove`/`solve`, calculus, linear algebra, linear programming, zero dimensional polynomial systems, univariate integer problems, and any disproof with an exactly checked counterexample. `SINGLE_PROVER` covers true real or integer statements with several unknowns or quantifiers and polynomial systems that are not zero dimensional over the complex numbers (for example `x^2 + y^2 = 0`). "Infallible" cannot be promised literally. The guarantee is *sound or abstain*, relative to a trusted base: Z3, CPython, the parsers' shared reading of the written grammar, the renderer and the decision rule. Two things no number of agents removes: a misreading that **both** formalizers make in the same way (measured below), and a bug in Z3 itself. The `Problem as understood` line exists so that the user can confirm the formalization, which is the only check of the *meaning* of the question. **The decision rule, read on its own.** `decide` (`lingologos_math/agents.py`) is a pure function of the dossier, which is what lets the driver recompute it from the transcript. A solver's answer is kept when **every checker that is in the dossier confirms it and none of them rejects it**: the verifier says `z3`, the adversary says `z3b` or `exact`. A checker that is in the dossier but could not decide - its entry for that solver is missing, malformed, or holds no usable judgement - **blocks** the answer rather than being ignored: dropping that checker's silence would keep a refutation that the checker never made and would raise the assurance on evidence that got weaker. A checker that is not in the dossier at all (the role was switched off in the topology being measured) simply does not count. A sampling match can refute an answer but never confirms one by itself, because matching on sample points is the weakest of the judgements and `UNKNOWN` is defined by a *missing confirmation*. Assurance 3 then needs the exact (non Z3) judgement, a Z3 judgement on the same answer, and the proof that the two readings are equivalent. Anything else that is not usable evidence - a confirmation that is not a boolean, an answer that cannot be read or rendered - degrades the verdict to `UNKNOWN` rather than raising, since the driver has to recompute the rule on a transcript it did not write. `tests/test_decide_rule.py` builds 77,760 dossiers from the evidence space, transcribes this paragraph independently and compares every outcome; it also checks that weakening the evidence never raises assurance, and that the driver survives dossiers it cannot read. Two looser readings of the same rule were measured rather than argued. On the 199 supported problems of the corpus all four readings (this one, one that ignores a checker that could not decide, and the same two with the cross-checking requirement dropped) give exactly the same verdicts: 178 `VERIFIED`, 21 `SINGLE_PROVER`, no `UNKNOWN`, so being strict costs no availability on this corpus. The 21 `unsupported` rows abstain under every reading, since no solver answer reaches the rule at all. On the 77,760 dossiers of the evidence space the relaxations were swept as switches, each one measured against the rule as written (which sorts them into 70 `VERIFIED`, 644 `SINGLE_PROVER`, 77,046 `UNKNOWN`). Ignoring a checker that could not decide moves 112 dossiers, and every one of them goes *up* the assurance scale: that reading is exactly the one that raises assurance when evidence gets weaker. Discounting the adversary whenever formalization B is missing moves 273 dossiers, 147 upwards and 126 downwards: it discards refutations, and it costs availability as well. Dropping the requirement that the two readings be equivalent moves 70 dossiers, all upwards. None of the three is used, and the second one is not a hypothetical: the rule that shipped with the families stopped reading the adversary when formalization B was absent, and that variant measured 52 silent errors in one experiment on the corpus of that time. It is a historical number: the results file shipped here measures the rule as written. **Reading the printed answer.** The renderer is part of the trusted base, so its precision policy is written down. A bare rational (`2`, `1/3`, `10000000000001/10000000000000`) is the exact value. A root that is a finite decimal is printed exactly, without a tilde: approximating an exact value loses information. Any other root is printed as `root(P ; ~d)` with `P` the square free product of atoms and `~d` rounded to 12 significant digits; if two roots of one answer would print identically both are reprinted with two more digits, up to 30, so two different roots never share a printed form. `tests/test_answer_rendering.py` reads the printed text back with an independent reader, re-evaluates the printed formula by hand at points outside the interval, and checks each printed decimal against the equation it is claimed to solve, which turns a rendering defect into a failing test instead of a wrong answer on the terminal. ## 4. How many agents are needed **Argument.** Faults come from five places: reading the problem, solving it, checking the answer, completeness, and reporting. Solving needs no replication for soundness because it is verified. Reading and checking are *trusted*, so each needs two independent implementations to detect one fault (f faults need f+1 versions to detect, 2f+1 to also mask). With f = 1 that is 2 formalizers + 2 checkers + 1 solver = **5 agents** for soundness; a second solver and the arbiter bring it to **7**, which buy availability and a second implementation of the decision rule. A hardware mapped mesh cannot exceed 15 nodes anyway (the topology control register keeps `TOTAL_NODES` in 4 bits). **Experiment** (`tools/ablation.py`, results in `results/ablation.json`). The 199 supported corpus problems (the 21 `unsupported` rows are left out) were run in memory with the same agent code, injecting faults from a catalogue: parser misreadings, wrong or incomplete solver answers in every family, rubber stamping checkers, a lying arbiter. *Silent error* means a `VERIFIED` or `SINGLE_PROVER` verdict that differs from the gold answer. A run is *activated* when the injected fault really changed something. | Agents | Configuration | Single fault runs activated | Silent errors | Abstained | Correct anyway | |---|---|---|---|---|---| | 3 | formalizer_a, solver_a, verifier | 724 | **56** | 434 | 234 | | 4 | + formalizer_b | 817 | 0 | 582 | 235 | | 5 | + adversary | 1013 | 0 | 590 | 423 | | 6 | + solver_b | 1437 | 0 | 193 | 1244 | | 7 | + arbiter (full) | 1633 | 0 | 193 | 1440 | Trusting `solver_a` with no checks at all would have been wrong in 422 of the 1633 activated runs. With no faults every configuration answers all 199 problems correctly; from 5 agents on, 178 are `VERIFIED` and 21 `SINGLE_PROVER` (with 3 or 4 agents all 199 are `SINGLE_PROVER`, there is no independent exact engine yet). Removing the verifier keeps the 178 `VERIFIED` because the adversary still supplies the exact judgement; removing the adversary drops all 199 to `SINGLE_PROVER`. Removing either formalizer makes every activated run abstain, and removing `solver_a` leaves 178 correct answers and 21 abstentions. *Tolerance model: any solver faults plus at most one fault in a trusted role.* | Configuration | Experiments | Activated runs | Silent errors | |---|---|---|---| | 7 agents | 44 | 5166 | **0** | | 5 agents | 40 | 4358 | **0** | | 7 minus adversary | 4 | 796 | 110 | | 7 minus verifier | 4 | 796 | 110 | | 7 minus formalizer_b | 4 | 93 | **0** | Each duplicated trusted role is therefore necessary: with one checker gone, the catalogue's pair of identical solver faults plus a rubber stamp on the remaining checker produced 110 silent errors in one experiment alone, 107 of them under `flip_verdict`. Removing a solver or the arbiter never produced a silent error. Beyond the model: a misreading shared by both formalizers produced 56 silent errors in 93 activated runs (the known limit); identical faults in both solvers produced 0 in 444 activated runs (the checkers catch them); a faulty solver with **both** checkers compromised produced 26 in 995, all on problems where the second solver cannot answer. With `formalizer_b` missing the adversary loses the reading it cross checks, and the rule of section 3 refuses to trust the remaining evidence: all 93 activated runs abstain, and the row has 0 silent errors. These are measurements over this corpus and this catalogue, not a proof. **Findings during development.** The contribution that added the certificate families first showed 10 silent errors at 4 agents and 10 more with the adversary removed, all of them on `maxflow` rows carrying an empty cut: the exact checker refused such an answer, but the Z3 checker had never looked at the cut and confirmed it. Both checkers now verify the same statement, the weak duality claim of section 7, and a delivered side that is not a valid separator is refused before any SMT text is built; the catalogue also gained the `closed_open` perturbation that widens the delivered side, which is what makes the difference visible in the experiment. That same contribution had shown 2 silent errors at 5 agents from two defects of its own, a rank claim producing an invalid SMT term and a decision rule that accepted an answer when one checker was inconclusive and the other was wrong; both are fixed and pinned by `tests/test_decide_rule.py`. ## 5. Running ``` python tools/solve.py "prove x^2 + y^2 >= 2*x*y" # real orchestrator, 7 node processes python tools/solve.py --json "det [[1,2],[3,4]]" # full transcript python tools/solve.py --corpus problems/corpus.jsonl --limit 10 python tools/shortcuts.py "evaluate 97*96" # one mental route, plus the plausibility gate python tools/shortcuts.py --catalogue # the 14 techniques and their SMT obligations python -m pytest tests -q # 2687 tests, about 90 s python tools/ablation.py --quick # redundancy experiment (minutes) ``` Measured on this bundle: 2687 tests pass in 70.4 s inside a LingoLOGOS checkout, 76.7 s when the suite is started from the checkout root as `python -m pytest datasets/math/tests -q`, and 57.5 s on a copy of this folder that stands alone, where the eleven end to end tests skip and the count is 2676 passed and 1 skipped (section 8). The driver and the tests locate the orchestrator package by walking up the folder tree, so the bundle works from both places; in a standalone clone the package has to be installed, and then the eleven end to end tests skip. Three family sentences (`maximize 3*x + 2*y subject to x + y <= 4 and x - y >= 0 and x >= 0 and y >= 0`, `det [[2,1],[1,3]]`, `solve n mod 3 = 1 and n > 2 for n over Z`) were re-run by hand through the seven node processes on the merged bundle and came back `VERIFIED` with all seven envelopes confirmed by the referee; the end to end tests cover calculus, `linsolve`, a two unknown system and the real solver over the same transport. `tools/solve.py` finds `src/` in an ancestor when the folder sits in the repository; otherwise install the orchestrator package. It generates a launcher with `sys.executable` (a `.sh` file, or a `.cmd` file on Windows; the `.cmd` launcher is what the eleven end to end tests used just here). `topology.json` can also be run directly with `lingologos-orchestrator -c datasets/math/topology.json -d datasets/math/nodes` from the repository root, using the POSIX executable `datasets/math/agents/math_agent`. `tools/ablation.py` regenerates `results/ablation.json`. `--quick` restricts the run to the five main configurations; `--configs`, `--multi` and `--tolerance` pick one part of the experiment, and `--merge part1.json part2.json ...` stitches the parts back into one file (the tables above come from two such parts, about one hour of compute on 24 cores; `--out` names the output). ## 6. Layout ``` topology.json ordered seven node pipeline nodes// grammar.gf, ontology.smt2, seed_payload.json for each agent (data) problems/corpus.jsonl 220 problems with gold answers (hand written, numpy, or brute force; never the code under test) problems/shortcuts.jsonl 92 evaluate problems, each naming the mental route the router should take lingologos_math/ library: parsers, exact arithmetic, SMT helpers, agents, decision rule, fault injection, mental routes (lingologos_math/shortcuts.py) agents/math_agent node executable, role chosen by --role tools/solve.py driver around the real orchestrator; tools/ablation.py redundancy experiments tools/shortcuts.py the teaching layer of section 10, one sentence at a time, plus its corpus generator tools/publish_dataset.py this folder as a dataset on the hub, and the check that every file arrived tests/ 2687 tests: parser agreement, algorithms against brute force, corpus, faults, end to end, printed answers read back, decision rule over 77760 dossiers, zero exponent, mental routes re-evaluated step by step, their routing and their isolation from the verdict, flow and cut certificates, LLL and the lattice change of basis, congruence and the squares results/ablation.json measured redundancy results quoted above ``` `lingologos_math/` holds 29 modules. The families live in `lingologos_math/fam_*.py` and implement one small interface declared in `lingologos_math/families.py`: `check_fragment`, two formalization views, two solvers, two confirmations, `render`, `same`, `gold_equal` and `perturb`. The registry loads a module only when a sentence of its kind appears, `family_of(kind)` answers the question the agents ask at dispatch time, and `all_kinds()` lists the 17 kinds that are not on the legacy path (`derivative`, `antiderivative`, `integral`, `optimize`, `det`, `rank`, `inverse`, `nullspace`, `linsolve`, `product`, `power`, `provez`, `solvez`, `solvesys`, `maxflow`, `reduce`, `sos`). `lingologos_math/famsteps.py` holds the agent steps shared by all of them, so **adding a family does not touch the agents**. The algebraic tools are `lingologos_math/mpoly.py` (sparse polynomials, Groebner), `lingologos_math/linalg.py`, `lingologos_math/lp.py`, `lingologos_math/flow.py` (networks, cuts, linear program bridge), `lingologos_math/lattice.py` (LLL, Gram-Schmidt over `Fractions`, Hermite form) and `lingologos_math/quadratic.py` (congruence, principal minors). ## 7. Verification of the pieces During development of the families, and reported here as measured by that contribution: both parsers agreed on 15000 random sentences of the extended language and the printer round tripped through both; the Hermite real root count equalled a Z3 enumeration on 118 random polynomial systems; the Fourier-Motzkin certificates were valid on 1500 random linear programs and matched vertex enumeration. The shipped tests repeat these checks on smaller samples, and add: determinants agree across Gauss, Laplace and Leibniz; the integer window method agrees with brute force on random formulas and is proven equivalent by Z3; every perturbed answer of the corpus is rejected by at least one checker. The three newer engines are checked in the same spirit. `tests/test_flow.py` compares Edmonds-Karp with an enumeration of every cut on the networks of the corpus, asks the linear program route to agree with its dual read back as a cut, and refuses a certificate that breaks capacity, conservation or the partition; it also walks every side of a network through both checkers and asserts each one is judged by the capacity it has, which is the gap described in section 4. `tests/test_lattice.py` runs LLL on random bases, re-derives the three claims of the certificate from the delivered basis, and asserts that the Hermite normal form is the same for two bases of one lattice and different for lattices that are not the same. `tests/test_quadratic.py` walks 60 random symmetric forms through the congruence diagonalization and checks that the product really is diagonal, that the delivered squares rebuild the matrix entry by entry, and that the rank read off the elimination agrees with the rank read off the principal minors. Each of the three also states, sentence by sentence, that every perturbation the family admits is refused by both checkers, in both Z3 configurations. The three files that came from the audit of the previous bundle are permanent: `tests/test_decide_rule.py` (77,760 dossiers against an independent transcription of section 3), `tests/test_answer_rendering.py` (printed text read back by a separate reader, over 34,713 sampled points) and `tests/test_zero_exponent.py`. Three tests of the incoming bundle were red before the merge and are green here: one on the exact cell decomposition in `lingologos_math/exact.py`, one on a calculus answer, one on a Groebner basis over `x^1*y^0`. The merge kept the `exact.py` this repository already had and the convention that `x^0` is the constant 1 in both SMT emitters, and that is what makes them pass (section 9). ## 8. Putting this dataset inside a LingoLOGOS checkout This dataset is the `math/` folder of the LingoLOGOS project, published as it stands: 81 files plus this card in place of their README, 312 problems in two corpus files (220 for the topology, 92 for the routes), the seven node definitions, the seventeen sentence families with the vector terms of section 1, the mental routes of section 10 and the decision rule of section 3. This card is the folder's own README with the same section numbers, so the reference in `tests/test_decide_rule.py` to section 3 of the README resolves either way; sections 11 to 13 below are added for readers who met the bundle here rather than in a repository. Every file but this card was compared by sha256 after the upload: the dataset holds one object per file of that folder plus `.gitattributes`, so the count is one above the number of files the publisher counts in the checkout, because this card replaces the README there rather than being added to it. Publishing a change of this folder back to the hub is an explicit step, never a side effect of a test run; `tools/publish_dataset.py` does it with the token taken from the environment. Standalone, without the orchestrator package, the eleven end to end tests skip. The rest of the suite does not depend on the repository: measured on a copy of this folder placed outside the repository, the suite gives **2676 passed and 1 skipped in 57.5 s** here as well, against the **2687 passed in 70.4 s** measured inside a LingoLOGOS checkout. The data are `nodes/`, `problems/` and `topology.json`; the code are `lingologos_math/`, `agents/` and `tools/`. The federated (git) transport of the orchestrator builds every node with the fixed executable `lllayer` (`schema.py`, `to_legacy_topology`), so a git delivered dataset cannot ship its own agent programs through that path. Either keep this folder together as a classic topology bundle, as it is now, or extend the orchestrator so that federated nodes can declare an executable. An earlier published revision of this dataset carried its library as `lgmath/` and the handle its fault catalogue reads as `LGMATH_FAULTS`; the library folder is now `lingologos_math/` and the handle is `LINGOLOGOS_MATH_FAULTS`. Names moved and nothing else: the 81 files, the 312 problems, the 2687 tests and the decision rule of section 3 are the ones that revision described, and `tests/test_topology.py` walks the library under its new name. ## 9. Known limits * Not covered: functions beyond polynomials (`sin`, `exp`, `log`, roots, absolute value), limits and series, number theory beyond linear integer arithmetic (primes, Diophantine equations, nonlinear integer problems), probability, geometry, complex numbers, matrices beyond 5 x 5, word problems and general theorem proving. * The three certificate families sit inside a deliberately small fragment. A network has 2 to 7 nodes (the exact checker enumerates cuts up to 8), a lattice sentence has 1 to 4 linearly independent integer vectors of at most 4 coordinates below `10^6`, and a quadratic form is a symmetric integer matrix of at most 4 rows with coefficients below `10^6`. Inside those bounds the checkers decide; outside them the fragment is rejected at the door rather than answered badly. * The Z3 route for a lattice only searches a change of basis up to rank 2 and abstains above it, and the Z3 route for a negative quadratic form abstains when its model is not a rational vector, is too large to read, or does not actually make the form negative. An abstention costs availability, never soundness: those sentences come back `SINGLE_PROVER` or `UNKNOWN`, not `VERIFIED`. "Sum of squares" here means over the rationals, and the object is the matrix of the form: no symbolic exponents, no summation signs. * Polynomial systems with infinitely many real solutions end in UNKNOWN; so do systems with more than 16 real solutions. Quantified `prove` over several unknowns stays `SINGLE_PROVER` at best. * The two formalizers share a specification written by the same author; a shared misreading is invisible (measured: 56 silent errors in 93 activated runs when both make the same one). * `lingologos_math/answers.py` rendering and `lingologos_math/agents.py:decide` are part of the trusted base: a bug in them is invisible to the topology, because the driver recomputes the same function. They used to be unchecked. A throwaway audit (a script outside this tree) over 622,080 dossiers found the rule of that time faithful to its specification (0 disagreements, and no case where weakening the evidence raised assurance) but fragile: a dossier missing a part raised and killed the driver, and a confirmation that was merely truthy (`"exact": "yes please"`) was accepted as the exact one and bought assurance 3. The renderer printed correct sets with lost precision: over 152 random problems and 34,713 sampled points there was no semantic error, but 4 answers described the wrong set at the printed precision, 10 endpoints were ambiguous and 4 printed decimals did not solve the equation they came from. Both are fixed, and the throwaway audit is now replaced by permanent tests that a reader can rerun (section 7). What no test removes: a decision rule that is *consistently* wrong, in the rule and in the driver. * A second fragility was found while merging the families: an auditor that is present but silent could be ignored, which would have hidden refutations (section 3 measures the three candidate readings). The rule now blocks on it, and `tests/test_decide_rule.py` pins that behaviour. * `x^0` is read as the constant 1, so `0^0` is 1 and `solve x^0 = 1 for x` is `(-inf, +inf)`. That matches how `lingologos_math/exact.py` evaluates and expands powers; Z3 5.3.3 leaves `(^ x 0.0)` unconstrained at `x = 0`, and that gap was one of the three red tests of the incoming bundle (section 7) until both SMT emitters started printing the constant 1. If your convention is that `0^0` is undefined, the answer above is wrong, and nothing in the topology will say so. * A root that is a root of a product of atoms is printed as `root(P ; ~d)` with `P` the square free product; the precision policy of `~d` and the rule that two different roots never share a printed form are in section 3. ## 10. Mental shortcuts: a teaching layer, never evidence `lingologos_math/shortcuts.py` answers a different question from the rest of this folder: not whether an answer is right, but how a person would have carried the same calculation in their head. It runs on `evaluate` sentences whose numbers have at most five digits, it attaches itself inside the record of `solver_b` as `sb.shortcut`, and `decide` (section 3) does not read it: that rule looks at the two checkers of the record and at nothing else. Removing the key, or replacing it with a lie, leaves every verdict of the corpus unchanged, and `tests/test_shortcut_corpus.py` checks that on all 92 rows of the shortcut corpus. **The catalogue.** Fourteen techniques derive an answer; two further entries (`nines_complement`, `digit_divisibility`) carry an obligation but no route of their own. Costs are the steps a route writes down and the carries it keeps in the head, measured on the six corpus rows of that technique. | technique | when it applies | steps, carries | | --- | --- | --- | | `common_factor` | a sum or difference of two products sharing a factor | 2, 0 | | `multiply_by_eleven` | one factor is 11 | 2, 0 | | `nines_factor` | one factor is 9, 99 or 999 | 2, 0 | | `finger_product` | both factors from 6 to 10 | 3, 1 | | `tens_companion` | same tens digit, units digits adding to 10 | 3, 0 | | `deficit_base` | both factors near 100, read by their deficits | 6, 3 | | `square_nearest` | a square, from the neighbouring ten | 3, 0 | | `count_up` | a subtraction, counted up over the round boundaries | 4, 0 | | `compensation` | a sum or difference shifted to a round number | 3, 0 | | `lines_product` | one digit times two digits, one row of partial products | 3, 0 | | `columns_product` | two factors of two digits, the grid | 7, 0 | | `shrink_ratio` | a ratio whose terms share a divisor | 3, 0 | | `decimal_scale` | a ratio whose bottom is made of 2s and 5s | 3, 0 | | `partial_quotients` | `div` and `mod`, taken away in blocks of 100, 10, 5 and 1 | 4 or 5, 0 | **A trace is re-evaluated, not trusted.** A route is a list of steps written as s-expressions over exact rationals in a small language of its own (`(mul 100 (sub 97 4))`), with a parser and an evaluator that do not touch `lingologos_math/exact.py`. `check_trace` recomputes every step and reports a defect when the value the step states is not the value it computes, when a numeral has not been earned (it is not an operand, a digit of an operand, a value of an earlier step or one of its digits, a place value, or one of at most two declared helper numerals), or when a numeral sits far outside the magnitude of the problem. Five techniques announce an interval their result has to land in (`finger_product`, `tens_companion`, `square_nearest`, `deficit_base`, `partial_quotients`); the other nine promise nothing. **The cheapest route wins.** The router builds every route that applies to a sentence and takes the minimum of (steps, carries); the order of the catalogue only breaks a tie, and across the 92 rows no tie occurs. A route that would be a single line restating the problem is not offered. On 8 rows of the corpus nothing applies and the layer says nothing at all: `selected` is false and there is no route to read. **A gate that can only take things away.** Each technique also bounds its result: widening the digits of the operands into place value intervals gives a range the answer has to fall in. Measured on the 92 rows, 91 carry a bound, and on those a value ten times too large and a value with the sign flipped are always refuted, a value ten times too small on 86. A power like `2^10` gets no bound. The gate never turns a verdict and never raises assurance; it behaves like a checker that is present but not decisive, so it can only object. It does not catch an off by one, and it does not claim to. **The obligations.** Each technique carries one SMT obligation: the identity it leans on, with its side conditions asserted, its negation expected `unsat`. All 16 come out `unsat` with the default solver configuration. Five careless readings taken from the original specification cards are satisfiable and Z3 returns a witness for each: the slot reading of the eleven rule without the carry (witness a = 1, b = 9; 38 x 11 is 418 and the careless reading writes 318), the `tens_companion` rule with the units left free (witness t = 6, u = 9, v = 3; 23 x 26 is 598 and the reading writes 618), `deficit_base` read without the carry (witness u = v = 49; 88 x 78 is 6864 and the reading writes 6664), the nines complement that takes the last digit from 9 as well (100-27 is 73, the reading writes 72), and the same rule aimed at 300 instead of at a power of ten (273 against the 173 the rule writes). Each of the fourteen routes records what it rests on under one of six labels (`digit reading`, `identity`, `identity only`, `interpretation only`, `side condition`, `telescoping`); the two entries without a route record theirs as `domain and last digit` and `prerequisite only`. Those two exist only for their obligation, because a divisibility fact or a complement rule decides whether a shortcut may be used and never computes an answer. **Data and tests.** `problems/shortcuts.jsonl` holds 92 `evaluate` rows: 84 named routes, six per technique, and 8 rows where the layer abstains. A row states the route the router is expected to choose and its measured cost, so a broken technique surfaces as a wrong label instead of as a silent absence. Three test files carry 1,745 of the 2,476 tests of this folder: `tests/test_shortcuts.py` (every step recomputed by an independent parser and evaluator, the gate, the 16 obligations, the 5 refutations with their models), `tests/test_shortcut_routing.py` (cost counted from the steps actually written, determinism, the minimum, abstention) and `tests/test_shortcut_corpus.py` (the 92 rows through the seven agents, and the isolation check described above). `python tools/shortcuts.py "evaluate 97*96"` shows the route and the gate for one sentence, `--catalogue` prints the catalogue with its obligations, `--generate` rewrites the corpus file and refuses to write a row whose label disagrees with the router. **What this layer does not do.** It adds no syntax: percentages, decimal literals and summation signs are still outside the language, so the techniques that would need them are not implemented. It adds no evidence: nothing in it can raise assurance, and when a fault is injected into `solver_b` the layer reports `agrees: false` beside an answer that the arbiter rejects on other grounds. ## 11. The two corpus files `problems/corpus.jsonl` holds 220 problems, one JSON object per line, written by hand (the irrational endpoints in some gold answers come from a numeric root finder, while the bundle itself computes exactly). It is a benchmark for the topology: there is no prompt, no response pair and nothing to fine tune on. | Field | Type | Meaning | |---|---|---| | `id` | string | unique; the prefix names the area (table below) | | `kind` | string | one of 21 kinds: `evaluate`, `prove`, `solve`, `unsupported`, and the 17 families of section 1 | | `text` | string | the problem in the language of section 1, between 9 and 181 characters | | `expect` | string | the status the topology is expected to return: `VERIFIED` (178), `SINGLE_PROVER` (21), `UNKNOWN` (21) | | `gold` | object | the expected answer, one shape per kind (below); `{}` for the 21 `unsupported` rows | | Id prefix | Kind | Rows | Id prefix | Kind | Rows | |---|---|---|---|---|---| | `ev`, `ie` | `evaluate` | 9, 5 | `ld` | `det` | 7 | | `pr`, `pm`, `pq` | `prove` | 14, 6, 7 | `lr` | `rank` | 5 | | `so` | `solve` | 22 | `li` | `inverse` | 4 | | `ps` | `solvesys` | 12 | `ln` | `nullspace` | 4 | | `iz` | `solvez` | 13 | `ls` | `linsolve` | 6 | | `iq` | `provez` | 13 | `lp`, `lp_` | `optimize`, `product` | 13, 3 | | `cd` | `derivative` | 6 | `lw` | `power` | 4 | | `ci` | `integral` | 6 | `ca` | `antiderivative` | 4 | | `mf` | `maxflow` | 10 | `rd` | `reduce` | 8 | | `sq` | `sos` | 12 | `dm` | `evaluate`, `optimize`, `prove` | 1, 2, 3 | | `un` | `unsupported` | 21 | | | | The `dm` rows are the sentences that carry a dot product or a matrix times a vector inside a kind that does not otherwise use one. The `gold` shapes, one per kind. Numbers that must stay exact are strings holding a rational, never floats. | Kind | `gold` | |---|---| | `evaluate`, `det`, `rank`, `integral` | `{"value": "5/6"}` | | `prove`, `provez` | `{"verdict": "proved"}` or `{"verdict": "disproved"}`. A disproved statement also gets a counterexample at run time; the corpus records only the verdict | | `solve` | `{"runs": [[lo, lo_closed, hi, hi_closed], ...]}`: the solution set as disjoint intervals and points in increasing order, `null` on an unbounded side, a closed end is `true`. Endpoints are exact integers where the answer is exact and decimal floats where the true endpoint is irrational, accurate to about 15 digits | | `derivative`, `antiderivative` | `{"coeffs": ["3", "0", "2"]}`, coefficients in increasing degree order, so `2*x^2 + 3` is `["3", "0", "2"]` | | `optimize` | `{"status": "optimal", "value": "12"}`, or `{"status": "unbounded"}` / `{"status": "infeasible"}` with no value | | `inverse`, `product`, `power` | `{"rows": [["1/2", "0"], ["0", "2"]]}`, a matrix of exact rationals | | `nullspace` | `{"dim": 1, "vectors": [["-2", "1"]]}`: the dimension and a basis | | `linsolve` | `{"kind": "unique", "x": [...]}`, `{"kind": "none", "y": [...]}` where `y` is a certificate that the system is inconsistent, or `{"kind": "affine", "x0": [...], "basis": [...]}` for a solution set that is an affine image | | `solvesys` | `{"count": 2, "irrational": 2, "rational": [["1", "2"], ["2", "1"]]}`: the number of real solutions, how many of them are not rational points, and the rational ones listed. The twelve rows here have at most four solutions | | `solvez` | `{"limit": 50, "in": [...], "neg": {"L": 1, "r": []}, "pos": {"L": 1, "r": []}}`: the solutions inside `-limit` to `limit`, and the description of the whole solution set on the negative and on the non negative integers as residue classes modulo `L` (residues `r`); `{"L": 1, "r": []}` means that side is empty | | `maxflow` | `{"status": "flow", "value": "6"}`: the value of a maximum flow between the two terminals. The flow and the closing cut are delivered at run time and re-checked, they are not in the gold | | `reduce` | `{"status": "reduced", "rank": 2, "covolume": "81", "hnf": [["1", "0", "4"], ["0", "1", "6"], ["0", "0", "9"]]}`: the rank, the covolume, and the canonical Hermite form of the reduced basis. The delivered basis is one of many, so the gold pins the lattice down through its canonical form | | `sos` | `{"status": "sos", "rank": 2}` or `{"status": "not", "rank": 2}`: whether the form is a sum of squares and the rank of its matrix. The witness, the squares or a point where the form is negative, is delivered and re-checked at run time | `problems/shortcuts.jsonl` holds 92 `evaluate` problems of one or two digits, and asks a different question: not which verdict the topology reaches but which mental route the teaching layer of section 10 takes. All 92 rows are expected to end `VERIFIED`. | Field | Type | Meaning | |---|---|---| | `id` | string | `sc__`; the technique is part of the id | | `kind` | string | `evaluate` on every row | | `text` | string | the problem, between 12 and 23 characters | | `technique` | string | the route the router is expected to choose, or `none` on the 8 rows where nothing applies | | `cost` | list | `[steps, carries]` measured for that route; absent when `technique` is `none` | | `expect` | string | `VERIFIED` on every row | | `gold` | object | `{"value": "9312"}`, an exact rational in a string | The 84 routed rows are six per technique over the fourteen techniques that derive an answer; the 8 remaining rows are the sentences on which the layer abstains (`2^10`, `2000-1500`, `1/2 + 1/3`, `3^5`, `12+13+14`, `100/7`, `7*8*9`, `9^2`). Nothing in these rows is evidence: the decision rule never reads a route, and `tests/test_shortcut_corpus.py` re-checks that the verdict is unchanged when the route is removed from the record of `solver_b`. Load either file with the `datasets` library, or with one `json.loads` per line, which needs no dependency: ```python from datasets import load_dataset corpus = load_dataset("tailot/lingologos-math", "corpus", split="train") routes = load_dataset("tailot/lingologos-math", "shortcuts", split="train") print(corpus[0], routes[0]) ``` Both files are what `tools/solve.py --corpus` walks over, and `lingologos_math/corpus.py` plus `tests/test_corpus.py` read them to compare the topology against the gold and the routing against its label. ## 12. Rights No license is declared for this dataset, its corpora, or its code: reuse is not granted by this page. The corpus gold answers, the mental route catalogue, the grammar specification, the node data and the Python sources were written by hand as part of the LingoLOGOS project. Ask before redistributing or building on them, and expect the answer to be yes for academic work with attribution. Z3 is a separate product with its own license and is not redistributed here; `z3-solver` is only named as a dependency in `requirements.txt`. ## 13. Citation ``` @misc{lingologos_math, title = {LingoLOGOS math topology: seven agents, a verified answer or an explicit UNKNOWN}, author = {LingoLOGOS project}, year = {2026}, url = {https://huggingface.co/datasets/tailot/lingologos-math}, note = {bundle of the math folder of the LingoLOGOS repository: 312 problems in two corpora, seven node definitions, seventeen sentence families with the vector terms, decision rule, mental shortcut catalogue with SMT obligations, exact arithmetic library, fault catalogue, 2687 tests} } ```