-
Notifications
You must be signed in to change notification settings - Fork 167
feat(Logic): logical operators #607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
31fb1ca
31dcc0e
060954e
2f4b4c9
1024345
d4410e3
63918a2
500a9d9
9669f24
604ba15
20b4a92
c7e5a4c
abf73e5
059a85c
c2ec296
8e68fb5
94d9d14
5c43f8e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,96 @@ | ||||||
| /- | ||||||
| Copyright (c) 2026 Fabrizio Montesi. All rights reserved. | ||||||
| Released under Apache 2.0 license as described in the file LICENSE. | ||||||
| Authors: Fabrizio Montesi, Thomas Waring | ||||||
| -/ | ||||||
|
|
||||||
| module | ||||||
|
|
||||||
| public import Cslib.Init | ||||||
|
|
||||||
| /-! # Logical operators | ||||||
|
|
||||||
| This module contains typeclasses and associated notation for common logical operators: propositional | ||||||
| connectives (like `∧` and `→`), modalities (like `◇`, plain and indexed), linear connectives (like | ||||||
| `⊗`), etc. | ||||||
| -/ | ||||||
|
|
||||||
| @[expose] public section | ||||||
|
|
||||||
| namespace Cslib.Logic | ||||||
|
|
||||||
| section Propositional | ||||||
|
|
||||||
| -- ## Propositional connectives | ||||||
|
|
||||||
| /-- The type `α` has an and connective (`∧`). -/ | ||||||
| class HasAnd (α : Type*) where | ||||||
| /-- `a ∧ b` is the conjunction of `a` and `b`. -/ | ||||||
| and (a b : α) : α | ||||||
|
|
||||||
| @[inherit_doc] scoped infixr:36 " ∧ " => HasAnd.and | ||||||
|
|
||||||
| /-- The type `α` has an or connective (`∨`). -/ | ||||||
| class HasOr (α : Type*) where | ||||||
| /-- `a ∨ b` is the disjunction of `a` and `b`. -/ | ||||||
| or (a b : α) : α | ||||||
|
|
||||||
| @[inherit_doc] scoped infixr:30 " ∨ " => HasOr.or | ||||||
|
|
||||||
| /-- The type `α` has an implication connective (`→`). -/ | ||||||
| class HasImp (α : Type*) where | ||||||
| /-- `a → b` denotes `a` implies `b`. -/ | ||||||
| imp (a b : α) : α | ||||||
|
|
||||||
| @[inherit_doc] scoped infixr:25 " → " => HasImp.imp | ||||||
|
|
||||||
| /-- The type `α` has a bi-implication connective (`↔`). -/ | ||||||
| class HasIff (α : Type*) where | ||||||
| /-- `a ↔ b` denotes `a` implies `b` and vice-versa. -/ | ||||||
| iff (a b : α) : α | ||||||
|
|
||||||
| @[inherit_doc] scoped infixr:20 " ↔ " => HasIff.iff | ||||||
|
|
||||||
| /-- The type `α` has a negation connective (`¬`). -/ | ||||||
| class HasNot (α : Type*) where | ||||||
| /-- `¬a` is the negation of `a`. -/ | ||||||
| not (a : α) : α | ||||||
|
|
||||||
| @[inherit_doc] scoped notation:max "¬" p:40 => HasNot.not p | ||||||
|
|
||||||
| end Propositional | ||||||
|
|
||||||
| section Modal | ||||||
|
|
||||||
| -- ## Modalities | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
will make this a heading in the docs, same throughout. |
||||||
|
|
||||||
| /-- The type `α` has a box modality (`□`). -/ | ||||||
| class HasBox (α : Type*) where | ||||||
| /-- `a` is valid in all immediately reachable states. -/ | ||||||
| box (a : α) : α | ||||||
|
|
||||||
| @[inherit_doc] scoped prefix:40 "□" => HasBox.box | ||||||
|
|
||||||
| /-- The type `α` has a diamond modality (`◇`). -/ | ||||||
| class HasDiamond (α : Type*) where | ||||||
| /-- `a` is valid in a reachable state. -/ | ||||||
| diamond (a : α) : α | ||||||
|
|
||||||
| @[inherit_doc] scoped prefix:40 "◇" => HasDiamond.diamond | ||||||
|
|
||||||
| end Modal | ||||||
|
|
||||||
| section Linear | ||||||
|
|
||||||
| -- ## Linear connectives | ||||||
|
|
||||||
| /-- The type `α` has a tensor connective (⊗). -/ | ||||||
| class HasTensor (α : Type*) where | ||||||
| /-- `a ⊗ b` is the multiplicative conjunction of `a` and `b`. -/ | ||||||
| tensor (a b : α) : α | ||||||
|
|
||||||
| @[inherit_doc] scoped infixr:35 " ⊗ " => HasTensor.tensor | ||||||
|
|
||||||
| end Linear | ||||||
|
|
||||||
| end Cslib.Logic | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -650,7 +650,7 @@ instance : Congruence (Proposition Atom) Proposition.Equiv where | |
| intro ctx a b hab | ||
| induction ctx <;> grind [= Context.fill] | ||
|
|
||
| noncomputable instance : LogicalEquivalence (Proposition Atom) (Sequent Atom) Proof where | ||
| noncomputable instance : HasLogicalEquivalence (Proposition Atom) (Sequent Atom) where | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that the
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We use |
||
| eqv := Proposition.Equiv | ||
| eqvFillValid {a b : Proposition Atom} (heqv : a.Equiv b) | ||
| (c : HasHContext.Context (Sequent Atom) (Proposition Atom)) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd still strongly recommend something like
to save reinventing the lemmas already in mathlib.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(similarly below for
HImp,bihimp, andhnot)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you have an example of lemmas we would duplicate? eg you would almost never have
a ∧ b = b ∧ aas an equality, so none of the lattice lemmas would apply