(WIP) Expose type_context_old as a monad.#69
Merged
cipher1024 merged 13 commits intomasterfrom Nov 9, 2019
Merged
Conversation
The idea is to investigate exposing some of the constructs which Lean uses to make type_context_old to enable the user to create more powerful tactics. Some examples can be seen in the `tests/lean/tco.lean`: There is a reimplementation of `intro` and `match_pattern` using the new monad.
Member
Please just ignore the EDIT: or maybe don't abbreviate it at all, and call it |
Member
Author
|
Any ideas why this test would be failing on just one configuration of travis? |
Collaborator
|
I've seen this sort of thing before on the macOS builds, where the build produces |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
what?
Under the hood,
tacticuses a C++ class calledtype_context_old.This PR introducesmeta constant tco : Type -> Typewhich lets you use this directly. This lets you do more 'unsafe' operations like directly declaring and assigning metavariables, as well as use temporary metavariables.type_context_oldis mutable, but all of the mutation occurs through interacting with the monad.why?
On my tactic writing adventures, I found there were situations where it was very frustrating to always go via
tacticand not be able to manipulate the mvar context.tacticdeliberately limits how you interact with the metavariable context so you can't produce dodgy terms that are rejected by the kernel.This also means that some constants like
intro_coreandmatch_patterncan be implemented entirely in Lean (seetest/lean/tco.lean). Although of course this will incur a performance penalty.should it be merged at all?
There is a fair case that this doesn't belong in Lean, because it is exposing an internal class and just adds cruft. But I have written the code so I thought I should present it as a potential feature for Lean 3.5c.
what needs to happen before merging?
lcis a terrible name forlocal_context. As is the nametco, maybe call itmvar_context_monad?. I think it would make sense to put it all in a namespace likeunsafeso that it doesn't break anything and beginners know that they can ignore it.tacticwhere it makes sense. At the moment I have just been adding constants as I need them. It would be cool if in principle you could implementtacticfromtco.type_context_oldis a mutable class so need to double check that it doesn't cause tactic_state to mutate or some other pureness-breaking.