agentsclimarketplace

Lean math discrete

Skill r-irbe/proof-skills/skills/lean-math-discrete

APM-installable agent skills for Lean 4 and Mathlib4 — proof tactics, math domains, review and research workflows, generic tooling.

Install
npx -y skills add r-irbe/proof-skills --skill lean-math-discrete

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 2 stars2 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

USE FOR: graph theory, applied lattice theory, combinatorics, DAGs, posets, provenance chains, dependency orders, lattice operations (severity / quality-gate / trust-vector / information-flow lattices), combinatorial bounds, and finite structures in Lean 4. Owns all applied lattice instances. DO NOT USE FOR: the abstract algebraic typeclass tower (use @lean-math-foundations); continuous structures (use @lean-math-analysis); writing one specific proof (use @lean-proof). TRIGGERS: graph, DAG, lattice, poset, combinatorics, provenance, dependency graph, severity lattice, knowledge graph, finite set bound.

SKILL.md

7.4 KB, as published. Nobody here has run it

Lean 4 Discrete Mathematics & Graph Theory

Guide to formalizing graphs, lattices, combinatorics, and discrete structures in Lean 4.

Routing

  • USE FOR: graph theory, applied lattice theory, combinatorics, DAGs, posets, provenance chains, dependency orders, lattice operations (severity / quality-gate / trust-vector / information-flow lattices), combinatorial bounds, and finite structures in Lean 4. Owns all applied lattice instances.
  • DO NOT USE FOR: the abstract algebraic typeclass tower (delegate to @lean-math-foundations); continuous structures (delegate to @lean-math-analysis); writing one specific proof (delegate to @lean-proof).
  • TRIGGERS: graph, DAG, lattice, poset, combinatorics, provenance, dependency graph, severity lattice, knowledge graph, finite set bound.

Workflow

  1. Identify the discrete structure (graph, lattice, poset, finite set, combinatorial relation).
  2. Map to the matching Mathlib.Combinatorics.* / Mathlib.Order.* API and read the relevant Part below.
  3. Apply the pattern; handoff to @lean-proof for the concrete proof and to @lean-math-foundations if a DecidableEq / Fintype instance is missing.

Recovery & STOP

  • STOP if cardinality blows up or a Fintype instance cannot be synthesised — handoff to @lean-math-foundations for the instance plumbing.
  • STOP if the lattice instance you need does not exist at the current Mathlib pin — escalate to @lean-research, then author the instance under @lean-proof.

Handoffs

  • Predecessors: agent:gateway, skill:lean-proof (mid-proof graph or lattice goal), skill:lean-research (combinatorial result survey).
  • Successors: skill:lean-proof (apply the discrete pattern), skill:lean-proof-review (audit the instance), skill:lean-math-foundations (typeclass / decidability plumbing).

Detailed reference

Full encyclopaedia content (Parts 1 through 7) lives in references/lean4-math-discrete.md. Load that file when authoring; the SKILL.md only carries the dispatch contract and the high-frequency pitfalls / recipes (kept inline below).

PartTopicCovers
Part 1Graph Theory in LeanSimpleGraph, Reachable, Connected, Walk / Path
Part 2DAG AlgorithmsQuiver.Path, topological-sort idioms (no canonical Mathlib tactic)
Part 3Lattice TheoryLattice, CompleteLattice, sup_inf distributivity, BoundedOrder
Part 4CombinatoricsFinset, Multiset, combinatorial identities, choose-sum lemmas
Part 5Knowledge Graph Formalizationproject knowledge-graph + provenance-chain idioms
Part 6Finite State MachinesInductive State types, transition relations, reachability
Part 7Order Theory ExtensionsGalois insertions, abstract interpretation patterns

Part 8 — Research Council Integration

Consolidated into the single canonical routing matrix: references/research-council-skill-map.md (see the "Discrete" section). When dispatching a question to a council member, cite that table rather than restating the rows here.


Part 9 — Common Pitfalls & Quick Tactics

PitfallSymptomRecovery
Missing DecidableEq on vertex typedecide / fin_cases fail with failed to synthesizederive DecidableEq on the type; or instance : DecidableEq V := …; for adhoc structures use instance : DecidableEq V := by intro a b; cases a <;> cases b <;> simp
Confusing Finset vs SetFinset.mem doesn't fire on a Set goalUse Set.toFinset (needs [Fintype]) or rewrite the goal in Finset terms; the two APIs do not mix lemma-by-lemma
omega fails on a "should be obvious" Finset.card boundomega has no card lemmasUnfold Finset.card via Finset.card_insert_of_not_mem / Finset.card_image_of_injective first, then omega
Lattice instance overlap with foundationsDiamond / "multiple instances" warningLocally attribute [-instance] foo or move the instance to the right cluster (applied → here, abstract → foundations)
Infinite graph snuck inDecidable synthesis explodes; build hangsAdd [Fintype V] and re-check the existential / for-all is bounded over a Finset, not a Set
SimpleGraph vs Graph (multi-edge) confusionTheorem statement uses the wrong vertex pair typeSimpleGraph = irreflexive symmetric V → V → Prop; multi-edge graphs need Quiver or hand-rolled types

Quick reference — top-5 discrete tactics

  1. decide — for closed finite goals (no free variables, small cardinality); the workhorse for Decidable props on Fin n.
  2. omega — linear arithmetic over Nat / Int; works on Finset.card only after unfolding the cardinality recurrence.
  3. fin_cases h — case-split on Fin n, Finset, or Finset.range; the canonical way to enumerate.
  4. simp [Finset.mem_*] — Finset membership rewrites are the staple; pair with mem_filter, mem_image, mem_insert.
  5. aesop — try last; often closes graph-and-lattice mixed goals with aesop (add safe simp [Finset.subset_iff]).

Part 10 — Mathlib Cross-Reference Index

Concrete entry-points for the most common discrete-math goals:

GoalMathlib lemma / namespace
Connectivity in a SimpleGraphSimpleGraph.Connected, Reachable
DAG / topological sortQuiver.Path, no canonical topological-sort tactic — author one
Lattice sup/inf interactionMathlib.Order.Latticesup_inf_distrib_left family
Galois connection between concrete and abstractGaloisConnection, GaloisInsertion in Mathlib.Order.GaloisConnection
Finset cardinality boundFinset.card_le_card, Finset.card_image_le, Finset.card_filter_le
Fintype instance on a structurederiving Fintype, DecidableEq (works on most product / sum types)
Combinatorial identityFinset.sum_range_succ, Finset.sum_choose_succ_* (Pascal-rule family)

See also

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.