Skip to content

[ssreflect] Use rw instead of rewrite to avoid conflicts with legacy tactic#21478

Merged
coqbot-app[bot] merged 11 commits into
rocq-prover:masterfrom
proux01:ssreflect-rw
Apr 1, 2026
Merged

[ssreflect] Use rw instead of rewrite to avoid conflicts with legacy tactic#21478
coqbot-app[bot] merged 11 commits into
rocq-prover:masterfrom
proux01:ssreflect-rw

Conversation

@proux01

@proux01 proux01 commented Jan 7, 2026

Copy link
Copy Markdown
Contributor

Since this was the major cause of conflict with legacy tactics, ssreflect could now be loaded in the Prelude (in a further PR, c.f. #21776 ). For backward compatibility

From Corelib Require Import ssreflect.

still loads a rewrite wrapper to rw.

The theories/Corelib/ssr dir still contains:

  • ssrfun.v and ssrbool.v that should go back in mathcomp (in a further PR)
  • ssreflect.v with
    • the compat rewrite tactic as alias to rw (to be removed in a few releases)
    • the of T & ... & T notation for anonymous binders (c.f., Add "& T" syntax for anonymous binder "(_ : T)" and "of _ & _ & _" syntax for constructors #21611 ) (merged)
    • the if <term> is <pattern> then <term> else <term> and if <term> isn't <pattern> then <term> else <term> notations (c.f., Add "if <term> is <pattern> then _ else _" syntax #21609 )
    • the boolean if ... then ... else notations: in the long run we should maybe deprecate the specific if ... then ... else for inductives with two constructors (that is error prone, since it depends from the order of the constructors) with a quickfix toward the new if g is first_constructor then ... else variant and restrict if ... then ... else to booleans (or anything coercible to bool)
  • Added / updated test-suite.
  • Added changelog.
  • Added / updated documentation.
    • Documented any new / changed user messages.
    • Updated documented syntax by running make doc_gram_rsts.

@proux01 proux01 added the request: full CI Use this label when you want your next push to trigger a full CI. label Jan 7, 2026
@coqbot-app coqbot-app Bot removed the request: full CI Use this label when you want your next push to trigger a full CI. label Jan 7, 2026
Comment thread plugins/ssrrewrite/ssrrewrite.mlg Outdated
proux01 added a commit to proux01/color that referenced this pull request Jan 7, 2026
proux01 added a commit to proux01/InteractionTrees that referenced this pull request Jan 7, 2026
proux01 added a commit to rocq-community/corn that referenced this pull request Jan 7, 2026
proux01 added a commit to proux01/coq-elpi that referenced this pull request Jan 7, 2026
proux01 added a commit to proux01/verdi that referenced this pull request Jan 7, 2026
proux01 added a commit to proux01/QuickChick that referenced this pull request Jan 7, 2026
proux01 added a commit to proux01/relation-algebra that referenced this pull request Jan 7, 2026
proux01 added a commit to proux01/coqprime that referenced this pull request Jan 7, 2026
proux01 added a commit to proux01/Mtac2 that referenced this pull request Jan 7, 2026
proux01 added a commit to proux01/coq-waterproof that referenced this pull request Jan 7, 2026
@proux01 proux01 added the request: full CI Use this label when you want your next push to trigger a full CI. label Jan 7, 2026
@coqbot-app coqbot-app Bot removed the request: full CI Use this label when you want your next push to trigger a full CI. label Jan 7, 2026
proux01 added a commit to proux01/flocq that referenced this pull request Jan 7, 2026
proux01 added a commit to proux01/coqutil that referenced this pull request Jan 7, 2026
@proux01 proux01 added the request: full CI Use this label when you want your next push to trigger a full CI. label Jan 7, 2026
@coqbot-app coqbot-app Bot removed the request: full CI Use this label when you want your next push to trigger a full CI. label Jan 7, 2026
proux01 added a commit to proux01/CompCert that referenced this pull request Jan 8, 2026
proux01 added a commit to proux01/relation-algebra that referenced this pull request Jan 8, 2026
@proux01 proux01 added the request: full CI Use this label when you want your next push to trigger a full CI. label Jan 8, 2026
@coqbot-app coqbot-app Bot removed the request: full CI Use this label when you want your next push to trigger a full CI. label Jan 8, 2026
proux01 added a commit to proux01/coqutil that referenced this pull request Jan 8, 2026
proux01 added a commit to proux01/coqutil that referenced this pull request Jan 8, 2026
proux01 added a commit to proux01/coqutil that referenced this pull request Jan 8, 2026
proux01 added a commit to proux01/riscv-coq that referenced this pull request Jan 8, 2026
@andres-erbsen

andres-erbsen commented Feb 12, 2026

Copy link
Copy Markdown
Contributor

I agree that the split of the ecosystem is not ideal and we ought to do something about it. I would be happy to discuss strategy if one was proposed.

I am not sure what you mean by Require-time conflicts -- are there any? I've been able to Require and wrap ssreflect in coqutil, for example, without needing the overlays here. The change I highlighted above adds controversial ssreflect constructs to by-default-Imported prelude. This does not seem necessary for fixing the compatibility issues, but is interesting as an experiment for investigating what the incompatibilities are -- or is that what you meant by "strategic PR"?

I would like to improve compatibility, but the path towards that must take into account desires and constraints of all users, mathcomp and otherwise. Obviously porting large swaths of code is costly, and shipping barely-tested constructs is not right. But I don't think we'd make any friends by forcing ssreflect as-is upon the supermajority of users who have not chosen it -- at the very least we should leave them the option whether to Import it or not.

At a higher level, my preferred path would be to

  1. Resolve Require-time issues, if any. Much less invasively than this PR.
  2. Factor out mechanisms from syntax, and make the (less controversial) mechanisms available through Require or qualified Import without the (more controversial) syntax.
  3. Evaluate individual ssreflect features (either syntax or mechanisms). For each one, either document it and adopt it or stdlib (and so on) or change/remove it in mathcomp. (And ssreflect rewrite was actually first on my list in terms of interest, I just didn't have a good experience with it.)

@CohenCyril

CohenCyril commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

I globally agree with you @andres-erbsen.

By the way I think I got mistaken when I said Require-time, I was more thinking about my experience wanting to use ssreflect in a development that did not use it and being forced to refactor all the code to be ssreflect compliant. I think this is very bad because: 1. it imposes ssreflect on potentially large code base 2. it forces a refactor before anything can be done. That's why the priority for me is to make this integration, without making other users pay the price for a language they do not (yet 😉) use, but let them use some features when they like their behaviour.

As for ssreflect evaluation, I fully agree that it should be tested on non ssr contexts to see what might be missing and improved in a backward compatible way. I'm sorry to see your issues with ssr rewrite taking an awful amount of time (I usually have the exact opposite experience so I was surprised) and I am eager to know where this slowdown comes from.

However I do think ssreflect syntax should not be "evaluated" but that there should be a second one, less perl-ish available to all, and that ideally it should resemble current syntax e.g. elim: x => [|y z] in H1 H2 * could be written induction x as [|y z] generalizing H1 H2] (with => written as, and in ... * written generalizing ..., etc) but as
compositional as ssreflect is, because I think the key feature of ssr is not its syntax, but its compositional semantics and uniformity (everything on the stack (however you call it), not modifying hypotheses implicitly, allowing on the fly generalization as part of a general "tacticial pattern", as being general, generalizing too, and not attached to each tactic with a different implementation). The syntax just happens to be short to do be able to do "obvious stuff" quickly when you are an expert, and could be opt-in.

@CohenCyril

CohenCyril commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

PS:

at the very least we should leave them the option whether to Import it or not.

What I would like to reach is the point where Importing should be fully backward compatible for users (except the possibility to use ssreflect tactic if they want). And the price to pay for that is to change a small amount of things that are incompatible with current ssreflect, without being too much of a change (both for impacted library, and also for mathcomp if we need to change somehting).

@proux01

proux01 commented Feb 20, 2026

Copy link
Copy Markdown
Contributor Author

To be discussed in a future Call: https://github.com/rocq-prover/rocq/wiki/Rocq-Call-2026-03-17

Comment thread test-suite/output-coqchk/bug_12845.out Outdated

@SkySkimmer SkySkimmer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not convinced we should be adding this stuff to the prelude
also even if we decide we should, it doesn't match the PR title "[ssreflect] use rw instead of rewrite"

Comment thread clib/unicode.ml
mk_lookup_table_from_unicode_tables_for IdentSep
[
single 0x005F; (* Underscore. *)
single 0x2017; (* Double low line. *)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ssreflect was using _foo_ for reserved identifiers (the ones introduced by move=> ?) which forbids explicitly using any such identifier. To avoid conflicts this changes it to ‗foo‗.


Axiom proof_admitted : False.
#[export] Hint Extern 0 => case proof_admitted : unused.
#[export] Hint Extern 0 => (case proof_admitted) : unused.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

???

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

case E: foo is valid ssreflect syntax (c.f., https://rocq-prover.org/doc/V9.1.0/refman/proof-engine/ssreflect-proof-language.html#generation-of-equations ), the parenthesis fixes the conflict.

@proux01 proux01 mentioned this pull request Mar 18, 2026
11 tasks
@proux01

proux01 commented Mar 20, 2026

Copy link
Copy Markdown
Contributor Author

Following last Rocq call, this is now split in two:

@gares CI green this now seems in a mergeable state

@gares gares left a comment

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.

I think that the PR now only contains what was discussed at the rocq-call, @SkySkimmer @andres-erbsen please amend your requests for changes.

I'm a little worried about the warning. I don't think it is urgent, since the use case this PR makes possible is to load SSR/MC inside non SSR/MC context. You don't really care if the the MC code uses rewrite instead of rw. The warning is there, correct me if I'm wrong, to push MC users to port their scripts. IMO this can wait. Also, the warning should really come with a quickfix, so that the porting can be done automatically.

@proux01

proux01 commented Mar 24, 2026

Copy link
Copy Markdown
Contributor Author

It's the common policy here to emit deprecation warning as soon as the replacement is available, since warnings can easily be silenced. No strong opinion but it would be strange to make an exception here.
I'll add the quickfix.

@SkySkimmer SkySkimmer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

remove the test suite makefile change

I'm also not very convinced about allowing DOUBLE LOW LINE in idents

Comment thread test-suite/Makefile Outdated
Comment thread theories/Corelib/ssrmatching/ssrmatching.v Outdated
proux01 added 8 commits March 27, 2026 11:13
Using double-low-line rather than underscore, i.e., `‗foo‗` instead of
`_foo_`, will cause less conflicts and is not an issue since, by
definition, we never type these identifiers by hand.
Since this was the major cause of conflict with legacy tactics,
ssreflect can now be loaded in the Prelude. For backward
compatibility

From Corelib Require Import ssreflect.

still loads a 'rewrite' wrapper to 'rw'. This compatibility layer
also includes the `if _ is _ then _ else _`
and the `if _ isn't _ then _ else _` notations.
Comment thread plugins/ltac/tacinterp.mli Outdated
@proux01

proux01 commented Mar 27, 2026

Copy link
Copy Markdown
Contributor Author

The warning is there, correct me if I'm wrong, to push MC users to port their scripts.

More generally, all ssreflect users.

IMO this can wait.

No strong opinion, but we usually introduce warnings with the replacement to let user know, they can then silence it until they can handle it. Doing it later means we have to remember introducing it latter, users may discover the change it later (probably not an issue here), the difference between the versions the replacement was introduced and the version the deprecation warning was introduced may make it harder to track/handle for users (particularly if this one differs whereas others usually don't).

Also, the warning should really come with a quickfix, so that the porting can be done automatically.

done

remove the test suite makefile change

@SkySkimmer done

@proux01

proux01 commented Mar 27, 2026

Copy link
Copy Markdown
Contributor Author

I'm also not very convinced about allowing DOUBLE LOW LINE in idents

Note that this is for ssreflect reserved identifiers (typically the ones introduced by move=> ?), users are not allowed to manually input such identifiers.

@proux01

proux01 commented Mar 27, 2026

Copy link
Copy Markdown
Contributor Author

@gares CI green

@gares

gares commented Mar 30, 2026

Copy link
Copy Markdown
Member

@andres-erbsen please check the updated PR. If I hear nothing I'll merge tomorrow.

@gares

gares commented Apr 1, 2026

Copy link
Copy Markdown
Member

@coqbot merge now

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

Labels

kind: enhancement Enhancement to an existing user-facing feature, tactic, etc. part: ssreflect The SSReflect proof language.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants