feat(Logics/Modal): refactor formula primitives to {atom, bot, imp, box}#662
Open
benbrastmckie wants to merge 1 commit into
Open
feat(Logics/Modal): refactor formula primitives to {atom, bot, imp, box}#662benbrastmckie wants to merge 1 commit into
benbrastmckie wants to merge 1 commit into
Conversation
benbrastmckie
added a commit
to benbrastmckie/cslib
that referenced
this pull request
Jun 19, 2026
…PR description with line-number links Phase 1: Removed ~157 scratch-work inline comments from 14 Modal/ proof files Phase 2: Revised PR description with exact line-number table for all 15 strong soundness/completeness results Phase 3: Updated GitHub PR leanprover#662 body Session: sess_1781890976_cc3df6
Refactors `Cslib/Logics/Modal/Basic.lean` to use four classical primitives
`{atom, bot, imp, box}` instead of `{atom, not, and, diamond}`. Negation,
conjunction, disjunction, and diamond become derived connectives via the
Lukasiewicz encoding. Adds `HasBox` class and `ModalConnectives` bundle
in `Connectives.lean`, stacking on propositional five-primitive formula
type with primitive bot.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
e01881d to
f46056b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR refactors
Cslib/Logics/Modal/Basic.leanto use four classical primitives{atom, bot, imp, box}instead of the current{atom, not, and, diamond}. Negation, conjunction, disjunction, and diamond become derived connectives via the Lukasiewicz encoding (¬φ := φ → ⊥,φ ∧ ψ := ¬(φ → ¬ψ),φ ∨ ψ := ¬φ → ψ,◇φ := ¬□¬φ). Four files are modified:Basic.lean(formula type),Denotation.lean(match cases),LogicalEquivalence.lean(context constructors), andConnectives.lean(newHasBoxclass andModalConnectivesbundle, stacking on PR #648). Approximate diff: ~355 insertions, ~222 deletions.This PR stacks on PR #648 (
feat/propositional-v2). PR #649 (temporal) is a sibling with no dependency in either direction.Design Rationale
Why box, not diamond?
With box primitive, necessitation is a pure rule —
⊢ φ → ⊢ □φ— mentioning onlybox. The K axiom□(φ → ψ) → □φ → □ψuses onlyboxandimp. With diamond primitive, necessitation becomes an interaction law:⊢ φ → ⊢ ¬◇¬φ(requiringneg), or expanding,⊢ φ → ⊢ (◇(φ → ⊥)) → ⊥(requiringdia,imp, andbot). The underlying reason is that□pairs naturally with→— both primitive in the{bot, imp, box}signature — while◇pairs with∨, which is derived from→and⊥. [ChagrovZakharyaschev1997] §3.1 adopts the box-first presentation.Semantically, box is universal quantification over accessible worlds and distributes over implication (K). Diamond is derived as
◇φ := ¬□¬φ = (□(φ → ⊥)) → ⊥, which requires excluded middle and is therefore specific to classical modal logic.HasDiashould be added as a separate typeclass once non-classical modal logics (IK, CK) are formalized.Why bot and imp as primitives?
This follows PR #648: bot and imp are the classical minimal signature. The key reason for primitive
botis substitution invariance —⊥as a nullary operation is fixed by every substitution, preserving the free algebra property. See the Zulip discussion for the full argument. Propositionaland/orare primitive inPL.Proposition(viaHasAnd/HasOr); the Modal formula type uses Lukasiewicz encodings instead.Extending to non-classical modal logics
In classical modal logic,
and,or, anddiaare all derivable from{bot, imp, box}. Non-classical systems require these as primitives:and/orare not interdefinable viaimp/botwithout excluded middle, and◇is independent of□. The typeclass hierarchy accommodates this:{atom, bot, imp, box}ModalConnectivesand,or,diaHasAnd,HasOr,HasDiaHasAndandHasOralready exist as standalone typeclasses (instantiated onPL.Proposition). AddingHasDiaand instantiating all three on a non-classical modal formula type requires no changes toModalConnectives. We recommend completing the classical metalogic (proof system, completeness, soundness) before adding these extensions.Main Definitions
Proposition (Atom)— inductive formula type with constructors{atom, bot, imp, box}Proposition.neg,.top,.and,.or,.diamond,.iff— derived connectives (abbrev)Proposition.Context— one-hole context type with constructors{hole, impL, impR, box}LogicallyEquivalent— semantic equivalence across all models and worldsModalConnectives— bundled typeclass extendingPropositionalConnectiveswithHasBoxNotation
All notation is scoped to
Cslib.Logic.Modal:¬Proposition.neg∧Proposition.and∨Proposition.or→Proposition.imp□Proposition.box◇Proposition.diamond↔Proposition.iffModal[m,w ⊨ φ]Judgement.mk m w φRelationship to Other PRs
PR #648 (stacking dependency): This PR stacks on #648 and carries all its changes including
Connectives.leanwithPropositionalConnectives. Review and merge #648 first.PRs #528 and #535 (foundation): This PR builds directly on @fmontesi's #528/#535, retaining the
Model/Satisfies/Judgementstructure unchanged.PR #607 (coordination): PR #607 by @fmontesi introduces per-operator typeclass files. PR #607 is active as of 2026-06-16. The
impnaming in this PR is #648's settled convention — it aligns with theHasImptypeclass name and the elimination ruleimpEacross CSLib's Bimodal and Temporal types. PR #607 usesimpl. Happy to align on whichever naming reviewers prefer. The constructor refactoring from{not, and, diamond}to{bot, imp, box}is structurally incompatible with #607's current instances and requires coordination — see the comment on PR #607.PR #587 (coordination): PR #587 by @thomaskwaring (DRAFT) creates
Connectives.leanwith semantic typeclasses. PR #648 creates the same path with syntactic typeclasses. The content is complementary — see the comment on PR #587.Breaking Changes
Proposition.not,.and,.diamondreplaced by derived abbrevs with the same names (.and,.diamondcontinue to work at call sites;.notbecomes.neg)Proposition.Contextconstructors renamed:notCremoved,andL→impL,andR→impR,diamondC→boxProposition.bot,.imp,.boxChanged Files
Cslib/Foundations/Logic/Connectives.lean— addedHasBox+ModalConnectives(stacks on feat(Logics/Propositional): five-primitive formula type with primitive bot #648)Cslib/Logics/Modal/Basic.lean— refactoredPropositiontype, derived connectives,ModalConnectivesinstance,SatisfiescasesCslib/Logics/Modal/Denotation.lean— match cases updated for new primitivesCslib/Logics/Modal/LogicalEquivalence.lean—Contextconstructors andcongruenceproof updatedExcluded:
FromPropositional.lean(depends on deferredSemantics.Bool),ProofSystem/,Metalogic/,Cube.lean(scoped to subsequent PRs).Contribution Roadmap
PR feat(Logics/Propositional): five-primitive formula type with primitive bot #648: Connective typeclasses + five-primitive propositional formula type (open)
This PR: Classical modal formula type with
{atom, bot, imp, box}primitivesPR 3: Hilbert proof systems for the 15 modal cube logics (K, T, B, D, S4, S5, K4, K5, K45, KB5, D4, D5, D45, DB, TB) using the
InferenceSystemAPI as @fmontesi suggestedPR 4: Kripke semantics with strong soundness and strong completeness for all 15 systems (canonical model construction via maximal consistent sets):
k_strong_soundnessk_strong_completenesst_strong_soundnesst_strong_completenessb_strong_soundnessb_strong_completenessd_strong_soundnessd_strong_completenesss4_strong_soundnesss4_strong_completenesss5_strong_soundnesss5_strong_completenessk4_strong_soundnessk4_strong_completenessk5_strong_soundnessk5_strong_completenessk45_strong_soundnessk45_strong_completenesskb5_strong_soundnesskb5_strong_completenessd4_strong_soundnessd4_strong_completenessd5_strong_soundnessd5_strong_completenessd45_strong_soundnessd45_strong_completenessdb_strong_soundnessdb_strong_completenesstb_strong_soundnesstb_strong_completenessReferences
AI Tools Used
This PR was prepared with the assistance of Claude Code (Anthropic), used for drafting the PR description, analyzing the upstream PR landscape, running CI verification. The mathematical content, proof architecture, and design decisions were verified by the author. All Lean code compiles with no sorries.