discrete-math-ai999x — offline, verified discrete math solver with step-by-step answers

Desktop app & command line · Compute in your browser · Install (Python) · Guides · Evaluation · AI999X on Hugging Face · Website · Support: Buy Me a Coffee

License: Apache-2.0 · Author: Ibnul Jaif Farabi (creator and engineer) · Organization: AI999X · Version 1.0.3

Field: Mathematics & Statistics · Tasks: Question Answering, Token Classification, Text Classification, Sentence Similarity, Feature Extraction

discrete-math-ai999x is an offline, deterministic Python solver that answers discrete math questions with verified results from 99 certified capabilities, gives 538 documented answers identically on Windows and Linux, and refuses rather than guesses when an answer cannot be verified.

discrete-math-ai999x is a compact, deterministic discrete math engine for Python. It reads a question in plain English (or a typed call), picks a certified discrete math capability, computes the answer exactly, checks it, and returns the result with its steps, units, LaTeX and assumptions — or an honest refusal that says what is missing. It runs fully offline on any CPU, needs no GPU, no API key and no internet, and is built to give zero wrong answers: when it is not sure, it refuses instead of guessing.

Buy me a coffee License Python Offline Rust

Run it your way. discrete-math-ai999x comes as the AI999X desktop app and as the command-line program discrete-math for Windows and Linux, runs in your browser as WebAssembly, and installs as a Python package. The desktop app, the command line and the browser run the same compiled Rust program on your own device: offline, no Python needed.

Get it

Way to run it For Get it
AI999X Discrete Math desktop app 1.2.0 Windows, Linux — this model in its own app: search, ask in words, forms, live figures, explanations, offline Windows (x86-64) · Linux (x86-64)
AI999X desktop app 1.2.0 Windows, Linux — every AI999X model in one app: search, ask in words, forms, live figures, explanations, offline Windows (x86-64) · Linux (x86-64)
Command line (discrete-math) Windows, Linux — one program per model, offline, no Python Windows (x86-64) · Linux (x86-64)
In your browser any device — nothing to install Compute on the model page
Python Python 3.10+ pip install discrete-math-ai999x

Checksums: SHA256SUMS · every version: https://www.ai999x.com/downloads/desktop/latest/ · install guide: desktop & command line

Rust versions

Discrete Math also comes as native programs compiled from Rust, version 1.2.0 of the AI999X desktop app and command line: they run offline on your computer and need no Python. Each file is in this repository's rust/ folder, on the GitHub release v1.0.3 and on the website.

Program System File Size Download Use
Desktop app (Discrete Math) Windows x86-64 ai999x-discrete-math-1.2.0-windows-x86_64.zip 8.0 MB Hub · GitHub · website unzip, then double-click ai999x-discrete-math.exe (no installer)
Desktop app (Discrete Math) Linux x86-64 ai999x-discrete-math-1.2.0-linux-x86_64.tar.gz 8.9 MB Hub · GitHub · website extract, then run ./ai999x-discrete-math (X11 or Wayland desktop)
Command line (discrete-math) Windows x86-64 ai999x-discrete-math-cli-1.2.0-windows-x86_64.zip 3.5 MB Hub · GitHub · website (all models) unzip, then discrete-math.exe ask "<question>" or discrete-math.exe solve <capability> name=value
Command line (discrete-math) Linux x86-64 ai999x-discrete-math-cli-1.2.0-linux-x86_64.tar.gz 3.5 MB Hub · GitHub · website (all models) extract, then ./discrete-math ask "<question>" or ./discrete-math solve <capability> name=value

The command-line archive holds discrete-math with a README of its commands and examples, the licence and the notice. Checksums: rust/SHA256SUMS (sha256sum -c SHA256SUMS).

Quick start

Desktop app

Download AI999X Discrete Math for your system (above), unpack it and start it; type a question in words or pick a capability, fill in the form and press Compute. Figures and an explanation of the answer appear beside it. The AI999X desktop app has the same, with Discrete Math among all AI999X models.

Linux, from a terminal:

curl -LO https://www.ai999x.com/downloads/desktop/1.2.0/ai999x-discrete-math-1.2.0-linux-x86_64.tar.gz
curl -LO https://www.ai999x.com/downloads/desktop/1.2.0/SHA256SUMS
sha256sum -c --ignore-missing SHA256SUMS
tar xzf ai999x-discrete-math-1.2.0-linux-x86_64.tar.gz
./ai999x-discrete-math-1.2.0-linux-x86_64/ai999x-discrete-math

Command line

Linux:

curl -LO https://www.ai999x.com/downloads/desktop/1.2.0/ai999x-cli-1.2.0-linux-x86_64.tar.gz
curl -LO https://www.ai999x.com/downloads/desktop/1.2.0/SHA256SUMS
sha256sum -c --ignore-missing SHA256SUMS
mkdir -p ~/.local/share && tar xzf ai999x-cli-1.2.0-linux-x86_64.tar.gz -C ~/.local/share
echo 'export PATH="$HOME/.local/share/ai999x-cli-1.2.0-linux-x86_64:$PATH"' >> ~/.bashrc && source ~/.bashrc
discrete-math --version

Windows (PowerShell):

