coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Jan Bessai <jan.bessai AT tu-dortmund.de>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] "Cannot satisfy constraint" error using subset types
- Date: Sun, 30 Apr 2017 02:43:44 +0200
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=Neutral smtp.pra=jan.bessai AT tu-dortmund.de; spf=Pass smtp.mailfrom=jan.bessai AT tu-dortmund.de; spf=None smtp.helo=postmaster AT unimail.uni-dortmund.de
- Ironport-phdr: 9a23:E7JLTxH7L05bIt1gaeYV4p1GYnF86YWxBRYc798ds5kLTJ7zp8WwAkXT6L1XgUPTWs2DsrQf2raQ6/iocFdDyK7JiGoFfp1IWk1NouQttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBXdrXKo8DEdBAj0OxZrKeTpAI7SiNm82/yv95HJbQhFgDWwbaluIBmqsA7cqtQYjYx+J6gr1xDHuGFIe+NYxWNpIVKcgRPx7dqu8ZBg7ipdpesv+9ZPXqvmcas4S6dYDCk9PGAu+MLrrxjDQhCR6XYaT24bjwBHAwnB7BH9Q5fxri73vfdz1SWGIcH7S60/VjO+4qplShLlhj4LOyI2/WrKjsB9jL5XrBenqhdiwYDbfZuVOeJjcK3Dc9MURWlPUMhfWCNOAIyzc4QBAvEdPetatYTxu0cCoBW8CASqGejhyiVIhnjz3aAi1+ouCwfG1xE9Et0Qq3TUt8/6NKYPWu2yzqnH1zPDY+lN1jjj84jIaQouofCXULJsbMrd0FQgFwTfjlWMrIzlIjWV2fkXv2eG8eVtTOSigHMppQF2pzig3MYsio/Ri4IUzFDE7yR5z5wvKd22Uk52Z8OvHphItyyCKod6XMcvT3t2tConyLAKo4O3cDYJxZg9xxPTduSLfouI7x75SuqdPy10iG95dL6hnRq+7Emtx+P6W8KpylhFtDBFncPJtn0V1xzc9MyHSvxl80e83zaP1gXT5ftFIUAwj6bbNpghwr8pmpUOtkTDBDP2mEDrjK+Qa0oo4PWn5Pr/brXnoJ+TKZN0hxnjPqgwnsGzG/o0PhUMUmSB5Oiwyr7u8Vf5TblXlvE2l7PWsJHeJcQVvK65BApV354h6xmlCTeqys8XkmccLFJeYh2HjpPkO03TIPzhEPi/hE6skCtux/DbOL3uH4/BIWXdn7v5Z7Zy91ZcyBYvzdBY/59bFrYBIOvqVkDtsNzYEwQ2Phevw+fnDdV9zpkRVXiOAq+fKqPSsEWH6vghI+mWN8cpv2P2LOFg7Przh1c4n0UcdO+nx8g5cne9S9ZvJQ2zbGH3i9ZJRWUDuEw0QffxgVyqTSMWa3GoQ6ch4D19BI/wXtSLfZyknLHUhHTzJZZRfG0TVwiB
Hi,
then "rew eq_prf in x" from https://coq.inria.fr/distrib/current/stdlib/Coq.Init.Logic.html can potentially help.
An example would be:
Require Import Coq.Vectors.Vector.
Inductive Tree (L: Set): Prop :=
| Node : forall (label: L) (arity: nat), (t L arity) -> Tree L.
Import EqNotations.
Inductive TreeRel (L: Set) (R: L -> L -> Prop): Tree L -> Tree L -> Prop :=
| InRel : forall l1 l2 arity1 arity2 (xs: t L arity1) (ys: t L arity2)
(arity_eq: arity2 = arity1),
R l1 l2 ->
Forall2 R xs (rew [t L] arity_eq in ys) ->
TreeRel L R (Node L l1 arity1 xs) (Node L l2 arity2 ys).
where the "rew [t L] arity_eq in ys" can also be written as "rew arity_eq in ys" whenever Coq is smart enough to detect the dependency of the rewritten expression on the subject of the equation.
There is also "rew <- arity_eq in" to get a right to left version of the equation.
In any case the equation can of course can be proven anywhere, especially in a lemma.
Also note, that datatypes formulated like this often get "stuck" in later proofs, where you have situations like
Foo xs (rew P in xs)
which you want to be
Foo xs xs
Should that be the case, Eqdep_dec (https://coq.inria.fr/distrib/current/stdlib/Coq.Logic.Eqdep_dec.html) is very useful to replace P by eq_refl, which then causes rew eq_refl in xs to reduce to xs.
Bests,
Jan
On 04/29/2017 01:50 PM, Klaus Ostermann wrote:
Hi Jan,
thanks for your answer! I'm not sure how to apply your suggestion, though.
This error does not happen in a proof but in the definition of an
inductive datatype.
I tried to formulate your assertion (adapted to my situation) as a lemma
and add it to the rewrite hint database,
but that doesn't change the error.
Any ideas? Maybe I need some kind of cast?
Klaus
Am 29/04/17 um 11:59 schrieb Jan Bessai:
Hi,
The term "fds" has type "id -> id -> {n : nat & eqn n}"
while it is expected to have type "id -> id -> {n : nat & eqn n}"
(cannot
satisfy constraint
"eqn (length tys1)" == "(fun n : nat => eqn n) (projT1 (fds f c))").
The types that it wants to be identical are identical, and they are also
identical if all implicit arguments, universe levels etc. are printed.
I came across issues like that when porting a proof from Coq 8.5 to
8.6. My guess is reduction during unification got less intelligent but
more predictable. I usually get around these cases doing something like
assert (x_eq: x = f y). {
unfold f; destruct y; simpl; reflexivity.
}
rewrite x_eq.
potentially using "rewrite in" or simpler proofs for x_eq.
This is a bit explicit and brittle, but I tend to prefer it over
overly intelligent magic.
Hope this helps.
Bests,
Jan
- [Coq-Club] "Cannot satisfy constraint" error using subset types, Klaus Ostermann, 04/29/2017
- Re: [Coq-Club] "Cannot satisfy constraint" error using subset types, Jan Bessai, 04/29/2017
- Re: [Coq-Club] "Cannot satisfy constraint" error using subset types, Klaus Ostermann, 04/29/2017
- Re: [Coq-Club] "Cannot satisfy constraint" error using subset types, Jan Bessai, 04/30/2017
- Re: [Coq-Club] "Cannot satisfy constraint" error using subset types, Klaus Ostermann, 04/29/2017
- Re: [Coq-Club] "Cannot satisfy constraint" error using subset types, Jan Bessai, 04/29/2017
Archive powered by MHonArc 2.6.18.