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: Beta Ziliani <beta AT mpi-sws.org>
  • To: Coq Club <coq-club AT inria.fr>, Eddy Westbrook <westbrook AT galois.com>
  • Subject: Re: [Coq-Club] Finding a pattern-matching fix in a term?
  • Date: Sun, 17 May 2020 12:33:40 -0300
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=beta AT mpi-sws.org; spf=Pass smtp.mailfrom=beta AT mpi-sws.org; spf=None smtp.helo=postmaster AT jupiter.mpi-klsb.mpg.de
  • Ironport-phdr: 9a23:ZaBQsxey91+DZPW6U4pCc/xwlGMj4u6mDksu8pMizoh2WeGdxcSzZB7h7PlgxGXEQZ/co6odzbaP7ua5ATdLscjJmUtBWaQEbwUCh8QSkl5oK+++Imq/EsTXaTcnFt9JTl5v8iLzG0FUHMHjew+a+SXqvnYdFRrlKAV6OPn+FJLMgMSrzeCy/IDYbxlViDanbr5+MRW7oR/MusUKj4ZuJaU8xxrUqXZUZupawn9lK0iOlBjm/Mew+5Bj8yVUu/0/8sNLTLv3caclQ7FGFToqK2866tHluhnFVguP+2ATUn4KnRpSAgjK9w/1U5HsuSbnrOV92S2aPcrrTbAoXDmp8qlmRAP0hCoBKjU063/chNBug61HoRKhvx1/zJDSYIGJL/p1Y6fRccoHSWZdQspdUipMCZ6+YYQSFeoMJelXr4f/qFUOoxWwBhSiCv3zxTJTnHD6wbc33v49HQ3a3gEtGc8FvnTOrNXyMacfSf24w7fUzTrZcvhZ2jb96IzJch87p/GMXK97fM3KxkYxCwPKlE6dqYn9PzOUz+gNqGaa7/F6WeKokW4npBh8rz6yzcgjlofHnJgaykzY9Spn2oY1I8W1RUF/bNK6EZZdtz+WOoh3T84mTW9kpSg3x6EYtJOnYiUHyYorywLBZvGbb4WF5h3uWPuMLTp8mn5pZLKyiRau/EWm1+byVdG03U5XoidLltTArG0B2hjJ5sWES/Zx5Fqt1DaX2wzN9u1JJVo4mKnbJpI737I9l5gevV7eEiL1hkn7irKdeF8+9eiy8evnZ63rpp+COI9wjQHzKqYumtGnAeQ5LggBQXKb9f651L37/E31WbZKjvktkqbCqpzaINwbpqGjDwBIzIkv8xe/DzG439QEhXQLMVxIdRadg4T0P1zCOvP1APalj1ixkDpn3/XGMafgApXJIHjDirDhfbNl5kFH1gUz0cpQ6olRCrEZIfL/Q1TxtdLDDhMjNAy02ennBM1n1owCQWKPHrOZMKTKvFCU4eIvOvCAa5MRuDbgMPco/OXujH88mV8FZ6alx5oXaHaiHvRnOUqVe3Tsgs1SWVsN6yE5VaTBjECIGWpYYG/3VKYh7Bk6DpinBMHNXNbpyJGN0DbzIZBNempcDVePWSP3ep6YUe0LbyG6LcZllT0fE7OmTtly+wupsVrQxqZuZtjV/iwRs5OrgNJ4++T7kAkzsCdrFIKayW7bHDI8pX8BWzJjhPM3mkd60FrWlPEg26UER+wW3OtAV0IBDbCZ1/ZzUougXxrAO8yWUxChWNr0WWhsHOJ0+McHZgNGI/vnjh3H2HD3Ub0Ij72XCYZy97rdmnv1PMw7zm7JkqUs3QF/E5l/cFa+j6s6zDD9QovAkkGXjaGvLP9O2TbMsXyc1iyJpk4KCQM=

If you don’t mind including a plugin, I’m certain that this can be done in Mtac2, although it isn’t trivial. I’ve started playing with it but I stumble upon the issue that a fixpoint only reduces when the argument is a constructor. If you want to have the solution, I can help you work it out.

To give you an idea of a piece of code relevant to the problem, the following helper function applies a given function f with a list containing enough parameters to make the function fully applied:

Definition get_parameters {C} (f: mlist dyn -> M C) : dyn -> M C :=
  (mfix2 app (l: mlist dyn) (d: dyn) : M C :=
    mmatch d return M C with
    | [? A P fu] @Dyn (forall x:A, P x) fu =>
      \nu x:A, app (Dyn x :m: l) (Dyn (fu x))
    | _ => f l
    end) [m:].

Best,
Beta


On Sun, May 17, 2020 at 5:05 AM Hugo Herbelin <Hugo.Herbelin AT inria.fr> wrote:
Hi,

As far as Ltac is concerned, its "match" is pretty constrained when it
is about matching a "fix" or "match" term (for instance the {struct id}
of a "fix" has to be the same in the pattern and in the matched term,
and, for "match" of terms, it has to be on the same inductive type).

There is otherwise a tactic "is_fix t" which tests if t is a fix and
fails it is not. There is also an ad hoc "destauto"/"destauto in H"
which destructs the "x" of all "match x with ... end" present in the
conclusion or in an hypothesis. Don't know what others would recommend
and what would more generally be the nicest approach to imagine to
deal with this kind of configuration.

Best,

Hugo

On Fri, May 15, 2020 at 06:17:13PM -0700, Eddy Westbrook wrote:
> Hey Coq Club,
>
> 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…?
>
> Thanks in advance,
> -Eddy



Archive powered by MHonArc 2.6.19+.

Top of Page