Note: Updated by hand. For every user-facing tactic name, see TACTIC_INDEX.md and
src/EndKan/Tactics.lean.
EndKan adds tactics for category theory in Lean 4: it looks at the goal, picks a strategy (ends, coends, Kan extensions, Beck–Chevalley, and related shapes), and applies rewrite-style steps. Errors and timeouts are handled in ErrorHandling.lean.
- Tactics (
src/EndKan/Tactics.lean) — goal inspection and which rule to try next. - Transformations (
src/EndKan/Transformation.lean) — the actual rewrites and universal-property steps. - Errors (
src/EndKan/ErrorHandling.lean) — messages, timeouts, and step limits.
The system automatically detects and categorizes goals into patterns:
- End Patterns:
EndObj,End.π,End.lift,End.map - Coend Patterns:
CoendObj,Coend.ι,Coend.desc,Coend.map - Kan Extension Patterns:
Lan,Ran,Lan.universal,Ran.universal - Beck-Chevalley Patterns:
Square,beckChevalleyIso, etc. - Dinaturality Patterns:
DinaturalTransformation - Functor Composition Patterns:
Functor.comp,Functor.map - Natural Transformation Patterns:
NatTrans,NatTrans.app - Limit/Colimit Patterns:
LimitCone,ColimitCocone, etc.
Each pattern has associated transformation strategies:
end_beta: β-reduction for endsend_eta: η-expansion for endsend_comp: Composition rulesend_universal: Universal property applications
coend_beta: β-reduction for coendscoend_eta: η-expansion for coendscoend_comp: Composition rulescoend_universal: Universal property applications
kan_fuse: Fusion ruleskan_universal: Universal property applicationskan_preserves: Preservation properties
beck_chevalley: Basic Beck-Chevalleybeck_chevalley_comp: Composition rules
timeout: Operation exceeded time limitmaxStepsReached: Maximum transformation steps reachedpatternMatchFailed: Pattern recognition failedtransformationFailed: Transformation application failedinvalidGoal: Goal is not suitable for the tacticdependencyMissing: Required dependencies not availabletypeMismatch: Type checking failedproofSearchFailed: Proof search unsuccessfulresourceExhausted: System resources exhaustedunsupportedPattern: Pattern not supported
low— minor (for example unsupported pattern)medium— normal failure (rewrite did not apply)high— time or step limit hitcritical— missing dependency or similar hard stop
structure EndKanConfig where
timeoutMs : Nat := 2000 -- Timeout in milliseconds
trace : Bool := false -- Enable tracing
maxSteps : Nat := 200 -- Maximum transformation steps
debug : Bool := false -- Enable debug mode
aggressive : Bool := false -- Enable aggressive transformations-- End transformations
end_beta
end_eta
-- Coend transformations
coend_beta
coend_eta
-- Kan extension transformations
kan_fuse
-- Beck-Chevalley transformations
beck_chevalley!end_beta!
end_eta!
coend_beta!
coend_eta!
kan_fuse!
beck_chevalley!!endkan_smart
endkan_debugendkan_beta
endkan_eta
endkan_all-- Set timeout
setTimeout 5000
-- Enable tracing
setTrace true
-- Set maximum steps
setMaxSteps 500
-- Enable debug mode
setDebug true
-- Enable aggressive mode
setAggressive trueexample (F : Cᵒᵖ × C ⥤ D) [HasProductsOfShape C D] [HasWideEqualizers D]
(f : ∀ c : C, D.obj (op c, c)) (h : ∀ {c c' : C} (g : c ⟶ c'), f c ≫ F.map (op g, g) = f c') (c : C) :
End.lift f h ≫ End.π F c = f c := by
end_betaexample (F : Cᵒᵖ × C ⥤ D) [HasProductsOfShape C D] [HasWideEqualizers D]
(G : C × Cᵒᵖ ⥤ D) [HasCoproductsOfShape C D] [HasWideCoequalizers D] :
EndObj F ≅ EndObj F ∧ CoendObj G ≅ CoendObj G := by
constructor
· endkan_smart
· endkan_smartTactics are meant for interactive proofs. Speed depends on your goal and Mathlib version.
Lean tests and the runner live under src/EndKan/ (for example UnitTests/, IntegrationTests/, TestRunner.lean). Benchmark Lean files are under bench/ if present.
lake build
lake exe test
lake exe run_tests
lake exe test-runner -- dev unitSee tests/README.md for more.
- Goal classification and tactics:
src/EndKan/Tactics.lean - Rewrites and rules:
src/EndKan/Transformation.lean - Errors and limits:
src/EndKan/ErrorHandling.lean
The real definitions differ from any informal sketch; open these files for accurate names and behavior.
- New goal shapes: extend the pattern type and recognition code in the tactics layer.
- New rewrites: hook them into the transformation module and add tests under
src/EndKan/. - New options: extend the configuration structure and document them in API.md.
See CONTRIBUTING.md. When you add patterns or tactics, add tests and update the docs in docs/.
This project is licensed under the Apache License 2.0.
Open an issue on the project repository or see CONTRIBUTING.md.