Section Automatas_TCG.
(* System TCG: Especification *)
(* Set of Labels *)
Inductive Label : Set :=
| Approach : Label
| In : Label
| Exit : Label
| Lower : Label
| Raise : Label
| Up : Label
| Down : Label
| Tick : Label.
(* Tick represent temporal transitions *)
(* Locations: ST (Train), SC (Controller) and SG (Gate) *)
Inductive ST : Set :=
| Far : ST
| Near : ST
| Inside : ST.
Inductive SC : Set :=
| Sc1 : SC
| Sc2 : SC
| Sc3 : SC
| Sc4 : SC.
Inductive SG : Set :=
| Open : SG
| Lowering : SG
| Closed : SG
| Raising : SG.
(* States with one clock *)
Definition S_Ck (S : Set) := (S * Clock)%type.
(* TCG constants *)
Definition kt1 : Instant := 8.
Definition kt2 : Instant := 20.
Definition kc1 : Instant := 4.
Definition kc2 : Instant := 4.
Definition kg1 : Instant := 4.
Definition kg2 : Instant := 4.
Definition kg3 : Instant := 8.
(* Invariants of locations for the Train *)
Inductive InvT : S_Ck ST -> Prop :=
| Ifar : forall x : Clock, InvT (Far, x)
| Inear : forall x : Clock, lt_Ck x kt2 -> InvT (Near, x)
| Iinside : forall x : Clock, lt_Ck x kt2 -> InvT (Inside, x).
(* Invariants of locations for the Controller *)
Inductive InvC : S_Ck SC -> Prop :=
| Isc1 : forall y : Clock, InvC (Sc1, y)
| Isc2 : forall y : Clock, le_Ck y kc1 -> InvC (Sc2, y)
| Isc3 : forall y : Clock, InvC (Sc3, y)
| Isc4 : forall y : Clock, lt_Ck y kc2 -> InvC (Sc4, y).
(* Invariants of locations for the Gate *)
Inductive InvG : S_Ck SG -> Prop :=
| Iopen : forall z : Clock, InvG (Open, z)
| Ilowering : forall z : Clock, lt_Ck z kg1 -> InvG (Lowering, z)
| Iclosed : forall z : Clock, InvG (Closed, z)
| Iraising : forall z : Clock, lt_Ck z kg3 -> InvG (Raising, z).
(* Train transitions *)
Inductive TrT : S_Ck ST -> Label -> S_Ck ST -> Prop :=
| ttApproach : forall x : Clock, TrT (Far, x) Approach (Near, Reset)
| ttIn :
forall x : Clock,
gt_Ck x kt1 -> lt_Ck x kt2 -> TrT (Near, x) In (Inside, x)
| ttExit : forall x : Clock, lt_Ck x kt2 -> TrT (Inside, x) Exit (Far, x)
| ttTick :
forall (x : Clock) (s : ST),
InvT (s, Inc x) -> TrT (s, x) Tick (s, Inc x).
(* Controller transitions *)
Inductive TrC : S_Ck SC -> Label -> S_Ck SC -> Prop :=
| tcApproach : forall y : Clock, TrC (Sc1, y) Approach (Sc2, Reset)
| tcLower : forall y : Clock, eq_Ck y kc1 -> TrC (Sc2, y) Lower (Sc3, y)
| tcExit : forall y : Clock, TrC (Sc3, y) Exit (Sc4, Reset)
| tcRaise : forall y : Clock, lt_Ck y kc2 -> TrC (Sc4, y) Raise (Sc1, y)
| tcTick :
forall (y : Clock) (s : SC),
InvC (s, Inc y) -> TrC (s, y) Tick (s, Inc y).
(* Gate transitions *)
Inductive TrG : S_Ck SG -> Label -> S_Ck SG -> Prop :=
| tgLower : forall z : Clock, TrG (Open, z) Lower (Lowering, Reset)
| tgDown :
forall z : Clock, lt_Ck z kg1 -> TrG (Lowering, z) Down (Closed, z)
| tgRaise : forall z : Clock, TrG (Closed, z) Raise (Raising, Reset)
| tgUp :
forall z : Clock,
ge_Ck z kg2 -> lt_Ck z kg3 -> TrG (Raising, z) Up (Open, z)
| tgTick :
forall (z : Clock) (s : SG),
InvG (s, Inc z) -> TrG (s, z) Tick (s, Inc z).
(* States for the system: train||controller||gate *)
Definition StGlobal := (S_Ck ST * (S_Ck SC * S_Ck SG))%type.
(* Transitions for the system: train||controller||gate *)
Inductive TrGlobal : StGlobal -> Label -> StGlobal -> Prop :=
| tGl_In :
forall st1 st2 : S_Ck ST,
TrT st1 In st2 ->
forall (sc : S_Ck SC) (sg : S_Ck SG),
TrGlobal (st1, (sc, sg)) In (st2, (sc, sg))
| tGl_Down :
forall sg1 sg2 : S_Ck SG,
TrG sg1 Down sg2 ->
forall (st : S_Ck ST) (sc : S_Ck SC),
TrGlobal (st, (sc, sg1)) Down (st, (sc, sg2))
| tGl_Up :
forall sg1 sg2 : S_Ck SG,
TrG sg1 Up sg2 ->
forall (st : S_Ck ST) (sc : S_Ck SC),
TrGlobal (st, (sc, sg1)) Up (st, (sc, sg2))
| tGl_Approach :
forall (st1 st2 : S_Ck ST) (sc1 sc2 : S_Ck SC),
TrT st1 Approach st2 ->
TrC sc1 Approach sc2 ->
forall sg : S_Ck SG,
TrGlobal (st1, (sc1, sg)) Approach (st2, (sc2, sg))
| tGl_Exit :
forall (st1 st2 : S_Ck ST) (sc1 sc2 : S_Ck SC),
TrT st1 Exit st2 ->
TrC sc1 Exit sc2 ->
forall sg : S_Ck SG, TrGlobal (st1, (sc1, sg)) Exit (st2, (sc2, sg))
| tGl_Lower :
forall (sc1 sc2 : S_Ck SC) (sg1 sg2 : S_Ck SG),
TrC sc1 Lower sc2 ->
TrG sg1 Lower sg2 ->
forall st : S_Ck ST, TrGlobal (st, (sc1, sg1)) Lower (st, (sc2, sg2))
| tGl_Raise :
forall (sc1 sc2 : S_Ck SC) (sg1 sg2 : S_Ck SG),
TrC sc1 Raise sc2 ->
TrG sg1 Raise sg2 ->
forall st : S_Ck ST, TrGlobal (st, (sc1, sg1)) Raise (st, (sc2, sg2))
| tGl_Tick :
forall (st1 st2 : S_Ck ST) (sc1 sc2 : S_Ck SC) (sg1 sg2 : S_Ck SG),
TrT st1 Tick st2 ->
TrC sc1 Tick sc2 ->
TrG sg1 Tick sg2 -> TrGlobal (st1, (sc1, sg1)) Tick (st2, (sc2, sg2)).
(* Initial states *)
Definition ini_CkT := 0.
Definition ini_CkC := 0.
Definition ini_CkG := 0.
Definition SiniT : S_Ck ST := (Far, ini_CkT).
Definition SiniC : S_Ck SC := (Sc1, ini_CkC).
Definition SiniG : S_Ck SG := (Open, ini_CkG).
Definition SiniTCG : StGlobal := (SiniT, (SiniC, SiniG)).
End Automatas_TCG.
Hint Constructors InvT: sysTCG.
Hint Constructors InvC: sysTCG.
Hint Constructors InvG: sysTCG.
Hint Constructors TrT: sysTCG.
Hint Constructors TrC: sysTCG.
Hint Constructors TrG: sysTCG.
Hint Constructors TrGlobal: sysTCG.
(****************************************************************************)
(*                               System TCG: Analysis                       *)
(****************************************************************************)
Load "TemporalOperators.v".
(* Temporal operators. CTL -computation tree logic- and TCTL -timed computation tree logic- *)
(* Elemental properties of clocks and constants of the System TCG *)

Lemma trivial_inv_1 : lt_Ck Reset kt2.