Skip to content
Snippets Groups Projects

Fix `Export` order for `length`. Remove `length` hack in strings.

Merged Robbert Krebbers requested to merge ci/robbert/length into master

The notation in strings was a hack to shadow the length function on strings with those on lists.

@msammler and I figured out how to change the imports to fix this problem without the hack. Basically, stdpp.base exports Coq.Strings and Coq.List in the right order, so the shadowing is done right. As a consequence Coq.Strings should never be exported by hand.

This approach seems to work among all supported Coq versions.

We also added a test.

Edited by Robbert Krebbers

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
3 3 abstract interfaces for ordered structures, sets, and various other data
4 4 structures. *)
5 5
6 From Coq Require Export Morphisms RelationClasses List Bool Utf8 Setoid.
6 (** The order of this [Require Export] is important: The definition of [length]
7 in [List] should shadow the definition of [length] in [String]. We also need
8 to export [Datatypes] because [List] contains a [parsing only] notation for
9 [length], not the actual definition of [length], which is in [Datatypes]. *)
10 From Coq Require Export String Datatypes List.
  • It seems rather excessive and potentially problematic to export String to every single user of std++. (I am not sure what Datatype contains.)

    Edited by Ralf Jung
  • Datatypes contain all the basic data types like bool, list, unit, and some basic functions on those, like length.

  • It seems rather excessive and potentially problematic to export String to every single user of std++.

    If things are properly shadowed it should not hurt. Note that we already export tons of stuff like Utf8, Setoids, Program stuff, etc.

    Anyway, to assess if it causes any problems, could we run the CI on all Iris reverse dependencies?

  • If things are properly shadowed it should not hurt.

    Well this is still a gross misuse of the Coq module system. Just because we in Iris are not very careful about what we import, and rely on "C-style namespacing" to disambiguation, that does not mean we should force this on all Iris users.

    could we run the CI on all Iris reverse dependencies?

    I can do that. (I can also tell you how to do it so you don't have to wait for me each time, and I don#' have to forward the results each time.^^)

  • FWIW, given the way we "use" the module system, I do not think that passing CI would indicate that this is not a problem. So at best this can give us a negative signal (it breaks even our own code), but I do not think it can give us a positive signal.

  • Please register or sign in to reply
  • added 1 commit

    Compare with previous version

  • Edited by Ralf Jung
  • My guess what is going wrong with the The term "bool" has type "Set" while it is expected to have type "type". failure in lambda-rust (https://gitlab.mpi-sws.org/iris/lambda-rust/-/jobs/64059#L230): There is a lambda-rust type called bool in lambda rust and there is a Coq Set called bool in Datatypes. This is a violation of the usual c-style namespacing we do and this is why this MR break this code. Note that the failure is in int.v which first imports bool and then (ordering is important) imports programs. https://gitlab.mpi-sws.org/iris/lambda-rust/-/blob/master/theories/typing/int.v#L3 [rograms transitively exports stdpp.base which with this MR exports the Coq bool due to the export of Datatypes. Thus with this MR bool in int.v refers to the Coq bool, while without this MR it refers to the lambda rust bool. Note that my other MR !139 (closed) would probably also run into this problem as it would also make programs export Datatypes.

    This is all very messy and I don't know what the best solution is. I see the following options:

    • accept this MR (or !139 (closed)) and accept the breakage
    • I thought there was a version which works on all Coq versions and does not rely on exporting Datatypes but prints Datatypes.length on Coq versions before 8.11. (Was it making the notation in strings.v parsing only?) This would make the problem for users of 8.11 go away and change strings.length to Datatypes.length for users for older Coq versions.
    • do nothing (please not)
    Edited by Michael Sammler
  • accept this MR (or !139 (closed)) and accept the breakage

    s/accept/fix/

    I'm afraid that's the most pragmatic choice. I would be in favor of this.

    I thought there was a version which works on all Coq versions and does not rely on exporting Datatypes but prints Datatypes.length on Coq versions before 8.11. (Was it making the notation in strings.v parsing only?) This would make the problem for users of 8.11 go away and change strings.length to Datatypes.length for users for older Coq versions.

    That's removing the Notation length in base.v. I don't think that affects the lambdarust problem.

  • I'm still opposed to increasing the reexports of stdpp.base. That's a very heavy hammer you are swinging here.

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading