coq-club AT inria.fr
Subject: The Coq mailing list
List archive
Re: [Coq-Club] Question regarding the "Typeclasses Filtered Unification" option.
Chronological Thread
- From: Matthieu Sozeau <mattam AT mattam.org>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Question regarding the "Typeclasses Filtered Unification" option.
- Date: Tue, 18 Jul 2017 14:45:11 +0000
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=mattam AT mattam.org; spf=Pass smtp.mailfrom=matthieu.sozeau AT gmail.com; spf=None smtp.helo=postmaster AT mail-ua0-f169.google.com
- Ironport-phdr: 9a23:EP0PwhIC1GAc6eG2PNmcpTZWNBhigK39O0sv0rFitYgRKvXxwZ3uMQTl6Ol3ixeRBMOAuq0C07KempujcFRI2YyGvnEGfc4EfD4+ouJSoTYdBtWYA1bwNv/gYn9yNs1DUFh44yPzahANS47xaFLIv3K98yMZFAnhOgppPOT1HZPZg9iq2+yo9ZDeZwdFiCChbb9uMR67sRjfus4KjIV4N60/0AHJonxGe+RXwWNnO1eelAvi68mz4ZBu7T1et+ou+MBcX6r6eb84TaFDAzQ9L281/szrugLdQgaJ+3ART38ZkhtMAwjC8RH6QpL8uTb0u+ZhxCWXO9D9QLYpUjqg8qhrUgflhygJNzE78G/ZhM9+gr9Frh29vBFw2ZLYbZuPOfZiYq/Qf9UXTndBUMZLUCxBB5uxYYwVAOodIeZYr4j9qEUTrRCjGAesA+LuxSFSiX/rwKY31OEhHhva3Aw8Bd0OtW/ZrNDvO6cOTeC61qzIwS/Eb/NM1jfw8Y7FeQ0ir/GURb98b9bdxE01Gw7Gjlics5LpMy6X2+gXrmSW7u5tWOSygGA9sQ5xuCKgxsI0h4nJmI0VzlfE+D18wIkvJN24TFd3YcO+H5dMri2aOZZ6T8ImTm1ytyY6zboGuZG/fCcU0pgo2xnfa/mff4iJ5BLsSvqRLC9miH55fL+znRW//Ei6xuHiS8W50kxGojdEn9TIrnwN0gbc6smDSvtz5Eeh3jOP2hjW6u5ePUA0iarbK58/zb4tjJYTqkPDHy7ol0rska+bbUok+u2y5OTmZrXqvIOTN4hxig3mKKQhhtS/AfgkMggJR2WU5eO81KT68ULlRLVKk+Y5n7LCsJHaIMQbvrS2DxVU0oYl8Ra/Di2p3M4WnXkdfxp5f0eMiJGsMFXTKtj5C+2+ihKiimRF3ffDa5joHonNL3Xe2Izmb7t09gYIzQMv0dlaz5ddFq0IJbT0QECn54+QNQMwLwHhm7WvM956zI5LAW8=
Hi Kathrin,
sorry for the delayed response. The pattern matching filtering phase is a purely syntactic operation, it cannot unify subterms as you expect, so here it fails to match because 0 and ?n are not syntactically equal. To avoid this, you can use a less refined pattern like so (actually, without filtered unification on, it's as if you used that pattern instead, where just the head of the application matters):
Class Test (x y : nat) := testeqn : x = y.
Set Typeclasses Filtered Unification.
Instance: forall n, Test n n | (Test _ _). (** This sets the pattern used by the filtering phase *)
Proof. reflexivity. Qed.
Set Typeclasses Debug Verbosity 2.
Goal True.
eassert (Test 0 ?[n]). try typeclasses eauto.
(* Here we get:
Debug: Starting resolution with 1 goal(s) under focus and 0 shelved goal(s) in only_classes mode, unbounded
Debug: 1: looking for (Test 0 ?n) with backtracking
Debug: 1.1: simple apply Test_instance_0 with pattern (Test _ _) on (Test 0 ?n), 0 subgoal(s)
Debug: 1.1: after simple apply Test_instance_0 with pattern (Test _ _) finished, 0 goals are shelved and unsolved ( )
exact I.
Qed.
Cheers,
-- Matthieu
On Wed, Jun 28, 2017 at 11:43 AM Kathrin Stark <kathrin.stark AT rz-online.de> wrote:
Hello,
I have a question concerning the "Typeclasses Filtered Unification"
option.
Using the typeclasses eauto tactic, I would like to unify a pattern of
the form
Test 0 ?n with another pattern of the form Test ?m ?m
- however, Coq complains that the patterns do not match:
pattern (Test ?META158 ?META158) on (Test 0 ?n) failed with: pattern
does not match
I don't understand why - I would have guessed it could unify ?META158
with ?n with 0.
(Without the above option activated, it works out of course.)
So I wondered how exactly the pattern matching algorithm works? -
Unfortunately I didn't find an answer to that.
The minimal code example can be found below.
Thank you very much!
Best,
Kathrin S.
------------------------------------------------------
Class Test (x y : nat) := testeqn : x = y.
Unset Typeclasses Filtered Unification.
Instance: forall n, Test n n.
Proof. reflexivity. Qed.
Set Typeclasses Filtered Unification.
Set Typeclasses Debug Verbosity 2.
Goal True.
evar (n : nat).
assert (Test 0 ?n). try typeclasses eauto.
(* Here we get:
simple apply Test_instance_0 with pattern (Test ?META158 ?META158) on
(Test 0 ?n) failed with: pattern does not match *)
Abort.
- Re: [Coq-Club] Question regarding the "Typeclasses Filtered Unification" option., Matthieu Sozeau, 07/18/2017
Archive powered by MHonArc 2.6.18.