Skip to content

Conversation

javierdiaz72
Copy link
Contributor

This PR adds cartesianProductWith⁻ and cartesianProduct⁻ to Data.List.Relation.Unary.All.Properties.

Copy link
Contributor

@JacquesCarette JacquesCarette left a comment

Choose a reason for hiding this comment

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

A few nitpicks.

* In `Data.List.Relation.Unary.All.Properties`:
```agda
cartesianProductWith⁻ : ∀ f →
f Preserves₂ _≈₁_ ⟶ _≈₂_ ⟶ _≡_ →
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no point right-indenting so much, go ahead and only indent the type by 2-4 spaces, so as to use fewer lines

Copy link
Contributor

@jamesmckinna jamesmckinna Sep 4, 2025

Choose a reason for hiding this comment

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

Also: no need for the explicit quantifiers for f and xs/ys in this type?
(But there seems to be no explicitly documented consensus on how much detail of such kind we expect in a CHANGELOG entry...?)

Indeed, are you sure that xs/ys even need to be explicitly quantified at all here?

All P (cartesianProductWith f xs ys) →
(∀ {x y} → x ∈₁ xs → y ∈₂ ys → P (f x y))
cartesianProductWith⁻ {P = P} f pres (x′ ∷ xs) ys Ps {y = y} x∈x′∷xs y∈ys
with x∈x′∷xs | ++⁻ (map (f x′) ys) Ps
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 it would be nicer the use plain pattern-matching for the x∈x′∷xs argument and then dispatch on with.

Also: is there a way to use equational reasoning instead of rewrite? This proof is far from limpid.

Copy link
Contributor

Choose a reason for hiding this comment

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

And rather than use with, as the result of that computation has a single-constructor type, it can be irrefutably matched with a pattern-matching let instead, or even the new using syntax?

Copy link
Contributor

Choose a reason for hiding this comment

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

But, if the issue is one of laziness, namely that different projections are used in each branch, then better to use proj₁/proj₂ instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also: in each case branch, pointless eta-expansion wrt the y∈ys argument...

@jamesmckinna
Copy link
Contributor

jamesmckinna commented Sep 3, 2025

The Preserves assumption on f seems suspiciously strong, with its use of propositional equality. In other words the lemmas added seem to be insufficiently generalised. Can you improve matters by making a suitable additional Respects assumption about P?

UPDATED: I think that the 'real' cartesianProductWith⁻ should take into account a Setoid/IsEquivalence structure on the codomain of f... and that f should be suitably Congruent₂ wrt its input arguments, and that result structure... in such a way that when specialised to the Pointwise structure on the product, in the special case of cartesianProduct, such congruence property becomes automatic. Additionally, P should suitably respect such structure.

I think that this is the 'usual' problem with _∧_/ _×_ as a connective: we can present it (Prawitz-style) just in terms of _,_/proj₁/proj₂, but it is 'better' to consider it Gentzen-/Schroeder-Heister- style in terms of _,_ and a left rule which is more like pattern-matching let, with result type/conclusion in 'general position' as arbitrary proposition C. The extension to considering Setoid lifting of these concepts seems to demand that we take the more general option?

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.

3 participants