coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Matthieu Sozeau <mattam AT mattam.org>
- To: Coq Club <coq-club AT inria.fr>
- Subject: Re: [Coq-Club] multiple typeclass instance question
- Date: Tue, 15 Mar 2016 20:25:57 +0000
- Authentication-results: mail2-smtp-roc.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-wm0-f49.google.com
- Ironport-phdr: 9a23:ThwSxxBE1Jnbd/ExjiWWUyQJP3N1i/DPJgcQr6AfoPdwSP78psbcNUDSrc9gkEXOFd2CrakU26yO6+u5ADdIyK3CmU5BWaQEbwUCh8QSkl5oK+++Imq/EsTXaTcnFt9JTl5v8iLzG0FUHMHjew+a+SXqvnYsExnyfTB4Ov7yUtaLyZ/nh6bqo9aKOl4ArQH+SI0xBS3+lR/WuMgSjNkqAYcK4TyNnEF1ff9Lz3hjP1OZkkW0zM6x+Jl+73YY4Kp5pIZoGJ/3dKUgTLFeEC9ucyVsvJWq5lH/Sl6k4WJUeWELmFIcCA/cqRr+Q53Zsy3gt+M71jPMbuPsSrVhfD2+86dqRQKgsyAVOjckuDXSg9BshadzpRu9uxV6hYnOb9fGZ7JFYqrBcIZCFiJ6VcFLWnkEW9vkYg==
Indeed, it seems this would require pretyping (refinement from untyped terms to typed terms) to be done similarly to what the old refine tactic did (or Idris does AFAIU). You'd have a tactic pretype that takes a untyped term and produces a typed one, with clauses like:
pretype (forall x : T, b) = mkProd x; [pretype T| pretype b]
pretype (fun x : t => b) = mkLam x; [pretype t|pretype b]
pretype (f a) = refine (_ _); [pretype f|pretype a]
pretype ($(tac)$) = tac
pretype (_) = try typeclasses eauto
pretype (match x with brs) = evar(T : Type); subst T; unshelve (evar (t : ?T));
[pretype x| mkCase t; pretype brs]
I think that would not be too hard to implement (the devil's in the details though).
I'm not so sure it is desirable to have the regular type inference be implemented like
that, but that would make a fun experiment.
-- Matthieu
On Tue, Mar 15, 2016 at 8:36 PM Arnaud Spiwack <aspiwack AT lix.polytechnique.fr> wrote:
Without understanding what the pretyper does, is the implication of not having any backtracking in the pretyper that Coq can't change the decision about the type of any term once it is typed?This is correct, but I’d say this should be seen as two things:
- There is no backtracking in the pretyper, so it doesn’t know how to produce a second type if a first one has been invalidated
- Even if there was, if it wasn’t implemented using the abstraction provided by the tactics a type couldn’t be invalidated due to a tactic failing
Does this restriction on backtracking in the pretyper also imply that experimental typed alternatives to LTac, such as MTac, would all be incapable of backtracking after a successful solution of a type? If so, would the potential solution of the issue for tactic-in-term also improve the situation for MTac-like alternatives?I’m not sure about that. It may be. There are certainly benefits to be derived for MTac and the like, but they may be able to get most of the way without solving point 2 above which is the thorny bit.
- Re: [Coq-Club] multiple typeclass instance question, (continued)
- Re: [Coq-Club] multiple typeclass instance question, Jason Gross, 03/10/2016
- Re: [Coq-Club] multiple typeclass instance question, Jonathan Leivent, 03/10/2016
- Re: [Coq-Club] multiple typeclass instance question, Jonathan Leivent, 03/10/2016
- Re: [Coq-Club] multiple typeclass instance question, Jason Gross, 03/10/2016
- Re: [Coq-Club] multiple typeclass instance question, Jonathan Leivent, 03/11/2016
- Re: [Coq-Club] multiple typeclass instance question, Pierre-Marie Pédrot, 03/12/2016
- Re: [Coq-Club] multiple typeclass instance question, Arnaud Spiwack, 03/13/2016
- Re: [Coq-Club] multiple typeclass instance question, Jonathan Leivent, 03/13/2016
- Re: [Coq-Club] multiple typeclass instance question, Arnaud Spiwack, 03/15/2016
- Re: [Coq-Club] multiple typeclass instance question, Matthieu Sozeau, 03/15/2016
- Re: [Coq-Club] multiple typeclass instance question, Jonathan Leivent, 03/15/2016
- Re: [Coq-Club] multiple typeclass instance question, Matthieu Sozeau, 03/15/2016
- Re: [Coq-Club] multiple typeclass instance question, Arnaud Spiwack, 03/16/2016
- Re: [Coq-Club] multiple typeclass instance question, Matthieu Sozeau, 03/16/2016
- Re: [Coq-Club] multiple typeclass instance question, Arnaud Spiwack, 03/13/2016
- Re: [Coq-Club] multiple typeclass instance question, Arnaud Spiwack, 03/16/2016
Archive powered by MHonArc 2.6.18.