Library HOC04DefLTS


Require Import HOC01Defs.
Require Import HOC02BaseLemmas.
Require Import HOC03CanonicalLemmas.


Inductive label : Type :=
 | LabOut : chanwfprocesslabel
 | LabIn : chanlabel
 | LabRem : varlabel
 | Tau.


Inductive abstraction : Set :=
 | AbsPure : varwfprocessabstraction
 | AbsPar1 : abstractionwfprocessabstraction
 | AbsPar2 : wfprocessabstractionabstraction.

Inductive agent : Set :=
 | AA : abstractionagent
 | AP : wfprocessagent.

Definition par_ag1 (a : agent) (p : wfprocess) : agent :=
  match a with
    | AA fAA (AbsPar1 f p)
    | AP qAP (wfp_Par q p)
  end.

Definition par_ag2 (p : wfprocess) (a : agent) : agent :=
  match a with
    | AA fAA (AbsPar2 p f)
    | AP qAP (wfp_Par p q)
  end.

Inductive const_abs : abstractionProp :=
 | CAbs : X (p : wfprocess), X \notin GV pconst_abs (AbsPure X p)
 | CAbsPar1 : f p, const_abs fconst_abs (AbsPar1 f p)
 | CAbsPar2 : f p, const_abs fconst_abs (AbsPar2 p f).

Hint Resolve CAbs CAbsPar1 CAbsPar2.

Fixpoint const_abs_dec (fp : abstraction): bool :=
  match fp with
    | AbsPure X pifb (X # p) then true else false
    | AbsPar1 fp pconst_abs_dec fp
    | AbsPar2 p fpconst_abs_dec fp
  end.

Instance const_abs_decidable : (f:abstraction), Decidable (const_abs f).
Proof.
  intros.
  applys¬ decidable_make (const_abs_dec f).
  inductions f; simpls¬.
  cases_if; try rename f into Hf; symmetry.
    applys¬ isTrue_true.
    apply isTrue_false. intro H1. inverts¬ H1.
    rewrite isTrue_def in ×. cases_if; cases_if¬.
      inverts H. false.
      false¬ H.
    rewrite isTrue_def in ×. cases_if; cases_if¬.
      inverts H. false.
      false¬ H.
Qed.

Fixpoint sizeAbs (fp :abstraction) : nat :=
  match fp with
    | AbsPure X psizeX X p
    | AbsPar1 fp psizeAbs fp
    | AbsPar2 p fpsizeAbs fp
  end.

Fixpoint wfp_inst_Abs (fp : abstraction) (q : wfprocess) : wfprocess :=
  match fp with
    | AbsPure X pwfp_subst q X p
    | AbsPar1 fp pwfp_Par (wfp_inst_Abs fp q) p
    | AbsPar2 p fpwfp_Par p (wfp_inst_Abs fp q)
  end.


Reserved Notation "{{ p -- l ->> ap }}" (at level 60).

Inductive transition : wfprocesslabelagentProp :=
 | TrOut : a p, {{wfp_Send a p -- LabOut a p ->> AP wfp_Nil}}
 | TrIn : a X p, {{wfp_Abs a X p -- LabIn a ->> AA (AbsPure X p)}}
 | TrRem : X, {{wfp_Gvar X -- LabRem X ->> AP wfp_Nil}}
 | TrAct1 : p q l ap, (transition p l ap) → (transition (wfp_Par p q) l (par_ag1 ap q))
 | TrAct2 : p q l aq, (transition q l aq) → (transition (wfp_Par p q) l (par_ag2 p aq))
 | TrTau1 : a p q p´´ fq,
    (transition p (LabOut a p´´) (AP )) →
    (transition q (LabIn a) (AA fq)) →
    (transition (wfp_Par p q) Tau (AP (wfp_Par (wfp_inst_Abs fq p´´))))
 | TrTau2 : a p q q´´ fp,
    (transition p (LabIn a) (AA fp)) →
    (transition q (LabOut a q´´) (AP )) →
    (transition (wfp_Par p q) Tau (AP (wfp_Par (wfp_inst_Abs fp q´´) )))
where "{{ p -- l ->> ap }}" := (transition p l ap).

Hint Resolve TrOut TrIn TrRem TrAct1 TrAct2 TrTau1 TrTau2.