Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Building a constructive term from inside an ML tactic

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Building a constructive term from inside an ML tactic


Chronological Thread 
  • From: Talia Ringer <tringer AT cs.washington.edu>
  • To: Coq-Club <coq-club AT inria.fr>
  • Subject: Re: [Coq-Club] Building a constructive term from inside an ML tactic
  • Date: Tue, 10 Apr 2018 02:35:58 +0000
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=tringer AT cs.washington.edu; spf=None smtp.mailfrom=tringer AT cs.washington.edu; spf=None smtp.helo=postmaster AT mail-vk0-f43.google.com
  • Ironport-phdr: 9a23:texHoxypKpzahW7XCy+O+j09IxM/srCxBDY+r6Qd1OgfIJqq85mqBkHD//Il1AaPAd2Araocw8Pt8InYEVQa5piAtH1QOLdtbDQizfssogo7HcSeAlf6JvO5JwYzHcBFSUM3tyrjaRsdF8nxfUDdrWOv5jAOBBr/KRB1JuPoEYLOksi7ze+/94HdbglSmDaxfa55IQmrownWqsQYm5ZpJLwryhvOrHtIeuBWyn1tKFmOgRvy5dq+8YB6/ShItP0v68BPUaPhf6QlVrNYFygpM3o05MLwqxbOSxaE62YGXWUXlhpIBBXF7A3/U5zsvCb2qvZx1S+HNsDwULs6Wymt771zRRDnhicINT43/m/UhMJtkqxUvAmsqAZjz4POeoyZKOZyc6HbcNgHRWRBRMFRVylZD42idYQPC+sBMvxFpIfhplsOqxS+Che2BOjyzTJImmX23aw80+QuDw7GxhctEM4VsHjOotT6LrwSUeC0zKnOwjXDc/RW2THn5IfWbx8hvOiBULRtesTS0UkiDx3JgkmUpID/PD6Y1v4Bv3aG4+duT+6ihGAqpgdsqTa13MgskJPGhocNx1DE6yp5xIE1KMW9SEFhYN6kFIJctz+ZN4dqW88iTW5ltSggxr0Jvp67eycKyJA5yBLFd/OHdI2I7griVOaXPzh4mGpodKyjixu260Stye3xWtOq3FpXoCdJiNbBu34V2xzW8MeHS/99/km72TaI0gDe8v1EIVo1lardJJ4u3KQwm4EPvkTYBCP3ll/5jLSWdkUl/Oio5PjnYrLgppOGKYB7lxz+Prw0msOjGeQ4LhQOX2+D9Oug073j5FT1T6lOjv0riabUq4vaJMQepq6hGQBZyIcj6xClDzenytsUh3cHLEgWMC6A2qPuIhTlJO3yRaO0hE3pmzN2zdjHOKfgC9PDNC6Qvq3meONB4kpdwUIJzNZQ6ogcXq0bIfT8V1XZv8eeERYiMw2yzPrgDpNw2p5ICjHHObOQLK6H6QzA3ekoOeTZPNZE6ga4EOAs4rvVtVF8nFYceaez2p5OOSKzBbJ5Kl6ZYHzjntAHV2oGo1hmFbC4uBi5STdWIk2Kceck/DhiWdCtFsHcT5utgbqOwCC9WJBaezIeUw3eITLTb4yBHsw0RmeSL8tmyGFWULGgT8o/1knrulOhjbVgKeXQ92sTspexjNU=

Here's one way to build an inductive type and one of it's constructors given its FQ name and the index of the constructor, with example code that I wrote for sigT, which you can modify as needed. Zero guarantees it's up-to-date or the best way but hopefully it gets you somewhere.

let coq_init_specif = ModPath.MPfile (DirPath.make (List.map Id.of_string ["Specif"; "Init"; "Coq"]))
                                     
let sigT =
  mkInd (MutInd.make1 (KerName.make2 coq_init_specif (Label.make "sigT")), 0)

let existT =
  mkConstruct (fst (destInd sigT), 1)



On Mon, Apr 9, 2018, 6:44 PM Kenneth Roe <kendroe AT hotmail.com> wrote:

I am writing a tactic to simplify expressions.  As an example consider the following:


Fixpoint beq a b :=

    match a,b with

    | 0,0 => true

    | (S x),(S y) => beq x y

    | _,_ => false

    end.


Fixpoint blt a b :=

    match a,b with

    | _,0 => false

    | (S x),(S y) => blt x y

    | 0,(S x) => true

    end.


Theorem test: forall x y, q(x,y) = orb (negb (beq x y)) (negb(blt x y)).

Proof.

    arewrite.


The "arewrite" tactic can reduce this theorem to "forall x y, q(x,y) = true".  The tactic needs to construct the inductive term "true".  I tried the following piece of ml code which did not work:


let true_term = Term.mkApp (mkConstructorUi (Lib_coq.init_constant ["Coq"; "Init"; "Datatypes"] "bool") 1) [||]


The problem seems to be that I need to convert a constr object to a pinductive object.  Can someone give me a piece of ml code to construct the term "true"?


                                   - Ken





Archive powered by MHonArc 2.6.18.

Top of Page