Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Finding a pattern-matching fix in a term?

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Finding a pattern-matching fix in a term?


Chronological Thread 
  • From: Gregory Malecha <gregory AT bedrocksystems.com>
  • To: coq-club AT inria.fr
  • Cc: Eddy Westbrook <westbrook AT galois.com>
  • Subject: Re: [Coq-Club] Finding a pattern-matching fix in a term?
  • Date: Mon, 1 Jun 2020 15:43:22 -0400
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=gregory AT bedrocksystems.com; spf=None smtp.mailfrom=gregory AT bedrocksystems.com; spf=None smtp.helo=postmaster AT mail-pf1-f170.google.com
  • Ironport-phdr: 9a23:caKqlBE4HvIcEltgFIWHMJ1GYnF86YWxBRYc798ds5kLTJ7zr86wAkXT6L1XgUPTWs2DsrQY0reQ6vu9EjVbuN6oizMrSNR0TRgLiMEbzUQLIfWuLgnFFsPsdDEwB89YVVVorDmROElRH9viNRWJ+iXhpTEdFQ/iOgVrO+/7BpDdj9it1+C15pbffxhEiCCybL9vLBi6txjdu8cWjIdtN6o8xAbFqWZUdupLwm9lOUidlAvm6Meq+55j/SVQu/Y/+MNFTK73Yac2Q6FGATo/K2w669HluhfFTQuU+3sTSX4WnQZSAwjE9x71QJH8uTbnu+Vn2SmaOcr2Ta0oWTmn8qxmRgPkhDsBOjUk62zclNB+g7xHrxKgvxx/wpDbYIeJNPplY6jRecoWSXddUspNUiBMBJ63YYkSAOobJetXoIf9qFkOoxWwBgeiGf3hxSNTi3DswaE3yf4sHR3a0AEiGd8FrXTarM/yNKcXSe27zbPIwivMb/NRwzf86JXDfBc7rvGIQ71/bcrRxlMyHA7CgVWQs5LqPzyS1uQXs2mW9PFvWvyyhG49rAF+vjuvxtwsi4nSmoIa1FXE9T5jzIkpIt24TVd2bNi5G5Rfqy+ULZF5Qt8+Q252oiY6zKULtJC1ciYE1pkr2wLSZuCEfoWV/x7tW+acLDN2iX9nd7+zmxm8/EyvxODgSMW63lhEoCpZntTQsn0A2ADf59SbR/Z740yv2i6P2hjN5u1YJU04j6nWJp47zrIui5YfrV7PEjL0lUnqiqKda18q9fKy6+v9Z7Xrvp+cOJFwigH5Kqkun9awAeU8MgQXR2ib9/mw2KTt/UHkQrhGkuc6kqbesJDdKsQborC2DxVJ3YYk7hazFzam0NIGknkbNF9JZg6LgozzN1zNIP30F+mzj0mwnDtx2vzLPKHtDo3ILnfZkbfhebh961RbyAo21d1f6IhUBa8OIPL0QE/wtMfVAQQnPAOp2ebnD8ly1oAFWWOPGa+ZLL3dsVqT5u41P+aMY4oVtC7nK/c5//7ukWM5mVgFcKa12psXcWm0EehiI0WEenXhmcwBEGcPvgomVuPmklyCUThJZ3azRa0w/D87CJj1RbvEE4uqmfmK2DqxNpxQfGFPTF6WQlnycIDRdO0BZyWIM4dEmzgJXrioA9suzxyhsxXr47BqIvDT8S4DpIn/2d1uoebUkEdhpnRPE82B3jTVHClPlWQSSmpzhfgn+B0v+hK4yaF9xsdgO5lW7vJNXB09MMSEneZ3B8r1UQHab8yVRVO9BN6hBGNpF49j85o1e094Xu6aoFXD0i6tWeFHkrWKANks/PuZ0SGuf4ByzHHJ0KRnhF4jEJMWaT+Ww5Vn/g2WPLbn1l2DnvzyJ64R0DTK/2SY3HGSsURDFgV3VPedUA==

It is late, but you can do this in template-coq simply by quoting the term and writing a function to check what you want. It wouldn't be truly gorgeous, but it doesn't require anything that is unsafe. Note that what template-coq gives you is a Gallina inductive type that reifies a Gallina term, so inspecting a term is *literally* just Coq pattern matching. That said, this is definitely not unification, so if you want "definitionally equal to" rather than "syntactically equal to you are currently out of luck with template-coq.

On Mon, May 18, 2020 at 5:40 AM Pierre-Marie Pédrot <pierre-marie.pedrot AT inria.fr> wrote:
Hi,

On 16/05/2020 03:17, Eddy Westbrook wrote:
> Is there any way to pattern-match on a fix + match term like (fix foo
> (x1:A1) … := match xi with … ) in a term? I am trying to write some
> tactics to determine if a particular argument is being destructed in
> a term, in order to apply the destruct or induction tactic on it, but
> it seems that Ltac at least won’t let me search for fix terms…?

if you're using Coq >= 8.11, it is possible to do this in Ltac2, albeit
in a way deemed "unsafe". Once done, you can also wrap the resulting
Ltac2 tactic into a proper Ltac1 tactic, so that it is transparent for
the end-user. Look at the Ltac2.Constr.Unsafe module for more details.

PMP



--

Gregory Malecha

Mail: gregory AT bedrocksystems.com

BedRock

Systems Inc
UNBREAKABLE FOUNDATION FOR

FORMALLY SECURED COMPUTING



Archive powered by MHonArc 2.6.19+.

Top of Page