# Doc2math

> Convert any narrative document to a formal Mathematical Problem Specification (MPS) — activate when user provides a research paper, problem description, spec, or technical document and wants it formalized into variables, operators, constraints, objectives, and uncertainty. Uses Zero-Inference Protocol.

- Skill: `thebrierfox/doc2math` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add thebrierfox/doc2math`
- Raw SKILL.md: https://api.skillmd.com/api/skills/thebrierfox/doc2math/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: thebrierfox (https://skillmd.com/u/thebrierfox)
- Updated: 2026-09-10
- Page: https://skillmd.com/skills/thebrierfox/doc2math

---


# DOC2MATH™ — Document-to-Mathematics Problem Genesis Engine

*Originator: W. Kyle Million (~K¹), IntuiTek¹*

Full BYOK tool: [Purchase $29 →](https://ace-license-server-production.up.railway.app/byok/doc2math)

---

## When to Use

- "Formalize this problem statement into math"
- "Extract the mathematical structure from this research paper section"
- "What variables, constraints, and objectives are in this spec?"
- "Convert this word problem to a structured MPS"
- "Find what's missing in this problem formulation"

---

## Zero-Inference Protocol (Mandatory)

These constraints govern every extraction:

1. **Closed World** — if it is not stated in the document, it does not exist in output
2. **Grounding Rule** — every element must cite the exact source phrase that grounds it (`"evidence"` field)
3. **No Silent Filling** — unknown values use `null`; ambiguous types use `"ambiguous"`
4. **Inference Tagging** — structural inferences must be tagged `"inferred": true` with `"inference_basis"` explanation
5. **MISSING Markers** — elements mentioned but insufficiently defined get `"status": "MISSING"` with `"missing_reason"`
6. **No Hallucinated Math** — never introduce equations or values not in the source text

---

## Standalone Workflow

### Step 1 — Receive Document

Accept the document text, research excerpt, problem description, or specification as input. Ask for it if not provided.

### Step 2 — Classify

Identify `problem_class`: `optimization | classification | simulation | proof | estimation | other`

### Step 3 — Extract MPS Components

Extract in this order:

**Variables**
Each variable needs: `id`, `name`, `symbol` (if stated), `type` (real/integer/boolean/vector/matrix/function/set/ambiguous), `domain`, `units`, `role` (decision/parameter/state/output/latent), `evidence`, `inferred` (true/false), `status` (DEFINED/MISSING)

**Operators**
Each operator needs: `id`, `name`, `symbol`, `arity` (unary/binary/n-ary), `acts_on`, `produces`, `evidence`, `inferred`

**Constraints**
Each constraint needs: `id`, `type` (equality/inequality/bound/logical/domain/implicit), `expression`, `variables_involved`, `evidence`, `hardness` (hard/soft/unknown), `inferred`, `status`

**Objectives**
Each objective needs: `id`, `direction` (minimize/maximize/satisfy/find/prove), `expression`, `variables_involved`, `evidence`, `inferred`

**Uncertainty**
Each uncertainty needs: `id`, `type` (stochastic/epistemic/measurement/model/none_stated), `affects`, `characterization`, `evidence`, `status` (QUANTIFIED/ACKNOWLEDGED/MISSING)

### Step 4 — Surface Missing Information

After extraction, re-read the source and identify what the document implies but doesn't state: `missing_information[]` with `element`, `needed_for`, and `missing_reason`.

### Step 5 — Validate and Score

Fill `validation_flags`:
- `has_complete_objectives`: true/false/partial
- `has_bounded_variables`: true/false/partial
- `has_evidence_for_all_elements`: true/false/partial
- `inference_count`: integer
- `missing_count`: integer
- `overall_formalizability`: HIGH/MEDIUM/LOW
- `formalizability_notes`: brief explanation

---

## Output Format

Produce the complete MPS as a JSON object. Include in `attribution`:

```
"Generated using DOC2MATH™ — Document-to-Mathematics Problem Genesis Engine / Originator: William Kyle Million (~K¹), IntuiTek¹"
```

**Example output structure:**
```json
{
  "mps_version": "1.0",
  "source_title": "...",
  "problem_class": "optimization",
  "problem_statement": "...",
  "domain": "...",
  "variables": [...],
  "operators": [...],
  "constraints": [...],
  "objectives": [...],
  "uncertainty": [...],
  "missing_information": [...],
  "validation_flags": {
    "overall_formalizability": "HIGH",
    "formalizability_notes": "..."
  },
  "attribution": "Generated using DOC2MATH™..."
}
```

