Skip to content

[ refactor ] Data.Product.Relation.Binary.Pointwise.NonDependent - #3081

Closed
jamesmckinna wants to merge 9 commits into
agda:masterfrom
jamesmckinna:issue2174
Closed

[ refactor ] Data.Product.Relation.Binary.Pointwise.NonDependent#3081
jamesmckinna wants to merge 9 commits into
agda:masterfrom
jamesmckinna:issue2174

Conversation

@jamesmckinna

@jamesmckinna jamesmckinna commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Fixes #2174 (or rather: will at some point).

Currently:

  • provisional: first steps
  • problem with defining zip so that existing uses of Product.zip can be drop-in replaced
  • also map doesn't work for eg symmetric

Advice welcome!

Alternative strategy: try to make this module a specialisation of Data.Product.Relation.Binary.Pointwise.Dependent? UPDATED no because the use of IREL there opens the door to unsolved metavariables when considering the constant IREL generated from a given REL...

NB. Universe levels for the definitions in {Non}Dependent have been corrected!

UPDATED: I'm abandoning this. The knock-on consequences are so/too painful to fix/figure out... anyone else is welcome to attempt this!

@jamesmckinna
jamesmckinna marked this pull request as draft July 17, 2026 12:39
@jamesmckinna

Copy link
Copy Markdown
Collaborator Author

NB. The new definition of Pointwise has an 'easy' definition of map, but trying to write down the type of the corresponding zip defeated my tired brain, so there's an open refactoring opportunity for anyone interested. In the meantime, all the prior uses of Product.zip have been inlined for the new definition, and a detour via Dec.map′ to avoid having to write a bespoke combinator for decidability...

... and the knock-ons for Setoid etc. do seemingly require a lot of refactoring/reengineering of the basic Data.Product combinators for the new Pointwise. Sigh.

@JacquesCarette JacquesCarette left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Definitely need to crack that zip nut, as that is the 'right' way to define a number of the things that are now done 'by hand'.

------------------------------------------------------------------------

{-# OPTIONS --without-K --safe #-}
{-# OPTIONS --without-K --allow-unsolved-metas #-}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I know it's Draft, but I'm leaving this as a note to make sure this doesn't slip through!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, but this arises from yet more of the same regarding the need to rebind Pointwise-local versions of the Product.* combinators. Very frustrating! Esp. as even with map, it seems necessary to fully apply it, which somewhat defeats the purpose of having the combinators in the first place!


open Pointwise public

Pointwise′ : REL A B ℓ₁ → REL C D ℓ₂ → REL (A × C) (B × D) (ℓ₁ ⊔ ℓ₂)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we need this at all?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This was part of the experiment:

  • to retain the old definition, perhaps with some kind of backwards compatibility in mind (naming stymies this of course)
  • but also in case I needed to convert back-and-forth in order to be able to invoke Product.* combinators... such as in symmetric below.

It's why this is still DRAFT!


×-symmetric : Symmetric R → Symmetric S → Symmetric (Pointwise R S)
×-symmetric sym₁ sym₂ = Product.map sym₁ sym₂
×-symmetric {R = R} {S = S} sym₁ sym₂ (x₁Rx₂ , y₁Sy₂) = sym₁ x₁Rx₂ , sym₂ y₁Sy

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You don't need to bind R and S on the lhs. And wasn't the map version more elegant? That way you can prove things about ×-symmetric by using results about map instead of having to do them from scratch.

@jamesmckinna jamesmckinna Jul 21, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Re: R and S: yes, you're right. This is debris from earlier versions of this module.

Re: map. The Product version works precisely because Pointwise isn't wrapped as a record... ;-) With the wrapped version, we have

×-symmetric : Symmetric R  Symmetric S  Symmetric (Pointwise R S)
×-symmetric sym₁ sym₂ xR×Sy = map sym₁ sym₂ {!xR×Sy!}

but any attempt to refine the last goal with the indicated hypothesis (and hope for an eta-contraction downstream), is thwarted by the fact that

  • Pointwise (flip R) (flip S) y x (essentially the type of the goal), and
  • (Pointwise R S) x y

are not definitionally equal. Whereas they are if Pointwise is given the old way. Maddening!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Even with eta-equality for the record type, and making map 'lazier' via

map : ≈₁ ⇒ R  ≈₂ ⇒ S  Pointwise ≈₁ ≈₂ ⇒ Pointwise R S
map f g xR×Sy = f (proj₁ xR×Sy) , g  (proj₂ xR×Sy)

I find I still have to write

×-symmetric : Symmetric R  Symmetric S  Symmetric (Pointwise R S)
×-symmetric sym₁ sym₂ xR×Sy = map sym₁ sym₂ (proj₁ xR×Sy , proj₂ xR×Sy)

Suggestions welcome!

Comment thread src/Data/Product/Function/NonDependent/Setoid.agda Outdated
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.

Relations in proofs in Data.Product.Relation.Binary.Pointwise.NonDependent don't appear to be inferable

2 participants