coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Xavier Leroy <Xavier.Leroy AT inria.fr>
- To: ldou AT cs.ecnu.edu.cn, coq-club AT inria.fr
- Subject: Re: [Coq-Club] the context of sequence diagram
- Date: Sun, 18 Sep 2011 17:07:54 +0200
On 09/17/2011 03:12 PM,
ldou AT cs.ecnu.edu.cn
wrote:
> i'm using Coq to formalize the Sequence Diagram. The following inductive
> type of sequence diagram has been defined:
> Then i want to define "context" in Coq. According to our concept, a
> context is a sequence diagram with one of its fragment replaced by a special
> symbol x, just like term rewriting. how should i define "context"? any
> suggestions are appreciated.
Pierre's second solution is good, but here is another that I use all
the time to do Wright-Felleisen-style reduction semantics.
A context is just a Coq function:
Definition context : Set := seqDiag -> seqDiag.
... further constrained by the "iscontext" inductive predicate:
Inductive iscontext: context -> Prop :=
| iscontext_hole:
iscontext (fun x => x)
| iscontext_strict_l: forall C s,
iscontext C -> iscontext (fun x => DStrict (C x) s)
| iscontext_strict_r: forall s C,
iscontext C -> iscontext (fun x => DStrict s (C x))
| iscontext_par_l: forall C s,
iscontext C -> iscontext (fun x => DPar (C x) s)
| iscontext_par_r: forall s C,
iscontext C -> iscontext (fun x => DPar s (C x))
| iscontext_seq_l: forall C s,
iscontext C -> iscontext (fun x => DSeq (C x) s)
| iscontext_seq_r: forall s C,
iscontext C -> iscontext (fun x => DSeq s (C x)).
In this approach, "filling the hole" (Pierre's "fill d C" function) is
just Coq's function application "C d". It also makes it slightly easier
to compose contexts, shall you ever need to do that.
Hope this helps,
- Xavier Leroy
- [Coq-Club] the context of sequence diagram, ldou
- Re: [Coq-Club] the context of sequence diagram,
Pierre Casteran
- Re: [Coq-Club] the context of sequence diagram, Pierre Casteran
- Re: [Coq-Club] the context of sequence diagram, Xavier Leroy
- Re: [Coq-Club] the context of sequence diagram,
Pierre Casteran
Archive powered by MhonArc 2.6.16.