Skip to content

Conversation

mlebar-UC
Copy link

I've added a formalization of several substructural logics in the src folder, based on chapter 2 of Greg Restall's "An Introduction to Substructural Logics". This is work I did as part of a master's research project. My hope is that the work I've done here can be a useful resource for anyone wanting to study logics in Agda. Please let me know if there any changes I can make to help this fit the Agda standard library.

@jamesmckinna
Copy link
Contributor

jamesmckinna commented Sep 7, 2025

Zeroth thought: this looks really nice!

First thought: we might need to scratch out heads a while about opening up/committing the Logic.* namespace to this?

Second thought: could this be refactored to prune out a lot of the DRY repetition of eg the initial parameter telescopes of (most) of the definitions?

  • Either, by reifying them as a record, eg RawLogic on the model of Algebra.Bundles.Raw...?
  • Or, by making them top-level parameters of each (sub-)module?

Third thought: everything is tied to 'Logic over Set, ie at Level zero, rather than making it Level-polymorphic. Presumably (?) it would be straightforward to generalise everything, albeit a lot of tedious editing to do so...

Fourth thought: On the model of the various README modules which document/show exemplary usage, are there good such 'example' files which you could add to this development (esp. wrt the slightly 'occult' use of language such as Struct to embed propositions as ... wff-like things; readers unfamiliar with Restall's book, or general approach, might find this hard going at first?)

Fifth, nitpicky, thought: the fat semicolon is... annoying cf. #2303

@JacquesCarette
Copy link
Contributor

I've got a detailed review incoming. Agree with thoughts 0-4.

@MatthewDaggitt
Copy link
Contributor

At the risk of being a dissenting opinion, is this something that might be better as a standalone library? My initial reaction is that this feels very similar to https://github.com/agda/agda-stdlib/blob/master/src/Data/Fin/Substitution.agda and its child modules which I think we agreed at some point probably shouldn't live in the standard library?

@@ -0,0 +1 @@
* Added a folder "Logic" in src. This provides a formalization of several substructural logics based on chapter 2 of Greg Restall's "An Introduction to Substructural Logics". My hope is that this can provide a useful framework for anyone wanting to study a variety of logics in Agda. This was a master's research project done under Professor Stuart Kurtz, and I'm really happy with my work here - I would love to contribute to the standard library, and I am happy to make any appropriate modification to help with that.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We try not to have long lines - can you please cut these down to ~80 characters wide?

open import Logic.Logic

record And-Logic
{Lang : Set} {Struct : Set} (S : Lang → Struct)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would probably make sense to bundle all these things up in a record?

Certainly it would make sense to explain (in the CHANGELOG? A README?) what the overall design is.

(_⨾_ : Struct → Struct → Struct)
(_⇒_ _∧_ : Lang → Lang → Lang) : Set where
field
is-logic : Logic S _⊢_ C⟨_⟩ _⨾_ _⇒_
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this field be a parameter? You're building And-logic on top of implicational logic, right?

X ⊢ B →
-------------------
X ⊢ (A ∧ B)
and-elimination-1 :
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think left and right would make more sense than -1 and -2. I know you're following Restall, but he chose bad names, we don't have to follow suit!

X ⊢ B

if-and-distrib :
∀ (Lang : Set) (Struct : Set)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This repetition of arguments screams for having module _ ... encapsulating that.

open import Logic.Logics.BCK-Logic
open import Logic.Structural-Rules.W-Logic

record J-Logic
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're going to call it J, you need to explain why!

open import Logic.Connectives.Backif-Logic
open import Logic.Connectives.Fusion-Logic

record L-Logic
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lambek instead of L, unless there is precedent?


is-comma-logic : Comma-Logic S _⊢_ C⟨_⟩ _⨾_ _/_ _⇒_

comma-product-context-l :
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

surely a better name can be found?


open import Logic.Logic

record B'-Logic
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a standard name for this logic? reference?

field
is-logic : Logic S _⊢_ C⟨_⟩ _⨾_ _⇒_

converse-assoc :
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sym-assoc ?

@JacquesCarette
Copy link
Contributor

At the risk of being a dissenting opinion, is this something that might be better as a standalone library?

I certainly agree that the bar for introducing logics into stdlib ought to be high. But my work on MathScheme strongly hints that 'logics' are both quite algebraic and 'fit' quite well in a setting like stdlib if done well and in a certain style.

@jamesmckinna
Copy link
Contributor

Re: @MatthewDaggitt on Data.Fin.Substitution
The full discussion is on the PR which refactored that to move the untyped lambda calculus example to README, but I didn't think our intention had been to remove it entirely...

So, to the 'dissenting' view, I agree to the extent that I wouldn't be happy to give top-level Logic. over to this, but as Logic.Substructural... sure, why not?

I'd be interested to see @JacquesCarette develop his argument from MathScheme. 'Algebra of logic' seems a very respectable kind of addition... not least given my own interests towards developing (universes for) proof-theoretic constructions such as those of Harrop and successors, towards internalising certain kinds of proof procedures around classical logic/Decidable propositions.

@mlebar-UC
Copy link
Author

Thanks everyone for the detailed feedback. Jacques, I especially appreciate you taking the time to go through my code in such detail. I'll take some time to modify with these comments in mind and resubmit.

@MatthewDaggitt
Copy link
Contributor

I certainly agree that the bar for introducing logics into stdlib ought to be high. But my work on MathScheme strongly hints that 'logics' are both quite algebraic and 'fit' quite well in a setting like stdlib if done well and in a certain style.

'Algebra of logic' seems a very respectable kind of addition...

Okay, that's fine! Just wanted to raise it as a possibility, if you're both happy with the addition, let's go for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants