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

Deep matching like Ltac's context #12

Open
awalterschulze opened this issue Apr 28, 2023 · 0 comments
Open

Deep matching like Ltac's context #12

awalterschulze opened this issue Apr 28, 2023 · 0 comments

Comments

@awalterschulze
Copy link

quote4 is amazing at pattern matching in hypotheses and the goal.
Thank you so much for creating this library.
It is already a huge help.

I was wondering if would be possible to extend quote4's matching to do deeper matching, something like how context works in Coq's Ltac.

This way we can apply rewrite rules to anywhere in a hypothesis or goal that they are possible.
For example in Coq we can write:

match goal with
| [ H: context [[] ++ _] |- _ ] =>
  rewrite app_nil_l in H
  (* [] ++ xs = xs *)
end.

This way the following hypothesis will all be rewritten with one pattern match

H1: [] ++ xs = ys
H2: x :: ([] ++ xs) = y :: ys
H3: xs ++ ([] ++ ys) = zs
H4: xs ++ (x :: ([] ++ ys)) = z :: zs
H4: x :: xs ++ (x :: ([] ++ ys)) = z :: z :: zs

Maybe this feature already exists and I missed it?

If it doesn't exist maybe not to break backwards compatibility there could be a new syntax, maybe using square brackets, but that is totally up to you:

...
    match hypProp with
    | ~q[[] ++ $xs] =>
      -- rewrite [] ++ xs anywhere
      Lean.Elab.Tactic.evalTactic <- `(tactic| rw list_app_nil_l at $name )
...
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

No branches or pull requests

1 participant