Formal math & derivation verification workflow for Markdown documents annotated with MarkReview. Uses local SymPy, NumPy/SciPy, Z3 (SMT), and optional Lean 4 to verify equations, inequalities, derivations, and numerical examples, then writes verified/counterexample evidence directly back into MarkReview cards.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Markreview Verify?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/xd11012202-markreview-verify)
---
name: markreview-verify
description: Formal math & derivation verification workflow for Markdown documents annotated with MarkReview. Uses local SymPy, NumPy/SciPy, Z3 (SMT), and optional Lean 4 to verify equations, inequalities, derivations, and numerical examples, then writes verified/counterexample evidence directly back into MarkReview cards.
---
# MarkReview Formal Math Verification Skill (`markreview-verify`)
A universal, tool-agnostic Agent Skill for **Claude Code**, **Antigravity**, **Cursor**, **Codex**, and any terminal-capable AI coding agent working on Markdown documents with **MarkReview** (`v0.2.0+`).
---
## When to Use This Skill
Activate this skill whenever:
- A Markdown file contains MarkReview `🔬 形式化验证` cards with status `pending` (`待验`) or `failed` (`存疑`);
- The user pastes a MarkReview **「🔬 公式形式化验算 Prompt」** or asks you to verify equations, inequalities, derivations, or numerical tables in a `.md` manuscript / RFC / technical report.
---
## Golden Rules (Anti-Hallucination & Integrity Protocol)
1. **Never verify by mental math alone.** You MUST run real verification code in the terminal (`python`, `lean`, `lake`, etc.) and ground every conclusion in actual execution output.
2. **Never fabricate missing tool runs.** If a requested tool (e.g. `z3-solver` or `lean`) is not installed in the current environment, state that explicitly, offer the exact install command, and fall back to an actually installed verifier (`SymPy`/`NumPy`) with the **real** tool badge updated accurately (never label a `SymPy` run as `Lean 4`).
3. **Never silently modify manuscript equations or anchors.** During verification, preserve all original prose, LaTeX equations, and HTML anchor comments (e.g. `<!-- [S2.3-P2] -->`). Report mistakes or counterexamples by marking the card `failed` (`存疑`) with concrete evidence so the human author decides how to fix the prose.
4. **Prevent "Formalization Drift" (形式化失真).** Every formal model (SymPy expression, Z3 constraint, or Lean 4 theorem) must faithfully preserve the domain assumptions of the paper (e.g. $t_i > 0$, $N \ge 1$, integer vs. real, strict vs. non-strict inequalities). Never weaken assumptions just to make a proof pass.
5. **Zero `sorry` / `admit` / custom `axiom` in Lean 4.** Every Lean 4 proof must compile cleanly via `lean` or `lake build` AND pass static inspection (you may run `scripts/check_lean_proof.py <file.lean>`).
---
## Tiered Verification Strategy
Choose the highest-ROI tool matching the requested badge (or pick automatically when badge is `Auto`):
### Tier 1 — `SymPy+NumPy` (Default for 90% of Engineering, CS, & Applied Math Papers)
Best for: algebraic simplification, differentiation/integration, Taylor expansion, matrix identities, limits, and worked numerical examples/tables.
1. **Symbolic Check (`SymPy`)**:
- Define typed symbols with exact assumptions (`positive=True`, `real=True`, `integer=True`).
- Check `sp.simplify(lhs - rhs) == 0` (or `sp.expand`, `sp.factor`, `sp.trigsimp`, `sp.nsimplify`).
2. **Numerical Stress & Boundary Testing (`NumPy` / `SciPy`)**:
- Evaluate both sides on **≥ 100 random valid inputs** plus edge cases (equal inputs, near-zero, large scale, single element) and verify max absolute/relative error `< 1e-10`.
- Recompute **every worked example and numerical table** tied to the equation (e.g., verify claimed averages, ratios, percentages).
3. **Optional Monte Carlo Sanity Check**:
- For stochastic/queueing/probabilistic models (e.g., arrival processes, random hopping), run a quick simulation (e.g., 100k samples) to validate the modeling formula itself, not just algebra.
### Tier 2 — `Z3` (SMT Solver for Inequalities, Bounds, & Discrete Logic)
Best for: proving universal inequalities ($\forall x > 0, \dots$), feasibility/boundary conditions, piecewise formulas, scheduling/protocol invariants, and finding concrete counterexamples.
- To prove $\forall x \in D, P(x)$: assert $x \in D \land \neg P(x)$ in `z3.Solver()`.
- `unsat` → **Proven** (no counterexample exists within the modeled domain).
- `sat` → **Disproved** — extract `s.model()` and write the exact counterexample into a `failed` (`存疑`) MarkReview card!
- Keep `z3` dimension tractable (for $n$-variable symmetric sums, test fixed small $n = 2, 3, 4, 5$ in Z3 for counterexamples and combine with `SymPy`/Cauchy-Schwarz proof for general $n$, noting the exact proved scope transparently).
### Tier 3 — `Lean 4` (Machine-Checked Axiomatic Proofs)
Best for: pure math lemmas, cryptographic/security properties, strict convergence or inequality proofs where zero gaps are required.
1. Check environment: `lean --version` (or `lake --version` in a Mathlib project).
2. Write a standalone `.lean` file in a temporary/scratch location (do not pollute the user's manuscript directory unless requested).
3. Run `lean <file.lean>` (or `lake env lean <file.lean>`).
4. Run the static anti-cheat checker:
```bash
python scripts/check_lean_proof.py <file.lean>
```
Verify exit code `0` (zero `sorry`, zero `admit`, zero user-added `axiom`).
5. Explicitly cross-check that the Lean theorem statement matches the Markdown text without dropped constraints.
---
## MarkReview Source Card Protocol (Write-Back Format)
Inspect the target `.md` file first and **match the syntax already used in the file** (default is `span`).
### 1. Colored HTML `<span>` (Default, MPE & GitHub Compatible)
- **Verified (`已通过`)**:
```html
<span class="mr-ann mr-verify mr-verify-verified" data-mr="verify" data-mr-tool="SymPy+Z3" data-mr-status="verified" style="color: #15803d; font-weight: bold;">[形式化验证|SymPy+Z3|已通过:Z3 证明 ∀t_i>0 恒有 $\bar{W} \ge \bar{t}/2$;SymPy 复核算例表 2.5/3.0 分钟误差为 0]</span>
```
- **Failed / Counterexample (`存疑`)**:
```html
<span class="mr-ann mr-verify mr-verify-failed" data-mr="verify" data-mr-tool="Z3" data-mr-status="failed" style="color: #d93025; font-weight: bold;">[形式化验证|Z3|存疑:反例 $t=[1,3]$ 时左式 $=1.25 \ne$ 右式 $=1.00$,推导漏掉系数 $1/2$]</span>
```
### 2. Pure Markdown Blockquote (`blockquote`)
```markdown
> **[形式化验证|SymPy+NumPy|已通过]**:SymPy 化简恒等成立;200 组随机采样最大误差 < 1e-15。
```
### 3. CriticMarkup (`criticmarkup`)
```markdown
{>>形式化验证|Lean 4|已通过:lean 4.x 零 sorry 编译通过,严格等价于原命题假设<<}
```
### Concise Card Writing Guidelines
- Always update **both** `data-mr-tool` / `data-mr-status` attributes (if using `span`) **and** the visible header `[形式化验证|<ActualTool>|已通过/存疑:...]`.
- Set `<ActualTool>` to the **actual tool(s) executed** (e.g., `SymPy+NumPy`, `SymPy+Z3`, `Z3`, `Lean 4`).
- Keep card text crisp (1–3 sentences): include the exact checked scope, numeric tolerance or proof result, and concrete counterexample if failed.
---
## Optional Dual-AI Cross-Audit Workflow (Zero Formalization Drift)
For high-stakes papers (IEEE / Nature / formal specs) using dual-AI co-signing (e.g., **Claude Code + Antigravity / Codex**):
1. **Agent A (Verifier)**: Writes and runs verification scripts (`SymPy`/`Z3`/`Lean 4`), writes real evidence into MarkReview `🔬 形式化验证` cards, and saves/prints the short verification snippet.
2. **Agent B (Auditor)**: Reviews **only** (a) whether Agent A's script assumptions exactly match the Markdown prose/equations, (b) whether any hidden edge case (division by zero, negative values, boundary equality) was ignored, and (c) whether the card conclusion overclaims beyond what was actually proved.
3. Once both pass, the human author sees green `✅ 已通过` badges right under each equation and can export a stripped `*_clean.md` before final publication.