Skip to content

[ refactor ] make contradiction and friends entirely definitionally proof-irrelevant #2802

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

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

jamesmckinna
Copy link
Contributor

@jamesmckinna jamesmckinna commented Aug 4, 2025

The inevitable breaking consequence of #2785 , designed as a 'cleaning of the stables'.
Cf. #2346 whose intention it follows.
Currently duplicates functionality from #2803 ; will tidy up once that is merged.

Downstream consequence:

  • some uses of contradiction internally need eta-expansion (and this may be regarded as a UX failure...?)
  • consequently, so too may some client uses of this definition elsewhere (but no others in stdlib that I can find)

TODO:

Consider also:

  • refactoring Relation.Nullary.Reflects to make its various arguments definitionally proof-irrelevant
  • deprecating/removing Relation.Nullary.Negation.Core._¬-⊎_ in favour of contradiction₂, or else change its type as well; its one use in stdlib is inReflects, so could be refactored in any case via ¬-recompute and inlining...
  • ...

@jamesmckinna jamesmckinna added this to the v3.0 milestone Aug 4, 2025
@@ -409,17 +409,17 @@ module Antisymmetry
length (y ∷ ys₁) ≤⟨ length-mono-≤ ss ⟩
length zs ≤⟨ ℕ.n≤1+n (length zs) ⟩
length (z ∷ zs) ≤⟨ length-mono-≤ rs ⟩
length ys₁ ∎) $ ℕ.<-irrefl ≡.refl
length ys₁ ∎) (ℕ.<-irrefl ≡.refl)
Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps don't roll in such pure, non-breaking style changes in to something breaking and make a separate (if tiny) PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not a style change; it's yet another 'feature' of irrelevant function spaces: _$_ is no longer well-typed!

@@ -26,38 +26,48 @@ infix 3 ¬_
¬_ : Set a → Set a
¬ A = A → ⊥

-- Note the following use of flip:
private
note : (A → ¬ B) → B → ¬ A
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 bother to move this to the top of the file, maybe also document where the 'note' is useful in reading below?

Copy link
Contributor Author

@jamesmckinna jamesmckinna Aug 4, 2025

Choose a reason for hiding this comment

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

Well... for starters, breaking, so code motion ought to be permissible?

Secondly, more importantly, some of the properties in this module (eg _¬-⊎_ and ¬¬-η) are consequences of the minimal logic interpretation of ¬_, and they are conceptually prior to the ones which make genuine use of ex falso ⊥-elim(-irr)... so it made sense to me that they occur first in the module. Cf. #2803

As to the best way to document this separation of concerns, suggestions welcome!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe one way to resolve this is to interpolate a v2.4 non-breaking PR which reorganises Negation.Core to distinguish

  • definition
  • consequences/properties per minimal logic: note, ¬¬-η, contra-diagonal...
  • consequences/properties per use of ex falso

rather than try to do this as part of this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And/or add some text to #2798 to emphasise the distinction?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See: #2805

@jamesmckinna
Copy link
Contributor Author

jamesmckinna commented Aug 4, 2025

Thanks @JacquesCarette for the speedy feedback (on a DRAFT PR for v3.0!).

For most of your queries, eta-expansion is needed because there's no (contravariant) subtyping between .A → B and A → B.

As for the ones which seemingly contradict #2653 , see #2803 : don't use contradiction where simple application will do instead! (Ie use of negation sometimes happens in the minimal logic fragment, without needing ex falso at all)

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

Successfully merging this pull request may close these issues.

2 participants