coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Jason Gross <jasongross9 AT gmail.com>
- To: coq-club <coq-club AT inria.fr>
- Subject: Re: [Coq-Club] How to write variadic tactics
- Date: Wed, 19 Aug 2020 00:05:56 -0400
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=jasongross9 AT gmail.com; spf=Pass smtp.mailfrom=jasongross9 AT gmail.com; spf=None smtp.helo=postmaster AT mail-ej1-f52.google.com
- Ironport-phdr: 9a23:RVAw4h8U7ujjhf9uRHKM819IXTAuvvDOBiVQ1KB30+wcTK2v8tzYMVDF4r011RmVBNudsqobwLaM+4nbGkU4qa6bt34DdJEeHzQksu4x2zIaPcieFEfgJ+TrZSFpVO5LVVti4m3peRMNQJW2aFLduGC94iAPERvjKwV1Ov71GonPhMiryuy+4ZLebxhJiTanfL9+MBe7oQreu8UInIBvNrs/xhzVr3VSZu9Y33loJVWdnxb94se/4ptu+DlOtvwi6sBNT7z0c7w3QrJEAjsmNXs15NDwuhnYUQSP/HocXX4InRdOHgPI8Qv1Xpb1siv9q+p9xCyXNtD4QLwoRTiv6bpgRRn1gykFKjE56nnahcN+jK1ZoByvqR9xzZPKbo6JL/dxZL/RcMkASGZdQspcVSpMCZ68YYsVCOoBOP5VoY3nqFsVqhu+AxSnCuL1yj9PnX/2xrAx3uMjEQ7cxwwgGNQOsHvOrNXyL6cSSuS4wbLHzTXGdfxW2DP95JLUfRAmpPGBRLR9etfexkczDQ3KlEmQqZD7MDOP0OQAq2qW4uh8WO+uhGMqqQB8rySzy8sxioTEgoYYx1Pa+Ct2wos7K8C1RU1/bNK6EJVdqSGUOotrTs4sXm1luTo2x7IAtJWmfyYK0IwqywDDZ/GDaYSF4RLuWPyPLTtlh39pYrKyiwi0/EO90OPzTNO030xPriddktnDqHQN1xvL58iCUPR9/0Oh1S+R2ADR9+1IOE40mKrFJ5I7zb4wkZ0TsUvHHiDogkn5kKiWdkA89uip7eTofKnmq4eCO4NojgzyKKcjl8ylDegmLwQDXHKX9OSi2LH7+E32WrRKjvk4kqnDt5DaINwWpqyjDA9O1YYj7Rm/Dy2h0NQDhnkKKElIeB2Cj4fzOlHOJOr0Auu4g1SpiDtr3ezJPqX9ApXRKXjOiKvufbFk60JF1AUzyc1f6IlPB7EaIPPzX1fxu8bCAh84NQy02efnB89n2oMQQ2LcSpOeZajVqBqD4v8la72HY5ZQszLgIdAk4eTvhDk3gwlOU7Ou2M41YWu/GLxJOUKCejK4gN4aFmEFpA0lV73Ch1iLUDoVbHG3CfFvrgonAZ6rWN+QDrumh6aMiX/iT89mI1teA1XJKk/GMoCNWvMCciWXe5YznTkNVLznQIgkh0j36F3KjoF/J++RwRU28Ir53YEsteLWnBA2szdzCpbFijzffyRPhmoNAgQO8uV/rEh6kArR1KF5h7lVF4UW6a4TFAg9MpHYwqpxDNWgAg8=
There are two ways to do this:
1. Write a "dependently typed" tactic that takes a `nat` encoding how many arguments it expects, e.g.,
Ltac myintros_then n k :=
lazymatch n with
| O => k ()
| S ?n
=> fun H
=> myintros_then n ltac:(fun _ => k (); intro H)
end.
Ltac myintros n := myintros_then n ltac:(fun _ => idtac).
Goal True -> True -> True -> True.
myintros 3 A B C.
lazymatch n with
| O => k ()
| S ?n
=> fun H
=> myintros_then n ltac:(fun _ => k (); intro H)
end.
Ltac myintros n := myintros_then n ltac:(fun _ => idtac).
Goal True -> True -> True -> True.
myintros 3 A B C.
2. Use Tactic Notation, like
Tactic Notation "myintros" ident_list(vars) := intros vars.
Goal True -> True -> True -> True.
myintros A B C.
Goal True -> True -> True -> True.
myintros A B C.
Note that, unfortunately, there's not really a way to manipulate lists of things in Ltac, which brings us to
3. Use Ltac2, like
Require Import Ltac2.Ltac2.
Ltac2 Notation "myintros" p(intropatterns) := intros0 false p.
Goal True -> True -> True -> True.
myintros A B C.
Ltac2 Notation "myintros" p(intropatterns) := intros0 false p.
Goal True -> True -> True -> True.
myintros A B C.
On Tue, Aug 18, 2020 at 10:35 PM Christopher Ernest Sally <christopherernestsally AT gmail.com> wrote:
Hello ClubI'm looking to write variadic tactics ala clear, intros, destruct but inside coq, rather than ML.I wanted to ask what was the best known methodology for this currently.ThanksChris
- [Coq-Club] How to write variadic tactics, Christopher Ernest Sally, 08/19/2020
- Re: [Coq-Club] How to write variadic tactics, Jason Gross, 08/19/2020
- Re: [Coq-Club] How to write variadic tactics, jonikelee AT gmail.com, 08/19/2020
- Re: [Coq-Club] How to write variadic tactics, jonikelee AT gmail.com, 08/19/2020
- Re: [Coq-Club] How to write variadic tactics, jonikelee AT gmail.com, 08/19/2020
- Re: [Coq-Club] How to write variadic tactics, Jason Gross, 08/19/2020
Archive powered by MHonArc 2.6.19+.