Skip to Content.
Sympa Menu

coq-club - [Coq-Club] question about simulation relation

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

[Coq-Club] question about simulation relation


chronological Thread 
  • From: ldou AT cs.ecnu.edu.cn
  • To: coq-club AT inria.fr
  • Subject: [Coq-Club] question about simulation relation
  • Date: Thu, 26 Jan 2012 16:28:12 +0800

Hi, all,
  we're writing to seek advice on a question which bothers us quite a while. We're using Coq to define the "simulation" relation on two traces, but get stuck when proving the lemma  "SimulationExist":
Lemma SimulationExist : forall st c, exists c', forall a b z, simulation st a b ¡ú
                simulation st (sel c a z) (sel c' b z).
We think it is true:
when "simulation st a b" exists and the function of "sel" in c  is used to construct the interleave of two traces(a and z) , the function of "sel" in c' should construct the interleave of b and z in the same way as the previous one.
We have no idea about how to construct such c' in Coq, any suggestions are appreciated.
   The detail codes are as follows, you can also find them in the attachment. Thanks in advance.
===================
Require Import String List Compare_dec Coq.Unicode.Utf8.
Definition Pset (A:Type) := A ¡ú Prop.
(*A event is defined as a string *)
Definition event:=string.
Inductive id : Type :=
  Id : nat ¡ú id.
Inductive cnd : Type :=
  | BVar: id ¡ú cnd
  | BTrue : cnd
  | BFalse : cnd
  | BImp : cnd ¡ú cnd ¡ú cnd.
(*Inductive type for event with guard(condition)*)
Inductive core:Type:=
|ev: event¡úcore
|cd: cnd¡úcore.
(*A trace is defined as list of core*)
Definition trace := list core.
Definition obligation := Pset trace.
Notation "'¦Å'" := (@nil core).
Notation "x ¡¤ ¦Í" := (@cons core x ¦Í) (at level 60, right associativity).

(*1.the following part is to implement the formal definitions
  of "interleave operator":
Let ¦² be an alphbet. Let x,y ¡Ê ¦² and ¦Ì,v ¡Ê¦²*,
the definition of the interleave operator ¡ì is as follows:
¦Å¡ì¦Ì = ¦Ì¡ì¦Å = ¦Ì
x¦Ì¡ìyv = {x}¡¤(¦Ì¡ìyv) ¡È {y}¡¤(x¦Ì¡ìv)
where ¡¤ is the concatenation operator.
*)
Reserved Notation "x ¡ì y" (at level 5).
Notation "a ¡Ê s" := ((s:Pset _) a) (at level 10).
Notation "[ x | P ]" := (fun x => P).
Inductive interleave : trace ¡ú trace ¡ú obligation :=
| ¦Årule : ¦Å ¡Ê ¦Å ¡ì ¦Å
| lrule : forall x ¦Í ¦Ì ¦Ó, ¦Ó ¡Ê ¦Í ¡ì ¦Ì ¡ú (x¡¤¦Ó) ¡Ê (x¡¤¦Í) ¡ì ¦Ì
| rrule : forall ¦Í y ¦Ì ¦Ó, ¦Ó ¡Ê ¦Í ¡ì ¦Ì ¡ú (y¡¤¦Ó) ¡Ê ¦Í ¡ì (y¡¤¦Ì)
where "x ¡ì y" := (interleave x y).

(*2.the definition of choice:
the function "sel" is used to construct interleave of two traces,
the "spe" is used to restrict the result of "sel"
*)
Record choice := cho
 { sel : trace ¡ú trace ¡ú trace
 ; spe : forall t1 t2, (sel t1 t2) ¡Ê t1¡ìt2
 }.


(*3.the definition of "simulation" relation which is based on "trace"*)
Definition state := id -> bool.
Fixpoint beval (st:state)(c : cnd) : bool :=
  match c with
  | BVar i      => st i
  | BTrue       => true
  | BFalse      => false
  | BImp b1 b2  => orb (negb (beval st b1)) (beval st b2)
    (*translate [P->Q] into [(not P)\/Q]*)
  end.
Inductive simulation(st:state) :trace -> trace ->Prop :=
  |simu_foundation: simulation  st ¦Å ¦Å
  |sim_cnd: forall c c' t t', beval st (BImp c' c)=true ->
             simulation  st t t' ->
             simulation  st ((cd c)¡¤t) ((cd c')¡¤t')
  |sim_ev:  forall t t' e , simulation st t t' ->
             simulation  st ((ev e)¡¤t) ((ev e)¡¤t')
  |sim_add: forall e t t',  simulation st t t' -> 
             simulation  st t ((ev e)¡¤t').

Require Import Relations.
(*
we've proved the following two lemmas, but omitted the proofs for clarity*)
Lemma SimulationReflxive:forall st:state,reflexive _ (simulation st).
Admitted.
Lemma SimulationTransitive: (forall st:state,transitive _ (simulation st)).
Admitted.

Definition trace_dec:forall (a b:trace) ,{a = b} + {a <> b}.
   repeat decide equality.
Defined.


(*4.the properties of "simulation" .
we get stuck in this lemma. We think it is true:
when "simulation st a b" exists and the function of "sel" in c
is used to construct the interleave of two traces(a and z) , the function of "sel"
in c' should construct the interleave of b and z in the same way as the previous one.
We have no idea about how to construct such c' in Coq,
any suggestions are appreciated.
*)
Lemma SimulationExist:forall st c, exists c', forall a b z, simulation st a b ¡ú
                simulation st (sel c a z) (sel c' b z).
Proof.
  intros st c.
 

============
Best regards,
Lisa

Require Import String List Compare_dec Coq.Unicode.Utf8.
Definition Pset (A:Type) := A â†’ Prop.
(*A event is defined as a string *)
Definition event:=string.
Inductive id : Type := 
  Id : nat â†’ id.
Inductive cnd : Type :=
  | BVar: id â†’ cnd
  | BTrue : cnd
  | BFalse : cnd
  | BImp : cnd â†’ cnd â†’ cnd.
(*Inductive type for event with guard(condition)*)
Inductive core:Type:=
|ev: event→core
|cd: cnd→core.
(*A trace is defined as list of core*)
Definition trace := list core.
Definition obligation := Pset trace.
Notation "'ε'" := (@nil core).
Notation "x Â· Î½" := (@cons core x Î½) (at level 60, right associativity).

(*1.the following part is to implement the formal definitions
  of "interleave operator":
Let Î£ be an alphbet. Let x,y âˆˆ Î£ and Î¼,v âˆˆÎ£*, 
the definition of the interleave operator Â§ is as follows:
ε§μ = Î¼Â§Îµ = Î¼
xμ§yv = {x}·(μ§yv) âˆª {y}·(xμ§v)
where Â· is the concatenation operator.
*)
Reserved Notation "x Â§ y" (at level 5).
Notation "a âˆˆ s" := ((s:Pset _) a) (at level 10).
Notation "[ x | P ]" := (fun x => P).
Inductive interleave : trace â†’ trace â†’ obligation :=
| Îµrule : Îµ âˆˆ Îµ Â§ Îµ
| lrule : forall x Î½ Î¼ Ï„, Ï„ âˆˆ Î½ Â§ Î¼ â†’ (x·τ) âˆˆ (x·ν) Â§ Î¼
| rrule : forall Î½ y Î¼ Ï„, Ï„ âˆˆ Î½ Â§ Î¼ â†’ (y·τ) âˆˆ Î½ Â§ (y·μ)
where "x Â§ y" := (interleave x y).

(*2.the definition of choice:
the function "sel" is used to construct interleave of two traces,
the "spe" is used to restrict the result of "sel"
*)
Record choice := cho
 { sel : trace â†’ trace â†’ trace
 ; spe : forall t1 t2, (sel t1 t2) âˆˆ t1§t2
 }.


(*3.the definition of "simulation" relation which is based on "trace"*)
Definition state := id -> bool.
Fixpoint beval (st:state)(c : cnd) : bool :=
  match c with 
  | BVar i      => st i
  | BTrue       => true
  | BFalse      => false
  | BImp b1 b2  => orb (negb (beval st b1)) (beval st b2)
    (*translate [P->Q] into [(not P)\/Q]*)
  end.
Inductive simulation(st:state) :trace -> trace ->Prop :=
  |simu_foundation: simulation  st Îµ Îµ
  |sim_cnd: forall c c' t t', beval st (BImp c' c)=true -> 
             simulation  st t t' ->
             simulation  st ((cd c)·t) ((cd c')·t')
  |sim_ev:  forall t t' e , simulation st t t' ->
             simulation  st ((ev e)·t) ((ev e)·t')
  |sim_add: forall e t t',  simulation st t t' ->  
             simulation  st t ((ev e)·t').

Require Import Relations.
(*
we've proved the following two lemmas, but omitted the proofs for clarity*)
Lemma SimulationReflxive:forall st:state,reflexive _ (simulation st).
Admitted.
Lemma SimulationTransitive: (forall st:state,transitive _ (simulation st)).
Admitted.

Definition trace_dec:forall (a b:trace) ,{a = b} + {a <> b}.
   repeat decide equality. 
Defined.


(*4.the properties of "simulation" .
we get stuck in this lemma. We think it is true:
when "simulation st a b" exists and the function of "sel" in c 
is used to construct the interleave of two traces(a and z) , the function of 
"sel"
in c' should construct the interleave of b and z in the same way as the 
previous one.
We have no idea about how to construct such c' in Coq,
any suggestions are appreciated.
*)
Lemma SimulationExist:forall st c, exists c', forall a b z, simulation st a b 
→
                simulation st (sel c a z) (sel c' b z).
Proof.
  intros st c.
  




Archive powered by MhonArc 2.6.16.

Top of Page