$F = "ai999x-cli-1.2.0-windows-x86_64.zip"
Invoke-WebRequest "https://www.ai999x.com/downloads/desktop/1.2.0/$F" -OutFile $F
Invoke-WebRequest "https://www.ai999x.com/downloads/desktop/1.2.0/SHA256SUMS" -OutFile SHA256SUMS
(Get-FileHash $F -Algorithm SHA256).Hash.ToLower() -eq ((Select-String -SimpleMatch $F SHA256SUMS).Line -split ' ')[0]
Expand-Archive $F -DestinationPath "$env:LOCALAPPDATA\AI999X" -Force
$D = "$env:LOCALAPPDATA\AI999X\ai999x-cli-1.2.0-windows-x86_64"; $env:Path += ";$D"
[Environment]::SetEnvironmentVariable("Path", [Environment]::GetEnvironmentVariable("Path", "User") + ";$D", "User")
discrete-math --version

Every command below was run as shown; the text under it is what the program printed.

Ask in words — Write the question as you would say it: the program reads the quantities and their units, picks the capability and answers.

$ discrete-math ask "Find the inverse of 3 modulo 11."
Read as: Modular multiplicative inverse
inverse = 4
  by: Modular multiplicative inverse  (extended Euclidean algorithm)
  assumes: m >= 2; gcd(a, m) = 1 (otherwise no inverse exists)

What a capability needs — The equation or method, every input and output with its SI unit. Read this before solve: it tells you the input names.

$ discrete-math info mod_inverse
Modular multiplicative inverse
  extended Euclidean algorithm
  in   a        the integer to invert (integer) [1]
  in   m        the modulus (at least 2) (integer) [1]
  out  inverse  a^{-1} mod m [1]

Solve — Inputs as name=value, each with any unit of the right kind. The answer lists every output, the method used, each input converted to SI, and the conditions the answer assumes.

$ discrete-math solve mod_inverse a=3 m=11
inverse = 4
  by: Modular multiplicative inverse  (extended Euclidean algorithm)
  assumes: m >= 2; gcd(a, m) = 1 (otherwise no inverse exists)

Draw the figures — The live figures for your own inputs, written as SVG files into the folder given with --out (here the current folder); open them in any browser. Without --out the SVG text comes back as JSON.

$ discrete-math figures mod_inverse a=3 m=11 --out .
[
  {
    "slug": "mod-inverse-live-1",
    "title": "A^{-1} mod m as the integer to invert varies",
    "caption": "A^{-1} mod m as a runs from 1 to 7, every other input as you entered it (7 solutions). Marked: your a = 3 gives inverse = 4. Your inputs: a = 3, m = 11.",
    "file": "./mod-inverse-live-1.svg"
  },
  {
    "slug": "mod-inverse-live-2",
    "title": "A^{-1} mod m as the modulus (at least 2) varies",
    "caption": "A^{-1} mod m as m runs from 2 to 28, every other input as you entered it (11 solutions). Values in this range where the inputs admit no answer (4 of 15) are left out. Marked: your m = 11 gives inverse = 4. Your inputs: a = 3, m = 11.",
    "file": "./mod-inverse-live-2.svg"
  }
]

Many questions at once — One JSON request per line in, one JSON answer per line out, in order: for scripts, notebooks and agents (the program starts once). In PowerShell: Get-Content cases.jsonl | discrete-math batch

cases.jsonl:

{"key": "mod_inverse", "inputs": {"a": "3", "m": "11"}}
{"key": "crt", "inputs": {"residues": "[2, 3, 2]", "moduli": "[3, 5, 7]"}}
$ discrete-math batch < cases.jsonl
{"outcome":"SOLVED","message":"","value":4.0,"unit":"","solved_for":"inverse","values":[["inverse",4,""]],"target":"inverse","phrase":"a^{-1} mod m","assumptions":["m >= 2","gcd(a, m) = 1 (otherwise no inverse exists)"],"name":"Modular multiplicative inverse","equation":"extended Euclidean algorithm"}
{"outcome":"SOLVED","message":"","value":23.0,"unit":"","solved_for":"x","values":[["x",23,""],["modulus",105,""]],"target":"x","phrase":"the smallest non-negative solution","assumptions":["one residue per modulus","the system is consistent (r_i ≡ r_j modulo gcd(m_i, m_j))"],"name":"Chinese remainder theorem","equation":"merge the congruences pairwise with the extended Euclidean algorithm (works for non-coprime moduli)"}

In your browser

Open Discrete Math on ai999x.com, choose a capability and press Compute: the model runs on your own device as WebAssembly; nothing is sent anywhere. Change any input (any unit of the right kind) and the answer, its explanation and the figures follow.

