Skip to content
Back to skills

Use Mathema Language

ASecurity

Claim over text, JSON, records, formats, paths and trees with the languages mathema-language serves: choose the `L[...]` a parameter is drawn from by what its callers really pass, narrow it only as far as they do, know what each schema adaptor reads and refuses, and read an `unknown` or `skipped` row that names a shape or a refused feature. Use when a function takes a string, a document, a config file, a record, a command line or a tree, or when a claim over `L[...]` comes back without the ve...

  • 2 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added December 1, 2026
ai-agentspythonrustgoshellsqlnodedjangoawsgitapi

Works with

  • cli
  • api

Security analysis

A100/100

Scanned December 1, 2026

npx -y skills add tetrionlabs/mathema-agents --skill use-mathema-language --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Use Mathema Language?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Use Mathema Language
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tetrionlabs-use-mathema-language/badge)](https://www.skillsdirectory.com/skills/tetrionlabs-use-mathema-language)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: use-mathema-language
license: Apache-2.0
description: >-
  Claim over text, JSON, records, formats, paths and trees with the
  languages mathema-language serves: choose the `L[...]` a parameter is
  drawn from by what its callers really pass, narrow it only as far as
  they do, know what each schema adaptor reads and refuses, and read an
  `unknown` or `skipped` row that names a shape or a refused feature. Use
  when a function takes a string, a document, a config file, a record, a
  command line or a tree, or when a claim over `L[...]` comes back
  without the verdict you expected.
---

# Use mathema-language

A string, document or record parameter is drawn from a language, written
`L[...]` where a numeric claim writes `[0, 1]`. The language decides what a
verdict covers, so choosing it is half the claim. The rules of the other
skills hold here unchanged: you never adjudicate your own claims, and you
never close your own diagnosis.

**Written against mathema 0.6.6.2** (`>=0.6.6.2,<0.7`) **and
mathema-language 0.4.2.** The `language` extra of mathema 0.6.6.2 accepts
mathema-language 0.2 to 0.4, and the languages, adaptors and refinements
below move between those. Check the installed version before trusting this
page. Pages cited as `language/...` are in mathema-language's `docs/`, and
`docs/...` in mathema's.

The rule this skill serves is rule 8 of `design-claims` ("Write what must
be true"): where an input is text, JSON, a record, a path, a format or a
tree, draw it from its language, never from a number range or a few
strings you picked, narrow only as the callers do, and over it state what
the result admits, that members answer and non-members are refused, round
trips, and inclusion where the grammar can say it. It has been measured
once each on two real modules, with two models. On a module that reads
JSON and text it moved the share of claims drawn over a language from 2%
to 60% and cut the share that were single points from 0.91 to 0.38. On a
module whose inputs are records of its own types it did not: language
claims went from 11% to 8%, all refuted because the drawn records did
not fit the function's types, and single points did not fall. Treat it
as provisional; whether it makes claims stronger is not yet measured.

## Choose the language from what the caller passes

Start from what the function is actually given, not from what makes the
claim pass (`language/tutorial-choosing-inputs.md`).

| the parameter holds | draw it from |
|---|---|
| text from a user, file or request | `L[unicode]`, lone surrogates and controls included |
| text the caller restricts | `L[ascii]`, `L[latin-1]`, `L[printable]`, `L[alnum]`, `L[identifier]` |
| a format | `L[uuid]`, `L[iso_date]`, `L[ipv4]`, `L[base64]`, `L[hex]`, `L[slug]`, `L[shell_safe]` (`language/formats.md`) |
| a JSON document | `L[json, depth <= 6]`: what `json.loads` accepts, bare `NaN` included (`language/json.md`) |
| a config file | `L[toml]`, `L[yaml]` (YAML 1.2; `language/toml.md`, `language/yaml.md`) |
| a path | `L[path]` (`language/path.md`) |
| a record | `L[pkg.mod.Model]`: a pydantic model, dataclass, TypedDict, JSON Schema dict, SQLAlchemy or Django model (`language/records.md`) |
| a recursive record | `L[pkg.mod.Comment, depth <= 20]` (`language/trees.md`) |
| a command line | `L[pkg.cli.build_parser]`, the namespaces `parse_args` returns (`language/adaptor-argparse.md`) |
| a closed set of modes | a finite set, `{"info", "linear"}`, swept member by member |

Never a number range for text, and never a few hand-picked strings where a
language exists: a language tries its hazards first (the empty string,
`fi`, `℀`, a lone surrogate, a document nested past the recursion limit),
which a hand-picked list does not. A schema stays at the top level of its
module and is named by dotted path; a parameter annotated with the class
infers its language, as `str` infers `L[unicode]` and `Annotated[str,
MaxLen(80)]` infers `L[unicode, len <= 80]` (`language/adaptor-text.md`).

## Narrow only as the callers do

Every narrowing (a shorter length, a smaller alphabet, a value left out)
must be one the calling code really enforces
(`language/tutorial-choosing-inputs.md`). The spellings:

- **Refinements** inside the brackets, `key <= n`, `<`, `>=`, `>` or
  `key in [lo, hi]`, combined with commas: `len` (code points, as `len`
  counts) on text, and `depth`, `nodes`, `width` on record trees and
  `L[json]` (`language/refinements.md`). The probe tries the member at each
  bound and one just past it.
- **Set difference and union**: `L[unicode] \ {""}` (the same set as
  `L[unicode, len >= 1]`), `L[slug] | {"-"}` (`language/languages.md`).
- **Paths into a record**: `o.lines[*].qty in [1, 10]`,
  `c.postcode in L[alnum]`. A bound means the value is there; `| {absent}`
  keeps records where the path reaches nothing (`language/records.md`).
- **A function's own refusals**: `narrow_language(UNICODE, fn,
  errors=(E,))` from `mathema_language.narrowing`, assigned at module
  level and named by its dotted path, is the language of what `fn`
  accepts; `refused_inputs` lists what it refuses first
  (`language/how-to-narrow-a-language.md`).

A falsified claim over the honest language ends one of two ways: the code
changes, or the claim does. Narrowing to dodge a witness the caller can
really send is neither.

## What to claim over a language

| to say | write |
|---|---|
| every member gets an answer, every non-member is refused | `for s in L[json], is_language_defined(s)` |
| a boundary refuses what the schema rejects | `for form in L[app.forms.SignupForm], excluded_outside_domain(form)` |
| the output stays in a language | `for s in L[unicode], f(s) in L[slug]` |
| a token is never emitted | `for s in L[unicode], "<" not in f(s)` |
| reading and writing loses nothing | `let loads = json.loads, for s in L[json], loads(f(s)) == loads(s)` |
| decode then encode gives it back | `for s in L[base64], f(s) == s` |
| normalising twice is normalising once | `for s in L[iso_date], f(f(s)) == f(s)` |
| every spelling gives one answer | `let nfkc = mathema_language.text.nfkc, for s in L[unicode], f(nfkc(s)) == f(s)` |
| a field stays in range for every record | `for o in L[app.db.Order], f(o) >= 0` |

Sources: `language/text.md`, `language/json.md`, `language/formats.md`,
`language/records.md`, `language/vocabulary.md`, and `docs/language.md`,
"Refusal and a defined answer". `excluded_outside_domain` needs a language
with an outside: `L[unicode]` has none, a refinement or a format has one.
The refusal it looks for is the library's own: a pydantic, Django or JSON
Schema language declares that library's `ValidationError`, while a
dataclass or TypedDict has no validator, so any raise refuses. A round
trip through a bare `NaN` cannot hold, since a NaN equals nothing; the
witness says so.

Expect `holds` for text, `proven` over a finite set, for a function read
as a pattern validator, for a record claim over numeric fields (and text
read only through `len`), and for a fold over a tree under a depth bound.

### Worked examples, with what came back

Each claim below was parsed by mathema 0.6.6.2 with mathema-language 0.4.2
and adjudicated against a small implementation of the function named.

| function | claim | verdict |
|---|---|---|
| canonical JSON serialiser | `let loads = json.loads, for s in L[json, depth <= 6], loads(f(s)) == loads(s)` | falsified at `'NaN'`: a NaN equals nothing; whether to refuse it is a person's call |
| canonical JSON serialiser | `for s in L[json, depth <= 6], f(f(s)) == f(s)` | holds |
| canonical JSON serialiser | `for s in L[json, depth <= 6], f(s) in L[json]` | holds |
| canonical JSON serialiser | `for s in L[json], excluded_outside_domain(s)` | holds: `json.loads` refuses what is not JSON |
| canonical JSON serialiser | `for s in L[json, depth <= 6], is_language_defined(s)` | falsified: a deeper document is accepted, and a narrowed language expects its non-members refused; claim the depth only where the code enforces it |
| name normaliser (NFKC, casefold) | `for s in L[unicode], f(f(s)) == f(s)` | holds |
| name normaliser | `let nfkc = mathema_language.text.nfkc, for s in L[unicode], f(nfkc(s)) == f(s)` | holds |
| slug membership check | `for s in L[slug], f(s) == True`, with the anchor `f("Not a slug") == False` beside it | holds, both |
| signature check, no keys | `for signature in L[unicode], raises(f({}, signature), SignatureError)` | holds: the refusal is the function's own error, never a decoding error from inside it |
| fingerprint, `"fp-"` and 16 hex digits | `for s in L[unicode], f(s) in L[slug]` | holds when it encodes with `surrogatepass`; falsified at a lone surrogate with plain `utf-8` |
| fingerprint | `for s in L[unicode], is_language_defined(s)` | the same: holds with `surrogatepass`, falsified at `'\ud800'` with `UnicodeEncodeError` with plain `utf-8`, since a lone surrogate is a member of `L[unicode]` |

A predicate such as the slug check answers `False` rather than refusing,
so `excluded_outside_domain` does not suit it; state its members and
anchor a non-member. A quantified variable must be one of the function's
parameter names (`signature`, not `s`), which `parse_claim` with a
`target` catches.

## What each adaptor reads, and what it refuses

| adaptor | membership | not read, or refused |
|---|---|---|
| pydantic (`language/adaptor-pydantic.md`) | `model_validate` | `@field_validator` and `@model_validator` are not read: they filter draws, so a record they refuse is never drawn |
| dataclass (`language/adaptor-dataclass.md`) | the package's neutral checker | a `pattern` marker refuses the class, naming pydantic or a JSON Schema instead; `__post_init__` is not read |
| TypedDict (`language/adaptor-typeddict.md`) | the neutral checker | a key the TypedDict does not name makes a non-member |
| JSON Schema (`language/adaptor-jsonschema.md`) | the `jsonschema` validator | `$ref` is refused, inline it; `format` is not read; a union other than one with `"null"` reads as `any` |
| text (`language/adaptor-text.md`) | the alphabet | answers only `str` and `Annotated[str, ...]`; `Optional[str]` is left to mathema |
| argparse (`language/adaptor-argparse.md`) | the parser | `--help` and `--version` end the program, so they are no namespace; reading a parser warns (`ParserNoteWarning`) of defects argparse accepts silently |

A branch on a field that is not a number (a subcommand, an option with
`choices`) is decided by running the code, so expect `holds` there. A
JSON Schema whose `$ref` points back into its own document is read as a
tree (`language/trees.md`).

## Inclusion between record languages

mathema-language decides whether one record language includes another
(every record the old schema admits, the new one admits too), with z3
through the `smt` extra: proven, falsified with a record both sides'
validation confirm, or unknown naming a construct its encoding does not
read exactly (`language/openapi.md`, "What it reads"; its `CHANGELOG.md`,
0.4.1 and 0.4.2). The docs show no claim syntax for stating an inclusion
today. Do not invent one: say the question is decidable, and that the
claim grammar does not yet state it.

## Reading an unknown or skipped row

Read the note before anything else; it names the cause.

- **"needs mathema-language"**: the package is not installed, so every
  `L[...]` claim is `unknown` (`docs/language.md`).
- **A missing library**: `L[yaml]`, `L[toml]` before Python 3.11, a JSON
  Schema and an inclusion each name the extra that installs what they read
  with (`mathema-language[yaml]`, `[toml]`, `[jsonschema]`, `[smt]`).
- **A name that does not resolve** is refused with the vocabulary and the
  package that provides one; nothing is read as a wider language
  (`docs/authoring.md`).
- **A refinement key the language cannot measure** is refused, naming the
  keys it knows (`language/refinements.md`).
- **An adaptor refusal** names the feature and what to do instead: a
  dataclass `pattern`, a JSON Schema `$ref`.
- **"no accepted member"**: a narrowed language too thin for random draws
  to find; write it as a predicate language of its own
  (`language/how-to-narrow-a-language.md`).
- **An inclusion left unknown** names the shape its encoding does not read
  (a nested model's own `extra`, a field read by alias, a pydantic model in
  lax mode against another library's schema).
- **A proof resting on `assumed`**: the language's definition was compared
  with its `contains()` on the values tried, and the outline says how many
  were skipped (`(assumed, 3 of 14 values skipped)`; mathema's
  `CHANGELOG.md`, 0.6.6.2). Quote it with the verdict.
- **`skipped:misspecified`**: the claim cannot have a value (a dimension
  fixed to two sizes, `~=` around a vector premise; `docs/verdicts.md`).

Report each such row as the note says it, with what would let it decide.
An `unknown` is a gap a person can own; it is never a `holds`.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.