coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Agnishom Chattopadhyay <agnishom AT cmi.ac.in>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] How can I extract data from this exists Prop?
- Date: Mon, 10 Aug 2020 13:07:44 -0500
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=agnishom AT cmi.ac.in; spf=Pass smtp.mailfrom=agnishom AT cmi.ac.in; spf=None smtp.helo=postmaster AT mail.cmi.ac.in
- Ironport-phdr: 9a23:+uuNhhIwFP28Q529b9mcpTZWNBhigK39O0sv0rFitYgeKPXxwZ3uMQTl6Ol3ixeRBMOHsqwC27qd6vq4EUU7or+5+EgYd5JNUxJXwe43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6arXK99yMdFQviPgRpOOv1BpTSj8Oq3Oyu5pHfeQpFiCe8bL9oLxi7rgrdutQIjYd+N6081gbHrnxUdupM2GhmP0iTnxHy5sex+J5s7SFdsO8/+sBDTKv3Yb02QaRXAzo6PW814tbrtQTYQguU+nQcSGQWnQFWDAXD8Rr3Q43+sir+tup6xSmaIcj7Rq06VDi+86tmTgLjhSEaPDA77W7XkNR9g61VoB2jpxJxzY3abpyLOvViZa7SZ88WSHBbU8pNSyBMAIWxZJYPAeobOuZYqpHwqkcBrRu4BAmsH+PvyjhNhnTrw6A60/4uER3a3AwnB9IBqmnbrNX1NagIUeG+0a7Fwi/Mb/NQ2Df984jIchckofyXQb1wdMvRxVM1GAzZlFmQqIrlMiqT2+8QvGeV8/BuWvizi247tQ5xuD6vy98shITUmo4Z1l/J+CFkzIs1KtC1VEp2bcCkHZVfqi2UOYV7T8ciTmx2uCs0yr0Lt56lcSUU1pkr2h/SZv2JfoWL5B/oSeWfIS9giX54Zr6yiQy+/Emux+HmSMW4zFhHojBbntXRqHwBzwLf5tSDR/dn/Uqs2SyD2x3S5+xFO0w4iKjWJpwnz7UtjJQcq17DETXzmEjujK+ZaEEk+u+w5uTieLrmp5ucO5VohQH7M6QigNawDvgiPggPWWiX4eW81Lv98k3lWLhGk+M6n6fDvJ3bK8kXvLC1DxNb34o59RqzEimq3MwdnXYdLVJFfByHj5LuO1HLOP33F/i/g1KtkDdwx/DGObjhD47RIXjGkbftZ6xy5FJGxAoyy9BT/4hUBa0ZIPLvRk/xs8TVAQM+Mwyt2uroFNF91p4FVm+UGa+YMKbSsUeS6e41IumMYpUVuDfnJPQ/6f7ulyxxpVhIdq6wmJATdXqQH/J8Ikzfb2C/rM0GFDIjsQw/V+ztjRWpUTdPe3GqVq489zgqQNavAoHCXYCqhZSK2Sb9F5YQZ2YQWQPEKmvha4jRA6REUymVOMI0ymVVB4jkcJco0FSVjCG/zrNmKuTO/ShB7MDo0dkz7uaVlBdgrGUpXfTY6HmESiRPpk1NRzIy2/kh80l0y1PF2q15xfVTU91VtasQDlUKcKXExuk/MOjcHxrbd47QGl2jQ5OvCncwSIBpzg==
Wow, thanks that worked! What is the default PartialOrder, then?
On Mon, Aug 10, 2020 at 12:59 PM Roger Witte <Roger.Witte AT dft.gov.uk> wrote:
Use CRelationClasses.PartialOrder instead of PartialOrder and you'll be OK.
RegardsRoger
From: Agnishom Chattopadhyay <agnishom AT cmi.ac.in>
Sent: Monday, 10 August 2020 18:27
To: coq-club AT inria.fr
Subject: Re: [Coq-Club] How can I extract data from this exists Prop?
Thank You. These are both great ideas. However, what I presented was a simplification of what I actually wanted. I am trying to define prefixes in the context of trace monoids (i.e, lists in which certain shufflings are allowed), in which case Definition witness (x y : list A) := skipn (length x) y. does not hold.
Probably the best I can do is to work with the type
sig (fun z => x ++ z = y).
This has the downside that I can't use definitions like PartialOrder from the standard library.
On Mon, Aug 10, 2020 at 4:01 AM Castéran Pierre <pierre.casteran AT gmail.com> wrote:
Hello,
You can define isPrefixOf as an inductive predicate :
Inductive isPrefixOf {A:Type}: relation (list A) :=pf1 : forall x, isPrefixOf nil x| pf2 : forall a x y, isPrefixOf x y -> isPrefixOf (a::x) (a::y).
Then prove a small inversion lemma:
Lemma isPrefix_inv {A:Type} (x y: list A) (a b:A) :isPrefixOf (a::x) (b::y) -> a = b /\ isPrefixOf x y.Proof. inversion 1; auto. Qed.
Then you prove an equivalence between this definition and your sig definition (by induction on the lists, and applications of IsPrefix_inv).
Lemma isPrefixOf_ok {A} (x y:list A) : isPrefixOf x y -> {z | x ++ z = y}.
Lemma isPrefixOf_okR {A} (x y z:list A) : x ++ z = y -> isPrefixOf x y.
Best regards,
Pierre
Le 10 août 2020 à 05:55, Agnishom Chattopadhyay <agnishom AT cmi.ac.in> a écrit :
I have a function that is something like this:
Definition isPrefixOf (x : list A) (y : list A) :=
exists z, x ++ z = y.
Now, I want to define a witness function. Informally, it can be described as follows: Given x and y such that (isPrefixOf x y), return z which satisfies the criteria exists z, x ++ z = y.
I would try to define it this way, but that would not work (possibly because exists z, x ++ z = y is a Prop and we are asking for something in Type) :
Definition witness (x y : list A) {H : isPrefixOf x y} : list A.
destruct H.Abort.
Another option seems to be to define
Definition isPrefixOf (x y : list A) :=
sig (fun z => x ++ z = y).
But I do not like this because this does not let me define things like Instance isPrefixOf_PreOrder : PreOrder isPrefixOf.
So, how can I have my cake and eat it too?
__________________________________________________________________________________________
This email has originated from external sources and has been scanned by DfT’s email scanning service.
__________________________________________________________________________________________
The information in this email may be confidential or otherwise protected by law. If you received it in error, please let us know by return e-mail and then delete it immediately, without printing or passing it on to anybody else.
Incoming and outgoing e-mail messages are routinely monitored for compliance with our policy on the use of electronic communications and for other lawful purposes.
- [Coq-Club] How can I extract data from this exists Prop?, Agnishom Chattopadhyay, 08/10/2020
- Re: [Coq-Club] How can I extract data from this exists Prop?, Guillaume Melquiond, 08/10/2020
- Re: [Coq-Club] How can I extract data from this exists Prop?, Castéran Pierre, 08/10/2020
- Re: [Coq-Club] How can I extract data from this exists Prop?, Agnishom Chattopadhyay, 08/10/2020
- <Possible follow-up(s)>
- Re: [Coq-Club] How can I extract data from this exists Prop?, Roger Witte, 08/10/2020
- Re: [Coq-Club] How can I extract data from this exists Prop?, Agnishom Chattopadhyay, 08/10/2020
Archive powered by MHonArc 2.6.19+.