In your own page: discrete_math_ai999x.wasm and the loader ax-wasm.js (https://www.ai999x.com/compute/rust/ax-wasm.js).

Python

pip install discrete-math-ai999x

Worked examples in every form

The same worked example from the command line, from Python and in the browser. Each command-line output is what the program printed.

Bell numbers

B_n: the number of partitions of an n-element set into any number of non-empty blocks.

Command line:

$ discrete-math solve bell n=5
bell = 52
  by: Bell numbers  (Bell triangle (Aitken's array))
  assumes: 0 <= n <= 200

Python:

import discrete_math_ai999x as m

a = m.solve("bell", n="5")
print(a.values or (a.value, a.unit))

Browser: open this capability on the model page and press Compute in your browser.

What this means: This calculation determines the total number of ways to partition a set containing 5 elements into any number of non-empty subsets. The result, denoted as 52, represents the sum of all Stirling numbers of the second kind for that specific set size. It quantifies the comprehensive possibilities for splitting the group without regard to the order of blocks or their internal arrangement.

Bernoulli numbers

The Bernoulli number B_n as an exact fraction (convention B_1 = -1/2).

Command line:

$ discrete-math solve bernoulli n=10
numerator = 5
denominator = 66
value = 0.07575757576
  by: Bernoulli numbers  (exact recurrence sum_{k=0}^{m} C(m+1, k) B_k = 0 in rational arithmetic)
  assumes: 0 <= n <= 200; B_1 = -1/2 (the 'first' Bernoulli numbers)

Python:

import discrete_math_ai999x as m

a = m.solve("bernoulli", n="10")
print(a.values or (a.value, a.unit))

Browser: open this capability on the model page and press Compute in your browser.

What this means: This calculation determines the Bernoulli number corresponding to the input index 10. Using a recursive definition with rational arithmetic, the result is expressed as an exact fraction where the numerator is 5 and the denominator is 66. The decimal approximation of this value is 0.0757576. This method ensures precision by avoiding floating-point errors during the computation.

Bracelets (rotations and reflections identified)

Distinct bracelets of n beads in k colours when rotations and flips count as the same.

Command line:

$ discrete-math solve bracelets beads=6 colours=2
bracelets = 13
necklaces = 14
  by: Bracelets (rotations and reflections identified)  (Burnside's lemma over the dihedral group)
  assumes: 1 <= n, k <= 60

Python:

import discrete_math_ai999x as m

a = m.solve("bracelets", beads="6", colours="2")
print(a.values or (a.value, a.unit))

Browser: open this capability on the model page and press Compute in your browser.

What this means: This calculation determines the count of unique circular patterns using Burnside's lemma on the dihedral group, where rotations and reflections are considered identical. Given 6 beads and 2 available colours, the model computes that there are 13 distinct bracelet configurations. It also reports 14 as the count when only rotational symmetry is applied.

Catalan numbers

C_n: balanced parenthesizations with n pairs, triangulations of an (n+2)-gon, full binary trees with n+1 leaves.

Command line:

$ discrete-math solve catalan n=10
catalan = 16796
  by: Catalan numbers  (closed form binomial(2n, n)/(n + 1))
  assumes: 0 <= n <= 500; a convex polygon with s sides has C_(s-2) triangulations

Python:

import discrete_math_ai999x as m

a = m.solve("catalan", n="10")
print(a.values or (a.value, a.unit))

Browser: open this capability on the model page and press Compute in your browser.

What this means: This calculation determines the nth Catalan number using the closed form formula involving binomial coefficients. Given an input index of 10, the resulting value 16796 represents the count of specific combinatorial structures such as balanced parenthesizations, triangulations of a convex polygon, or full binary trees with a corresponding number of leaves.

Documentation

Highlights

  • Verified, not generated. Every answer is computed by a certified discrete math capability and checked (substituted back, dimension-checked or compared with an independent computation) before it is returned.
  • Zero wrong answers by design. Seven explicit outcomes — SOLVED, NEEDS_INPUT, AMBIGUOUS, INVALID_INPUT, OUT_OF_SCOPE, UNRECOGNIZED_FORMAT, INTERNAL_ERROR — never a silent guess. Every one of its 538 documented answers is reproduced exactly on every tested platform.
  • Plain-English questions and a guaranteed typed interface. ask() reads documented question forms; solve(capability_id, **inputs) always solves a supported task with valid inputs.
  • Explains itself. Steps, formulas in LaTeX, units, assumptions and the model used, ready for notebooks, tutoring apps and homework checkers.
  • Native and in the browser. Every capability also computes natively in Rust: the desktop app and the discrete-math command line for Windows and Linux, and WebAssembly on the model page — no Python, no network.
  • Small and portable. Pure Python (sympy, mpmath); identical answers on Windows and Linux (Python 3.10, 3.11, 3.12, 3.13, 3.14).
  • Coverage: number theory, modular arithmetic, combinatorics, graph structure, propositional logic and the mathematics of cryptography.

Model overview

Property Value
Package discrete-math-ai999x 1.0.3 (import discrete_math_ai999x)
Type Deterministic neuro-symbolic discrete math engine (rule-based reading + certified symbolic capabilities)
Capabilities 99 certified procedures
Knowledge pack version 1.0.0
Golden answers 538 documented answers, identical on every tested platform
Platforms tested Windows (Python 3.13), Linux x86-64 (Python 3.10, 3.11, 3.12, 3.13, 3.14)
Runtime CPU only, offline; no GPU, no network, no API key
License Apache-2.0
Creator / engineer Ibnul Jaif Farabi
Organization AI999X

Python quick start

pip install discrete-math-ai999x
# or straight from this repository:
pip install https://huggingface.co/AI999X/discrete-math-ai999x/resolve/main/dist/discrete_math_ai999x-1.0.3-py3-none-any.whl
import discrete_math_ai999x as discrete_math

discrete_math.ask("Find the inverse of 3 modulo 11.").show()
# -> SOLVED — inverse = 4  (mod_inverse)
discrete_math.ask("Solve x \u2261 2 (mod 3), x \u2261 3 (mod 5), x \u2261 2 (mod 7).").show()
# -> SOLVED — x = 23, modulus = 105  (crt)
discrete_math.ask("How many derangements of 5 objects are there?").show()
# -> SOLVED — derangements = 44, probability = 0.366667  (derangements)
discrete_math.solve("chromatic_number", edges="A-B, B-C, C-A, C-D").show()
# -> SOLVED — chromatic_number = 3, colouring = {'A': 1, 'B': 2, 'C': 3, 'D': 1}  (chromatic_number)
discrete_math.ask("Is (p -> q) | (q -> p) a tautology?").show()
# -> SOLVED — tautology = 1, false_rows = 0, counterexample = None  (logic_tautology)
discrete_math.ask("Who created you?").message
# -> discrete-math-ai999x was created and engineered by Ibnul Jaif Farabi at AI999X.

The Python package also installs a Python command, discrete-math-ai999x "<question>"; for the native program use discrete-math (above). The outputs above were produced by running this exact code on discrete-math-ai999x 1.0.3.

Find the right capability, and draw it

discrete_math.search() finds which certified capability a question is about — across every AI999X model, so a question for another model points you to it. It runs ai999x-encoder, AI999X's own capability encoder (4.7M parameters, a 4.9 MB ONNX model, offline; the root model.safetensors of this repository): pip install "discrete-math-ai999x[search]". ask(question, suggest=True) adds the same pointers to a question it does not answer; an answer itself never changes.

import discrete_math_ai999x as discrete_math

discrete_math.search("Solve x^2 - 5x + 6 = 0", k=2)
# -> Roots of a quadratic equation (math-foundations-ai999x, 0.63); Roots of a cubic equation (math-foundations-ai999x, 0.59)

How every answer is verified

  1. Reading — the question is turned into typed quantities (value, unit, kind, role) and one asked quantity; every stated number must be used or the question is refused.
  2. Planning — only certified capabilities may answer; a capability applies only under the conditions the wording states (for example a pendulum, a liquid at rest, boiling).
  3. Computing — exact symbolic or high-precision numeric evaluation.
  4. Checking — dimensions, substitution back into the defining equation, and agreement between independent readings; any disagreement becomes a refusal, never a number.

Capabilities are certified before they ship: each must reproduce hand-worked reference cases, reject a deliberately wrong variant (a control), and leave every benchmark answer unchanged.

Python worked examples, with their steps

Each question was put to discrete-math-ai999x; the answer is the one it returned, with the steps it took.

Modular multiplicative inverse · Modular arithmetic

Find the inverse of 3 modulo 11.

→ inverse = 4

Steps
  • Modular multiplicative inverse: a = 3, m = 11 → inverse = 4

Chinese remainder theorem · Modular arithmetic

Solve x ≡ 2 (mod 3), x ≡ 3 (mod 5), x ≡ 2 (mod 7).

→ x = 23, modulus = 105

Steps
  • Chinese remainder theorem: residues = [2, 3, 2], moduli = [3, 5, 7] → x = 23, modulus = 105

Derangements · Combinatorics

How many derangements of 5 objects are there?

→ derangements = 44, probability = 0.3666666667

Steps
  • Derangements: n = 5 → derangements = 44, probability = 0.3666666667

Chromatic number of a small graph · Graph theory

m.solve("chromatic_number", edges="A-B, B-C, C-A, C-D")

→ chromatic_number = 3, colouring = {'A': 1, 'B': 2, 'C': 3, 'D': 1}

Steps
  • Chromatic number of a small graph: edges = A-B, B-C, C-A, C-D → chromatic_number = 3, colouring = {'A': 1, 'B': 2, 'C': 3, 'D': 1}

Tautology test · Logic

Is (p -> q) | (q -> p) a tautology?

→ tautology = True, false_rows = 0, counterexample = None

Steps
  • Tautology test: formula = (p -> q) | (q -> p) → tautology = True, false_rows = 0, counterexample = None

Affine cipher · Cryptography

Encrypt "AFFINE CIPHER" with the affine cipher a = 5, b = 8.

→ result = IHHWVCSWFRCP

Steps
  • Affine cipher: a = 5, b = 8, message = AFFINE CIPHER, mode = encrypt → result = IHHWVCSWFRCP

Figures

Every point was computed by discrete-math-ai999x.

A graph coloured with the fewest colours

A graph coloured with the fewest colours — computed by discrete-math-ai999x

A wheel graph on 7 vertices with the chord A–C (13 edges): the package finds the chromatic number 4 and the colouring drawn here — no edge joins two vertices of the same colour (colour 1: A, D; colour 2: B, E; colour 3: C, F; colour 4: G).

Breadth-first search, layer by layer

Breadth-first search, layer by layer — computed by discrete-math-ai999x

Breadth-first search from A on a graph of 9 vertices and 12 edges, each vertex placed in the column of its distance from A as returned by the package (visit order A, B, C, D, E, F, G, H, I; 9 reached); highlighted, one edge per vertex to a neighbour one layer closer.

Stirling numbers of the second kind

Stirling numbers of the second kind — computed by discrete-math-ai999x

Stirling numbers of the second kind S(n, k) for n, k = 1 … 7 (row n, column k), each computed by the package: the ways to split n labelled objects into k non-empty groups; row 7 sums to the Bell number B(7) = 877, also computed by the package.

Integer partitions, all and into distinct parts

Integer partitions, all and into distinct parts — computed by discrete-math-ai999x

The number of ways to write n as a sum of positive integers, p(n), and as a sum of distinct ones, q(n), for n = 1 … 20, each counted by the package (logarithmic scale): p(10) = 42, q(10) = 10; marked: p(20) = 627 (q(20) = 64).

A labelled tree decoded from its Prüfer sequence

A labelled tree decoded from its Prüfer sequence — computed by discrete-math-ai999x

The labelled tree that the package decodes from the Prüfer sequence (3, 3, 3, 7, 7, 8, 8): 9 vertices, edges 1–3, 2–3, 3–4, 3–7, 5–7, 6–8, 7–8, 8–9. A vertex appears in the sequence one time fewer than its degree, so the leaves are exactly the labels the sequence never names.

Capabilities

99 certified procedures. A few of them:

  • Procedures: Affine cipher; Articulation points (cut vertices); Base (radix) conversion; Bell numbers; Bernoulli numbers; Bipartiteness test; Bracelets (rotations and reflections identified); Breadth-first search order; Bridges (cut edges); Caesar (shift) cipher; Carmichael function; Catalan numbers; Chinese remainder theorem; Chromatic number of a small graph; Clique number; Coefficient in a binomial expansion; Combinations C(n, k); Combinations with repetition (multisets); Connected components; Continued fraction of a rational number; Continued fraction of a square root; Contradiction test; Counting multiples by inclusion-exclusion; Cycle detection in a directed graph …

discrete_math_ai999x.templates() lists every question form ask() reads; the capability guide (PDF, every example executed) is included in this repository.

All 99 formulas

Show every formula, by topic

Combinatorics / basic counting

Combinations C(n, k)

(nk)=n!k! (n−k)! \binom{n}{k} = \frac{n!}{k!\,(n-k)!}

Combinations with repetition (multisets)

( ⁣(nk) ⁣)=(n+k−1k) \left(\!\binom{n}{k}\!\right) = \binom{n+k-1}{k}

Distinct arrangements of the letters of a word

n!n1! n2!⋯nr! \frac{n!}{n_1!\,n_2!\cdots n_r!}

Lattice paths in a grid

(m+nm) \binom{m+n}{m}

Multinomial coefficient

(nk1,…,km)=n!k1!⋯km! \binom{n}{k_1,\dots,k_m} = \frac{n!}{k_1!\cdots k_m!}

Permutations P(n, k)

P(n,k)=n!(n−k)! P(n,k) = \frac{n!}{(n-k)!}

Sequences with repetition (n^k)

nk n^k

Combinatorics / binomial theorem

Coefficient in a binomial expansion

(ax+b)n=∑k=0n(nk)akbn−kxk (ax+b)^n = \sum_{k=0}^{n} \binom{n}{k} a^k b^{n-k} x^k

Combinatorics / counting under symmetry

Bracelets (rotations and reflections identified)

B(n,k)=12N(n,k)+{12k(n+1)/2n odd14(k+1)kn/2n even B(n,k) = \tfrac12 N(n,k) + \begin{cases} \tfrac12 k^{(n+1)/2} & n \text{ odd} \\ \tfrac14 (k+1) k^{n/2} & n \text{ even} \end{cases}

Necklaces (rotations identified)

N(n,k)=1n∑d∣nφ(d) kn/d N(n,k) = \frac{1}{n}\sum_{d \mid n} \varphi(d)\, k^{n/d}

Combinatorics / distributions

Integer solutions of x1 + ... + xk = n (stars and bars)

#{xi≥0,∑xi=n}=(n+k−1k−1),∑j(−1)j(kj)(n−j(c+1)+k−1k−1) \#\{x_i \ge 0, \textstyle\sum x_i = n\} = \binom{n+k-1}{k-1},\quad \sum_j (-1)^j \binom{k}{j}\binom{n - j(c+1) + k-1}{k-1}

Combinatorics / inclusion-exclusion

Counting multiples by inclusion-exclusion

∣⋃iAi∣=∑∅≠S(−1)∣S∣+1⌊nlcm⁡(S)⌋ \Big\vert \bigcup_i A_i\Big\vert = \sum_{\emptyset \ne S} (-1)^{\vert S\vert +1} \left\lfloor \frac{n}{\operatorname{lcm}(S)} \right\rfloor

Derangements

!n=n!∑k=0n(−1)kk!=(n−1)(!(n−1)+!(n−2)) !n = n!\sum_{k=0}^{n}\frac{(-1)^k}{k!} = (n-1)\big(!(n-1) + !(n-2)\big)

Combinatorics / integer partitions

Integer partitions p(n)

p(n)=∑k≠0(−1)k+1 p ⁣(n−k(3k−1)2) p(n) = \sum_{k \ne 0} (-1)^{k+1}\, p\!\left(n - \tfrac{k(3k-1)}{2}\right)

Partitions into distinct parts

∑nq(n)xn=∏k≥1(1+xk)=∏k≥111−x2k−1 \sum_n q(n) x^n = \prod_{k \ge 1} (1 + x^k) = \prod_{k \ge 1} \frac{1}{1 - x^{2k-1}}

Partitions into exactly k parts

p(n,k)=p(n−1,k−1)+p(n−k,k) p(n,k) = p(n-1,k-1) + p(n-k,k)

Combinatorics / permutations and cycles

Stirling numbers of the first kind

c(n,k)=(n−1) c(n−1,k)+c(n−1,k−1),xn‾=∑kc(n,k) xk c(n,k) = (n-1)\,c(n-1,k) + c(n-1,k-1),\quad x^{\overline n} = \sum_k c(n,k)\,x^k

Combinatorics / pigeonhole principle

Pigeonhole principle: guaranteed load

max⁡ixi≥⌈nk⌉ \max_i x_i \ge \left\lceil \frac{n}{k} \right\rceil

Pigeonhole principle: objects needed for a guarantee

N=k(r−1)+1 N = k(r-1) + 1

Combinatorics / recurrences

Fibonacci numbers

Fn=Fn−1+Fn−2, F0=0, F1=1 F_n = F_{n-1} + F_{n-2},\ F_0 = 0,\ F_1 = 1

Lucas numbers

Ln=Ln−1+Ln−2, L0=2, L1=1 L_n = L_{n-1} + L_{n-2},\ L_0 = 2,\ L_1 = 1

Combinatorics / recursive counting

Catalan numbers

Cn=1n+1(2nn) C_n = \frac{1}{n+1}\binom{2n}{n}

Combinatorics / set partitions

Bell numbers

Bn+1=∑k=0n(nk)Bk B_{n+1} = \sum_{k=0}^{n} \binom{n}{k} B_k

Stirling numbers of the second kind

S(n,k)=k S(n−1,k)+S(n−1,k−1)=1k!∑j=0k(−1)j(kj)(k−j)n S(n,k) = k\,S(n-1,k) + S(n-1,k-1) = \frac{1}{k!}\sum_{j=0}^{k} (-1)^j \binom{k}{j} (k-j)^n

Combinatorics / special numbers

Bernoulli numbers

∑k=0m(m+1k)Bk=0,B0=1 \sum_{k=0}^{m} \binom{m+1}{k} B_k = 0,\quad B_0 = 1

Cryptography / RSA

RSA decryption

m=cd  n m = c^d \bmod n

RSA decryption from p, q and e (CRT)

m=mq+q (q−1(mp−mq)  p) m = m_q + q\,\big(q^{-1}(m_p - m_q) \bmod p\big)

RSA encryption

c=me  n c = m^e \bmod n

RSA key from p, q and e

n=pq, φ=(p−1)(q−1), d≡e−1(modφ) n = pq,\ \varphi = (p-1)(q-1),\ d \equiv e^{-1} \pmod{\varphi}

Cryptography / classical ciphers

Affine cipher

E(x)=(ax+b)  26, D(y)=a−1(y−b)  26 E(x) = (ax + b) \bmod 26,\ D(y) = a^{-1}(y - b) \bmod 26

Caesar (shift) cipher

E(x)=(x+k)  26 E(x) = (x + k) \bmod 26

Vigenère cipher

cj=(mj+kj  ∣k∣)  26 c_j = (m_j + k_{j \bmod \vert k\vert }) \bmod 26

Cryptography / key exchange

Diffie-Hellman key exchange

s=Ba  p=Ab  p=gab  p s = B^a \bmod p = A^b \bmod p = g^{ab} \bmod p

Cryptography / public-key encryption

ElGamal encryption

c1=gk, c2=m hk(modp),m=c2 c1−x c_1 = g^k,\ c_2 = m\,h^k \pmod p,\quad m = c_2\,c_1^{-x}

Graph theory / Euler and Hamilton

Eulerian circuits and paths

circuit  ⟺  connected∧∀v: 2∣deg⁡v \text{circuit} \iff \text{connected} \wedge \forall v:\ 2 \mid \deg v

Hamiltonian cycle of a small graph

v1v2⋯vnv1, {vi}=V v_1 v_2 \cdots v_n v_1,\ \{v_i\} = V

Graph theory / adjacency matrices

Number of walks of a given length

#walksk(u,v)=(Ak)uv \#\text{walks}_k(u,v) = (A^k)_{uv}

Graph theory / basic structure

Vertex degrees and degree sequence

∑vdeg⁡v=2∣E∣ \sum_v \deg v = 2\vert E\vert

Graph theory / cliques and independent sets

Clique number

ω(G)=max⁡{∣K∣:K complete} \omega(G) = \max\{\vert K\vert : K \text{ complete}\}

Independence number

α(G)=ω(G‾) \alpha(G) = \omega(\overline G)

Graph theory / colouring

Bipartiteness test

G bipartite  ⟺  G has no odd cycle G \text{ bipartite} \iff G \text{ has no odd cycle}

Chromatic number of a small graph

χ(G)=min⁡{k:G is k-colourable} \chi(G) = \min\{k : G \text{ is } k\text{-colourable}\}

Graph theory / connectivity

Articulation points (cut vertices)

u cut vertex  ⟺  ∃ child v: low(v)≥disc(u) u \text{ cut vertex} \iff \exists \text{ child } v:\ \mathrm{low}(v) \ge \mathrm{disc}(u)

Bridges (cut edges)

(u,v) bridge  ⟺  low(v)>disc(u) (u,v) \text{ bridge} \iff \mathrm{low}(v) > \mathrm{disc}(u)

Connected components

V=C1⊔⋯⊔Cc V = C_1 \sqcup \dots \sqcup C_c

Strongly connected components

u∼v  ⟺  u⇝v∧v⇝u u \sim v \iff u \leadsto v \wedge v \leadsto u

Graph theory / cycles

Cycles in an undirected graph (cyclomatic number)

μ(G)=∣E∣−∣V∣+c(G) \mu(G) = \vert E\vert - \vert V\vert + c(G)

Girth (shortest cycle length)

g(G)=min⁡{∣C∣:C a cycle of G} g(G) = \min\{\vert C\vert : C \text{ a cycle of } G\}

Graph theory / degree sequences

Graphical degree sequence

∑i≤kdi≤k(k−1)+∑i>kmin⁡(di,k)  ∀k,∑di even \sum_{i \le k} d_i \le k(k-1) + \sum_{i > k} \min(d_i, k)\ \ \forall k,\quad \textstyle\sum d_i \text{ even}

Graph theory / directed acyclic graphs

Cycle detection in a directed graph

G acyclic  ⟺  a topological order exists G \text{ acyclic} \iff \text{a topological order exists}

Topological sort

(u→v)∈E⇒π(u)<π(v) (u \to v) \in E \Rightarrow \pi(u) < \pi(v)

Graph theory / distances

Diameter, radius and center

diam⁡G=max⁡ve(v), rad⁡G=min⁡ve(v) \operatorname{diam} G = \max_v e(v),\ \operatorname{rad} G = \min_v e(v)

Graph theory / graph search

Breadth-first search order

d(v)=d(u)+1 when v is first seen from u d(v) = d(u) + 1 \text{ when } v \text{ is first seen from } u

Depth-first search order

visit(u): mark u; ∀v∈N(u) ascending, unmarked: visit(v) \mathrm{visit}(u):\ \text{mark } u;\ \forall v \in N(u) \text{ ascending, unmarked: } \mathrm{visit}(v)

Graph theory / subgraph counts

Number of triangles

t(G)=16tr⁡(A3) t(G) = \tfrac{1}{6}\operatorname{tr}(A^3)

Graph theory / trees

Number of spanning trees (Kirchhoff)

τ(G)=det⁡L11,L=D−A \tau(G) = \det L_{11},\quad L = D - A

Prüfer code of a labelled tree

(a1,…,an−2), ai=neighbour of the smallest leaf (a_1, \dots, a_{n-2}),\ a_i = \text{neighbour of the smallest leaf}

Tree from a Prüfer code

deg⁡(v)=1+#{i:ai=v} \deg(v) = 1 + \#\{i : a_i = v\}

Tree test

T tree  ⟺  T connected∧∣E∣=∣V∣−1 T \text{ tree} \iff T \text{ connected} \wedge \vert E\vert = \vert V\vert - 1

Logic / Boolean minimization

Minimal product of sums (CNF)

f=∏cover of fˉ∑ℓˉi f = \prod_{\text{cover of } \bar f} \sum \bar\ell_i

Minimal sum of products (DNF)

f=∑cover∏ℓi f = \sum_{\text{cover}} \prod \ell_i

Minimal sum of products from minterms (with don't-cares)

F(A,B,C)=∑m(… )+d(… ) F(A,B,C) = \sum m(\dots) + d(\dots)

Logic / propositional logic

Evaluate a propositional formula

p→q≡¬p∨q p \to q \equiv \neg p \vee q

Logical equivalence of two formulas

f≡g  ⟺  ⊨f↔g f \equiv g \iff \models f \leftrightarrow g

Truth table and minterms

f=∑m(true rows) f = \sum m(\text{true rows})

Logic / satisfiability

Contradiction test

∀v: f(v)=0 \forall v:\ f(v) = 0

Satisfiability of a propositional formula

∃v: f(v)=1 \exists v:\ f(v) = 1

Logic / validity

Tautology test

⊨f  ⟺  ∀v: f(v)=1 \models f \iff \forall v:\ f(v) = 1

Modular arithmetic / congruences

Chinese remainder theorem

x≡ri(modmi), i=1..k  ⇒  x  lcm⁡(m1,…,mk) x \equiv r_i \pmod{m_i},\ i=1..k \;\Rightarrow\; x \bmod \operatorname{lcm}(m_1,\dots,m_k)

Linear congruence ax ≡ b (mod m)

ax≡b(modm)  ⟺  x≡bg(ag)−1(modmg), g=gcd⁡(a,m)∣b ax\equiv b \pmod m \iff x \equiv \tfrac{b}{g}\left(\tfrac{a}{g}\right)^{-1} \pmod{\tfrac{m}{g}},\ g=\gcd(a,m)\mid b

Modular arithmetic / discrete logarithms

Discrete logarithm

gx≡h(modm),x=i⌈m⌉+j g^{x} \equiv h \pmod m,\quad x = i\lceil\sqrt m\rceil + j

Modular arithmetic / inverses

Modular multiplicative inverse

ax≡1(modm) a x \equiv 1 \pmod m

Modular arithmetic / orders and primitive roots

Multiplicative order

ord⁡n(a)=min⁡{k≥1:ak≡1(modn)}, ord⁡n(a)∣λ(n) \operatorname{ord}_n(a) = \min\{k \ge 1 : a^k \equiv 1 \pmod n\},\ \operatorname{ord}_n(a) \mid \lambda(n)

Smallest primitive root modulo a prime

g(p−1)/q≢1(modp)  ∀q∣p−1 g^{(p-1)/q} \not\equiv 1 \pmod p \ \ \forall q \mid p-1

Modular arithmetic / powers

Modular exponentiation

ae  m,a2k=(ak)2, a2k+1=a (ak)2 a^{e} \bmod m,\quad a^{2k} = (a^k)^2,\ a^{2k+1} = a\,(a^k)^2

Modular arithmetic / residues

Remainder modulo m (Euclidean division)

a=qm+r,0≤r<m a = q m + r,\quad 0 \le r < m

Number representations / binary arithmetic

Two's complement representation

pattern(n)=n  2b \text{pattern}(n) = n \bmod 2^b

Number representations / positional systems

Base (radix) conversion

(dk…d0)b=∑idi bi (d_k \dots d_0)_b = \sum_i d_i\, b^i

Number theory / Diophantine equations

Linear Diophantine equation ax + by = c

ax+by=c solvable  ⟺  gcd⁡(a,b)∣c;x=x0+bgt,  y=y0−agt ax+by=c \text{ solvable} \iff \gcd(a,b)\mid c;\quad x=x_0+\tfrac{b}{g}t,\; y=y_0-\tfrac{a}{g}t

Pell's equation (fundamental solution)

x2−d y2=1,xy=[a0;a1,…,ak−1] x^2 - d\,y^2 = 1,\quad \frac{x}{y} = [a_0; a_1, \dots, a_{k-1}]

Number theory / arithmetic functions

Carmichael function

λ(n)=lcm⁡(λ(p1e1),…), λ(pe)=pe−1(p−1) \lambda(n) = \operatorname{lcm}\big(\lambda(p_1^{e_1}),\dots\big),\ \lambda(p^e)=p^{e-1}(p-1)

Divisors, divisor count and divisor sum

τ(n)=∏(ei+1),σ(n)=∏piei+1−1pi−1 \tau(n)=\prod (e_i+1),\qquad \sigma(n)=\prod \frac{p_i^{e_i+1}-1}{p_i-1}

Euler's totient function

φ(n)=n∏p∣n(1−1p) \varphi(n) = n \prod_{p \mid n}\left(1 - \frac{1}{p}\right)

Möbius function

μ(n)={(−1)kn=p1⋯pk squarefree0p2∣n \mu(n) = \begin{cases} (-1)^k & n = p_1\cdots p_k \text{ squarefree} \\ 0 & p^2 \mid n \end{cases}

Number theory / continued fractions

Continued fraction of a rational number

pq=a0+1a1+1⋱+1an \frac{p}{q} = a_0 + \cfrac{1}{a_1 + \cfrac{1}{\ddots + \cfrac{1}{a_n}}}

Continued fraction of a square root

d=[a0;a1,…,ak−1,2a0‾] \sqrt d = [a_0; \overline{a_1, \dots, a_{k-1}, 2a_0}]

Number theory / divisibility

Extended Euclidean algorithm (Bezout coefficients)

ax+by=gcd⁡(a,b) a x + b y = \gcd(a, b)

Greatest common divisor and least common multiple

gcd⁡(a,b)=gcd⁡(b, a  b),lcm⁡(a,b)=abgcd⁡(a,b) \gcd(a,b)=\gcd(b,\,a \bmod b),\qquad \operatorname{lcm}(a,b)=\frac{ab}{\gcd(a,b)}

Number theory / primes

Next prime

min⁡{p>n:p prime} \min\{p > n : p \text{ prime}\}

Previous prime

max⁡{p<n:p prime} \max\{p < n : p \text{ prime}\}

Primality test

ad≡1 or a2rd≡−1(modn) for every base a a^{d}\equiv 1 \ \text{or}\ a^{2^r d}\equiv -1 \pmod n \text{ for every base } a

Prime factorization

n=p1e1p2e2⋯pkek n = p_1^{e_1} p_2^{e_2} \cdots p_k^{e_k}

Prime-counting function

π(x)=#{p≤x:p prime} \pi(x) = \#\{p \le x : p \text{ prime}\}

The n-th prime

pn<n(ln⁡n+ln⁡ln⁡n)(n≥6) p_n < n(\ln n + \ln\ln n)\quad (n \ge 6)

Number theory / quadratic residues

Jacobi symbol

(an)=∏i(api)ei,n=∏piei \left(\frac{a}{n}\right) = \prod_i \left(\frac{a}{p_i}\right)^{e_i},\quad n = \prod p_i^{e_i}

Legendre symbol

(ap)≡a(p−1)/2(modp) \left(\frac{a}{p}\right) \equiv a^{(p-1)/2} \pmod p

Square roots modulo a prime

x2≡a(modp),a(p−1)/2≡1 x^2 \equiv a \pmod p,\quad a^{(p-1)/2} \equiv 1

Number theory / squares

Integer square root and perfect squares

r=⌊n⌋  ⟺  r2≤n<(r+1)2 r = \lfloor \sqrt n \rfloor \iff r^2 \le n < (r+1)^2

Number theory / sums of squares

Sums of two squares

r2(n)=4(d1(n)−d3(n)) r_2(n) = 4\big(d_1(n) - d_3(n)\big)

Out of scope

  • Open-ended explanation, essay writing or tutoring dialogue: it is a solver, not a chatbot.
  • Questions outside its certified discrete math capabilities, and any question whose stated numbers it cannot all use — it refuses with the reason instead.
  • High-stakes engineering, medical or legal decisions without independent review.

Limitations

  • It answers what its certified capabilities cover (number theory, modular arithmetic, combinatorics, graph structure, propositional logic and the mathematics of cryptography); anything else is refused with a reason.
  • ask() reads documented question forms and common phrasings; unusual wording may be refused — use solve() for guaranteed results.
  • Results are as correct as the certified relations and their stated conditions; a certified relation is a checked model, not a claim about every physical situation.

Citation

@software{discrete_math_ai999x_1_0_3,
  title  = {discrete-math-ai999x: an offline, verified discrete math solver},
  author = {Farabi, Ibnul Jaif}, organization = {AI999X},
  year   = {2026}, version = {1.0.3},
  url    = {https://huggingface.co/AI999X/discrete-math-ai999x}
}

Contact

Questions, bug reports and requests: open a discussion on https://huggingface.co/AI999X/discrete-math-ai999x/discussions or visit https://ai999x.com.

Support the project

discrete-math-ai999x is free and open source. If it helps you, you can support further development on Buy Me a Coffee.

Created and engineered by Ibnul Jaif Farabi · AI999X · ai999x.com

Downloads last month
86
Safetensors
Model size
4.72M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Collections including AI999X/discrete-math-ai999x

Evaluation results

  • identical on every platform on Golden answers (538 documented questions, Windows + Linux Python 3.10-3.14)
    self-reported
    1.000