Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] "exists" Extraction

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] "exists" Extraction


Chronological Thread 
  • From: mukesh tiwari <mukeshtiwari.iiitm AT gmail.com>
  • To: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] "exists" Extraction
  • Date: Thu, 11 Apr 2019 11:00:38 +1000
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=mukeshtiwari.iiitm AT gmail.com; spf=Pass smtp.mailfrom=mukeshtiwari.iiitm AT gmail.com; spf=None smtp.helo=postmaster AT mail-wr1-f52.google.com
  • Ironport-phdr: 9a23:aFMI2xY1tPvghrr/Uf1JLDb/LSx+4OfEezUN459isYplN5qZr8u9bnLW6fgltlLVR4KTs6sC17OP9fmwEjdcqdbZ6TZeKcQKD0dEwewt3CUYSPafDkP6KPO4JwcbJ+9lEGFfwnegLEJOE9z/bVCB6le77DoVBwmtfVEtfre9FYHdldm42P6v8JPPfQpImCC9YbRvJxmqsAndrMYbjZZ/Jqor1xfEoXREdupZyGh1IV6fgwvw6t2/8ZJ+7yhcoe4t+9JFXa7nY6k2ULtUASg8PWso/sPrrx7DTQWO5nsYTGoblwdDDhbG4h/nQJr/qzP2ueVh1iaUO832Vq00Vi+576h3Uh/oiTwIOCA//WrKl8F/lqNboBampxxi347ZZZyeOfRicq/Be94RWGxMVdtTWSNcGIOxd4QAD+QDMuhYoYfzpEYAowWiCgS3Huzj1iVFi2Xq0aEm0eksFxzN0gw6H9IJtXTZtND1NLoRUe+r16nIzSjIb+9X2Tbz8ofIaBEhquyLULJ1bMrRylcgFxjFjlWMqIzkMSma1v4Ms2SB7upgVOOvi3IiqwxqrTivw90jiojNho4P1l/E8iB5zZ8zKNalRkB7ZtukH4FRtyGcL4Z2Q8UiQ3tpuCkg0LEGt4S7cDARyJQ73RHQd/+Hc4+W4h39TuaRLzN4hHVreb6lmxmy9k2gxvXgWcm01FZKrzJFncPItn8XzRDT7NaISud780y82jiPzxje5v9YLU0wj6bWKJ4szqQumpYNrEjPBC/7lFvwgaSLbEsr4PKo5P7iYrj+pp+TKYt0igbmP6QrgMO/AOA4PhEAXmiB5OiwzbPj8E3nTLlQgf02la7ZsJ/eJcsFvKK2HwhV0oM75xa+CTepzsgYkGEZIF5ZfB+LlYvkNlHULPzmE/uznk6gnTd1y/zeO73uGJTNLnzNkLf7erZ97lZRyA8uzdBc+Z1UEbEBIO7yWk7/rtPYFB45Pxa1w+bmCdV9yoYeVHmAAq+cKqzSsFuI6vgzLOmLYY8ZoCz9JOQ95/7ykX85nkcQcrWu3ZsOcXy3AvBmI1iCbnf3mdcAEWIKvhIkQ+DwiV2CVyRTZ3eoUK4m6DE7EtHuMYCWTYe0xbeFwS2TH5tMZ2kABErfP23vctCBRvQBcyLaPs5+myYFHeykVowszhGytRDz0bshL+vV5igwupfq1dwz7OrWw0JhvQdoBtiQhjneB1p/mXkFEmdvjfJP5Hdlw1LG6pBWxvlRFNhd/fRMC15oOpvVzug8ANf3CFuYIoW5DW2+S9DjOgkfC8oryoZXMUl4EtSmyBvE2njyWuJHp/mwHJUxt5nk8T3xKsJ6kSuU0aAgixw5WJIKOzD8wKF48AfXCsjClEDLz6s=

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!





Archive powered by MHonArc 2.6.18.

Top of Page