Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewriting is slow #161

Open
Lysxia opened this issue Feb 3, 2020 · 0 comments
Open

Rewriting is slow #161

Lysxia opened this issue Feb 3, 2020 · 0 comments
Labels
coq-dev Questions related to best practices for Coq programming enhancement New feature or request

Comments

@Lysxia
Copy link
Collaborator

Lysxia commented Feb 3, 2020

Instance search keeps reproving the same goals, which take time because of the way we currently compose structures, so we have to repeatedly reconstruct them.

Solution: specialize structures more, e.g., don't declare ktree notation for Kleisli itree, but make it a definition of its own. Derive the various instances with some copy-paste boilerplate.

A more long-term solution would be to implement caching in type class search. Our constraints are Haskell-like, so they're not too wild (we shouldn't have to worry about existential variables). Universe polymorphism might become a problem though. In any case, it's a lot of work.


The proof of Imp2AsmCorrectness.seq_asm_correct provides a small (enough for debugging) but still noticeably slow rewrite (0.2s) (there are probably many others earlier...).

In particular, looking at rewrite app_asm_correct line 455.

rewrite loop_asm_correct, relabel_asm_correct, app_asm_correct.

The goal looks like this:

loop (subpure swap >>> denote_asm (app_asm ab bc) >>> subpure (id_ (B + C)))
  ⩯ denote_asm ab >>> denote_asm bc

And we're rewriting using

app_asm_correct : denote_asm (app_asm ab cd) ⩯ bimap (denote_asm ab) (denote_asm cd)

That spawns the ridiculous tree search summarized below, but basically, the same goals keep on reappearing.


  1. Proper-ness of the context subpure swap >>> _, which is solved by properness of cat (>>>)...

    1. This also requires reflexivity of equivalence of arrows eq2 (to ensure here that subpure swap is "proper")

      1. eq2 is an Equivalence (...)
    2. Properness of cat solved by category_proper_cat, requiring

      1. sub (ktree E) is a Category, requiring

        1. ktree E is a Category, requiring

          1. itree E is a lawful monad (MonadLaws, EqMProps)
  2. Proper-ness of the context _ >>> subpure (id_ (B + C))), which basically spawns the same search (...)

  3. Proper-ness of loop, requiring

    1. eq2 is an Equivalence (...)

    2. sub (ktree E) is a Category (...)

    3. sub (ktree E) is an Iterative category, which in turn requires

      1. eq2 is an Equivalence (fourth time!) (...)

      2. ktree E is a Category (fourth time!) (...)

      3. ktree E has a Coproduct, requiring again that itree E is a monad, for at least the fifth time (others hidden in Category constraints)

(Related to #83)

@Lysxia Lysxia added enhancement New feature or request coq-dev Questions related to best practices for Coq programming labels Feb 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
coq-dev Questions related to best practices for Coq programming enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant