coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Théo Zimmermann <theo.zimmi AT gmail.com>
- To: Coq Club <coq-club AT inria.fr>
- Subject: Re: [Coq-Club] "exists" Extraction
- Date: Thu, 11 Apr 2019 08:09:38 +0200
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=theo.zimmi AT gmail.com; spf=Pass smtp.mailfrom=theo.zimmi AT gmail.com; spf=None smtp.helo=postmaster AT mail-vs1-f67.google.com
- Ironport-phdr: 9a23:quMaYBajq+F5ObprYmYzN8D/LSx+4OfEezUN459isYplN5qZr8u7bnLW6fgltlLVR4KTs6sC17OP9fmwEj1eqdbZ6TZeKcQKD0dEwewt3CUYSPafDkP6KPO4JwcbJ+9lEGFfwnegLEJOE9z/bVCB6le77DoVBwmtfVEtfre9FYHdldm42P6v8JPPfQpImCC9YbRvJxmqsAndrMYbjZZ/Jqor1xfEoXREduBXyGh1IV6fgwvw6t2/8ZJ+7yhcoe4t+9JFXa7nY6k2ULtUASg8PWso/sPrrx7DTQWO5nsYTGoblwdDDhbG4h/nQJr/qzP2ueVh1iaUO832Vq00Vi+576h3Uh/oiTwIOCA//WrKl8F/lqNboBampxxi347ZZZyeOfRicq/Be94RWHFMVdhNWSNfHoy8bpMPD+sfMuZes4n9vEYFoR+nCQWxGO/j1jpEi3nr1qM4zushCxnL0wMuH90MsHraotb7OroMX++pw6fF1inDb+pM1Dvh9ITEbhIsrPeRVrxwa8rRzkwvGhvbgFWQs4vlOCua2ecMs2ie6upvS/ivi2s9pAF3pDik28AhipXJho0LzVDI7yR4wIcwJd29SU52etGkEJ5KuCGbM4t6WN8tQ2ZtuCsjzLANpJC1fC8PyJs9xh7fbeSKc4mO4hL5VeaeOy10hHx/eL6nnBay7VKvxfH/VsmzzlZFsDBFktfItnAK2R3f8NSISvx4/kqnxD2B1BjT5/laLUwokafXMZ0sz74qmpYNrEjOHDX6lUT0gaKQa04q4PKn6/79bbXjvpKcN5F7igX5Mqk2n8ywG+U4MgwXU2iF4uSwyaTv/UP4TbhIlPE2na7ZsJfVJcQfuKG1GRNa0oEm6xqnDjem1soXnWUfIV5bZB6Ki5LlNlLOLfziE/uznlahnC1qyv3EJrHhB4/CLnnHkLfvZ7Z97EtcxRIvzdBf+Z1UDasNIfPyWk/0sdzYDwQ0MwOxw+n9CdV90pkSVn6IAq+cKK/Sq0OH5vozI+mQY48YoCryK/885/L3kXA5nUIdcrKy0JsMaHG4G+xmLF+DbXrthNcBC2YKsRAkQOzkkl3RGQJUMl21RuoX4iwxQNatCp6GTYSwipSA2j26F9tYfDYVJEqLFCLUdwSDbMUNbSefOMpolDpMAaShRohnxxCrsQ7SxL9uL+6S8Sod48GwnONp7vHewElhvQd/CN6QhiTUFzktzzE4AgQu1aU6mnRTj1KK0Kx2mftdTIUB6PZAUwN8PpnZnbUjVoLCHznZd9LMc26IB9WrBTZrE4A0yt4KJlhmQpCs0E+F0C2tDLsY0beMAc5sq/6O7z3KP894jk3++uw5lVB/G5lAMGSnguh08A2BX4M=
Hi,
Having an undecidable predicate certainly rules out expressing it in
bool, but it does not rule out expressing it in Type. There are two
differences between Prop and Type: impredicative Prop vs predicate
Type hierarchy and the erasable status of Prop vs the extractable
status of Type (and BTW the fact that Coq used to have an extractable
impredicative sort Set shows that the two questions are separate:
https://coq.inria.fr/refman/language/cic.html#the-calculus-of-inductive-constructions-with-impredicative-set).
The decidability of a proposition hasn't anything to do with this. If
you define a predicate in Type, it is not more decidable than if you
define it in Prop. The difference is that if you are able to prove
that an element is in your predicate in Type, then you can extract a
computation from this proof (not the same thing, as this is not
generic but for a single element).
Thëo
Le jeu. 11 avr. 2019 à 07:33, Morgan Sinclaire
<morgansinclaire AT boisestate.edu>
a écrit :
>
> Thank you for the responses, but I want to emphasize again that my
> predicate "valid" is not decidable, otherwise I could've just made it
> boolean in the first place. I think that rules out Sigma types, but I'd
> like to be wrong about that. I am glad I know about
> ConstructiveGroundEpsilon now, and that certainly looks close to what I
> need, but if the "P : A -> Prop" is supposed to be be my "valid" predicate,
> then that also won't work because it's not undecidable.
>
> Here is my current code for full details, the relevant stuff starts on line
> 3643. Let me try to explain my situation a little bit more fully (but
> without going into all the weeds):
>
> I have a data structure called ftree ("formula tree") which consists of
> infinitely branching trees decorated with formulas. The definition has 19
> constructors corresponding to the rules of inference in this system, and
> looks like:
>
>> Inductive ftree : Type :=
>> | node : formula -> ftree (* axiom *)
>> ...
>> | w_rule_a : formula -> nat -> (nat -> ftree) -> ftree
>> ...
>
>
> It is infinitely branching because of w_rule_a. What I'm trying to do is
> represent proofs in a certain infinitary logic, so the infinite branching
> is there intentionally. I can decidably extract the formula at the root of
> an ftree (the conclusion of a proof):
>
>> Fixpoint ftree_formula (P : ftree) : formula :=
>> match P with
>> | node A => A
>> ...
>> | w_rule_a A n g => univ n A
>> ...
>
>
> Where "univ n A" denotes the formula "forall x_n, A". I say that an a given
> ftree P is valid iff it actually represents a proof in this infinitary
> system:
>
>> Fixpoint valid (P : ftree) : Prop :=
>> match P with
>> | node A => PA_omega_axiom A = true
>> ...
>> | w_rule_a A n g => forall (m : nat),
>> ftree_formula (g m) = substitution A n (represent m) /\ valid (g m)
>> ...
>
>
> Where "substitution A n (represent m)" denotes the formula "A[m/x_n]", so
> the w_rule_a means that if we have a function g: nat -> ftree such that for
> every m, (g m) is a proof of A(m), then we can infer forall x_n A(x_n).
>
> So in this infinitary system, it is not decidable to determine if a given
> ftree is valid, since that would require reasoning about the halting of any
> given g.
>
> Finally, I define the predicate on formulas:
>
>> Definition provable (A : formula) : Prop :=
>>
>> exists (t : ftree), ftree_formula t = A /\ valid t.
>
>
> Now I'm trying to prove a technical lemma that involves inducting over
> ftree, and the place I'm stuck is:
>
>> A : formula
>> n : nat
>> H : forall m : nat,
>> exists t : ftree, ftree_formula t = substitution A n (represent m) /\
>> valid t
>> ______________________________________(1/1)
>> exists t : ftree, ftree_formula t = univ n A /\ valid t
>
>
> So to prove the goal, I need to use "w_rule_a", which means I need a
> function g: nat -> ftree satisfying the required properties. By
> Curry-Howard, that function should be H itself, but this doesn't seem to
> work because I (apparently) can't extract the needed computational content
> from H.
>
> So is it completely hopeless since valid is undecidable in general? I feel
> like what I'm trying to do makes sense if one takes Curry-Howard literally,
> and if so there should be some workaround.
>
>
>
> P.S. One other thing I tried was defining "provable" instead as a sig:
>
>> Definition provable (A : formula) : Type :=
>> {t : ftree | ftree_formula t = A /\ valid t}.
>
>
> But then the induction setup I'm using to prove this lemma totally breaks,
> with the error:
>
>> Cannot find the elimination combinator PA_omega_theorem_rec, the
>> elimination of the inductive definition PA_omega_theorem on sort Set is
>> probably not allowed.
>
>
> I don't think I can avoid that, but if this is the recommended route, I'll
> probably have to give more details about this lemma.
>
> On Wed, Apr 10, 2019 at 7:01 PM mukesh tiwari
> <mukeshtiwari.iiitm AT gmail.com>
> wrote:
>>
>> Hi Morgan,
>> I am not Coq expert, so take my answer with grain of salt. For your first
>> question, you can have a look at constructiveEpsilon[1] library, specially
>> ConstructiveGroundEpsilon.
>>
>> Variable A : Type.
>> Variable f : A -> nat.
>> Variable g : nat -> A.
>>
>> Hypothesis gof_eq_id : forall x : A, g (f x) = x.
>> Variable P : A -> Prop.
>> Hypothesis P_decidable : forall x : A, {P x} + {~ P x}.
>>
>> Definition P' (x : nat) : Prop := P (g x).
>>
>> Lemma P'_decidable : forall n : nat, {P' n} + {~ P' n}.
>> Lemma constructive_indefinite_ground_description : (exists x : A, P x) ->
>> {x : A | P x}.
>>
>> If you can show one to one correspondence with nat and your type ftree
>> with proof of gof_eq_id and P_decidable, then using
>> constructive_indefinite_ground_description you can turn (exists x : A, P
>> x) to {x : A | P x} (computational content) which is probably you are
>> looking for.
>>
>> I don't have any precise answer for your second question, but have a look
>> at Arthur's answer about Prop and bool [2]. If you can turn your
>> connectives in Fixpoint valid (P : ftree) : Prop := ... in such a way that
>> it returns bool then you would have function which computes. Also, feel
>> free to share your code.
>>
>> Best,
>> Mukesh
>>
>> On Thu, Apr 11, 2019 at 7:31 AM Morgan Sinclaire
>> <morgansinclaire AT boisestate.edu>
>> wrote:
>>>
>>> I'm having trouble with extracting information from Prop, and
>>> specifically with the Prop/Type and ex/sig distinction which I wasn't
>>> aware of before. What I have is this definition:
>>>
>>>> Fixpoint valid (P : ftree) : Prop := ...
>>>
>>>
>>> Where "ftree" is a certain infinitely-branching tree structure I've
>>> defined, and for this reason "valid" is undecidable in general.
>>>
>>>
>>> Now I'm in the middle of a proof, where I have a hypothesis that looks
>>> like:
>>>
>>>> H : forall m : nat, exists t : ftree, valid t /\ [stuff about t]
>>>
>>>
>>> And to complete my proof I need to produce a function of the form:
>>>
>>>> nat -> ftree
>>>
>>>
>>> And by Curry-Howard, H should be such a function, but Coq doesn't believe
>>> so, because I can't extract computational information from "exists" (as
>>> discussed here, section 12.2).
>>>
>>> Now, I know Coq does this because it wants to limit the amount of program
>>> extraction one can do, but in my case I want full Curry-Howard. So my
>>> first question is:
>>>
>>> 1) Can I "toggle" this feature in Coq so I can get full program
>>> extraction from "exists"?
>>>
>>>
>>> If not, I don't know much about Sigma types, but I don't think I can just
>>> convert this "ex" into "sig" since the predicate "valid" is undecidable?
>>> I haven't worked with Type at all, so my other question:
>>>
>>> 2) Is there an easy way to convert a Prop to a Type?
>>>
>>> If so, I can change my definition of "valid" to be of type Type.
>>> Currently that definition is 63 lines and involves some Prop syntax such
>>> as "forall" and "/\", so any reference on how to do that in Type would be
>>> helpful so I can understand what I'm doing.
>>>
>>>
>>> Thanks!
>>
>>
>>
>> [1] https://coq.inria.fr/library/Coq.Logic.ConstructiveEpsilon.html
>> [2]
>> https://stackoverflow.com/questions/31554453/why-are-logical-connectives-and-booleans-separate-in-coq/31568076#31568076
- [Coq-Club] "exists" Extraction, Morgan Sinclaire, 04/10/2019
- Re: [Coq-Club] "exists" Extraction, Helmut Brandl, 04/10/2019
- Re: [Coq-Club] "exists" Extraction, Jason -Zhong Sheng- Hu, 04/11/2019
- Re: [Coq-Club] "exists" Extraction, mukesh tiwari, 04/11/2019
- Re: [Coq-Club] "exists" Extraction, Morgan Sinclaire, 04/11/2019
- Re: [Coq-Club] "exists" Extraction, Théo Zimmermann, 04/11/2019
- Re: [Coq-Club] "exists" Extraction, Morgan Sinclaire, 04/11/2019
- Re: [Coq-Club] "exists" Extraction, Gaëtan Gilbert, 04/11/2019
- Re: [Coq-Club] "exists" Extraction, Gaëtan Gilbert, 04/11/2019
- Re: [Coq-Club] "exists" Extraction, Sylvain Boulmé, 04/11/2019
- Re: [Coq-Club] "exists" Extraction, Gaëtan Gilbert, 04/11/2019
- Re: [Coq-Club] "exists" Extraction, Morgan Sinclaire, 04/11/2019
- Re: [Coq-Club] "exists" Extraction, Dominique Larchey-Wendling, 04/11/2019
- Re: [Coq-Club] "exists" Extraction, Dominique Larchey-Wendling, 04/11/2019
- Re: [Coq-Club] "exists" Extraction, Théo Zimmermann, 04/11/2019
- Re: [Coq-Club] "exists" Extraction, Morgan Sinclaire, 04/11/2019
- Re: [Coq-Club] "exists" Extraction, Helmut Brandl, 04/10/2019
Archive powered by MHonArc 2.6.18.