Skip to content

Add displays for topologies - #2143

Draft
nmolinamounier wants to merge 8 commits into
math-comp:masterfrom
nmolinamounier:topology-displays
Draft

nmolinamounier wants to merge 8 commits into
math-comp:masterfrom
nmolinamounier:topology-displays

Conversation

@nmolinamounier

@nmolinamounier nmolinamounier commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator
Motivation for this change

Fixes #758 by adding extra display arguments to topologies, in the same way as orders in math-comp.

A new type fdisp_t is added in filter.v, and every topology is associated with an instance of fdisp_t, which can be used in notations for proper display.

Since it is common to define specific topologies in terms of more generic ones, with_fdisp d' T has the same topology as T, but with display d'.

This PR requires changing every single definition involving a filtered type to add a display argument, hence its very large footprint.

About order topologies : right now, order topologies have two arguments for topology and order displays respectively. I tried merging them into a record, but this doesn't seem to play well with canonical structure inference ; we should discuss this.

Checklist
  • appended entries in the relevant sections of CHANGELOG_UNRELEASED.md
  • Finish header docs
  • Bikeshed notations and naming
  • added corresponding documentation in the headers

Reference: How to document

Merge policy

As a rule of thumb:

  • PRs with several commits that make sense individually and that
    all compile are likely to be merged as they are into master.
  • PRs with disorganized commits are very likely to be squash-rebased.
Reminder to reviewers

@nmolinamounier
nmolinamounier marked this pull request as draft October 24, 2026 16:33
@nmolinamounier
nmolinamounier marked this pull request as ready for review October 26, 2026 20:58
@nmolinamounier nmolinamounier added this to the 1.20.0 milestone Oct 26, 2026
@nmolinamounier
nmolinamounier force-pushed the topology-displays branch 4 times, most recently from 837bd9c to 39ab475 Compare November 2, 2026 07:57
Comment thread classical/filter.v Resolved
Comment thread classical/filter.v Resolved
Comment thread classical/filter.v Resolved
Filter F -> (F --> (x : T)) <-> (F --> (x : initialT)).
Proof.
move=> FF; split.
move=> FF; split.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
move=> FF; split.
move=> FF; split.

Comment on lines +130 to +131
Context (d : fdisp_t).
Context (V : topologicalType d) (S : pred V) (U : subChoiceType S).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
Context (d : fdisp_t).
Context (V : topologicalType d) (S : pred V) (U : subChoiceType S).
Context d (V : topologicalType d) (S : pred V) (U : subChoiceType S).

@affeldt-aist

Copy link
Copy Markdown
Member

Could you check for trailing spaces? (It looks your PR is introducing a few.)

Regarding the order of declaration of displays, it looks like you put all the displays at the beginning of the type signature. An alternative could be to put the display just before the first type that uses it. I have the vague memory that we already discussed this in a meeting. Do you remember @proux01 ?

Maybe we do not need to indicate the type of displays in type signatures. This is an advantage of using Context instead of Variable. Displays are already noisy enough in themselves and their type is often not informative.

@affeldt-aist

affeldt-aist commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Maybe we need to update the documentation. For example, d.-nbhs in filter.v, d.-cluster, etc. in compact.v, .-sub in subspace.v, .-open, etc. in topology_structure.v, also in connected.v, etc.

@affeldt-aist

Copy link
Copy Markdown
Member

(If it is possible, maybe several PRs introducing the notations incrementally could help organizing the work (including documentation, changelog, and review).)


Arguments nbhs_subspaceP {T} A x.
Notation "{ 'within' A , 'continuous' f }" :=
(continuous (f :> subspace A -> _)) (only parsing) : classical_set_scope.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

:> -> : ?

(forall x, @continuous_at (subspace_fdisp A) _ _ _ x f)
(only printing) : classical_set_scope.
Notation "{ 'within' A , E @[ x --> F ] --> l }" :=
(E @[x --> (F :> set_system (subspace A))] --> l)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

:> -> :?

@affeldt-aist

affeldt-aist commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

Shouldn't :> be :? I think that :> is rather used for equalities, as in a = b :> T. (I only commented on two occurrences but there are more.)

@nmolinamounier

Copy link
Copy Markdown
Collaborator Author

Shouldn't :> be :? I think that :> is rather used for equalities, as in a = b :> T. (I only commented on two occurrences but there are more.)

They are different, : remains in the resulting term whereas :> is truly volatile, which is what we want for a parse-only notation. An alternative is to specify the desired type with an implicit argument, but that is the same as using :>.

@affeldt-aist

Copy link
Copy Markdown
Member

Shouldn't :> be :? I think that :> is rather used for equalities, as in a = b :> T. (I only commented on two occurrences but there are more.)

They are different, : remains in the resulting term whereas :> is truly volatile, which is what we want for a parse-only notation. An alternative is to specify the desired type with an implicit argument, but that is the same as using :>.

Is this documented somewhere? If not, it is maybe worth at least a comment in the code, as I don't see this usage mentioned in eqtype.v. (But I might just have missed the documentation: I remember that Zachary already used it in this way.)

@nmolinamounier

Copy link
Copy Markdown
Collaborator Author

Shouldn't :> be :? I think that :> is rather used for equalities, as in a = b :> T. (I only commented on two occurrences but there are more.)

They are different, : remains in the resulting term whereas :> is truly volatile, which is what we want for a parse-only notation. An alternative is to specify the desired type with an implicit argument, but that is the same as using :>.

Is this documented somewhere? If not, it is maybe worth at least a comment in the code, as I don't see this usage mentioned in eqtype.v. (But I might just have missed the documentation: I remember that Zachary already used it in this way.)

Yes, here in the Rocq manual.

@affeldt-aist

Copy link
Copy Markdown
Member

Ah, I didn't know. I assumed this was coming from ssreflect which always had a similar syntax for equality. No documentation issue then.

@affeldt-aist

affeldt-aist commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

supremum_fdisp is maybe missing from the changelog

(prod_fdisp maybe also)

@affeldt-aist

affeldt-aist commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Regarding the order of declaration of displays, it looks like you put all the displays at the beginning of the type signature. An alternative could be to put the display just before the first type that uses it. I have the vague memory that we already discussed this in a meeting. Do you remember @proux01 ?

Here for example the displays are not put at the beginning of the type signature:

HB.mixin Record isPath {d} {i : bpTopologicalType d} 
    {d'} {T : topologicalType d'} (x y : T) (f : i -> T) 
    & isContinuous d i d' T f := {

(other occurrences in landau.v)

@nmolinamounier

Copy link
Copy Markdown
Collaborator Author

You're looking at a recent commit, I'm changing them to be before the relevant type because that's what mathcomp does for orders.

@nmolinamounier

Copy link
Copy Markdown
Collaborator Author

I am soon going to rename fdisp_t to filter_display, unless anyone has a better suggestion. Additionally, I'll use the following rule of thumb to determine when and how to declare a new display:

  1. If a type/type former has a canonical/natural topology (e.g. product, sigT, nat, bool), then it has default display. Custom displays are reserved for type aliases.
  2. If a type alias has a custom display, the display takes the same arguments as the type alias.

@nmolinamounier
nmolinamounier marked this pull request as draft November 10, 2026 14:19

This branch has not been deployed

No deployments
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.

Printing specialized notations

2 participants