Theory FR
section ‹FlexRay: Specification›
theory FR
imports FR_types
begin
subsection ‹Auxiliary predicates›
definition
DisjointSchedules :: "nat ⇒ nConfig ⇒ bool"
where
"DisjointSchedules n nC
≡
∀ i j. i < n ∧ j < n ∧ i ≠ j ⟶
disjoint (schedule (nC i)) (schedule (nC j))"
definition
IdenticCycleLength :: "nat ⇒ nConfig ⇒ bool"
where
"IdenticCycleLength n nC
≡
∀ i j. i < n ∧ j < n ⟶
cycleLength (nC i) = cycleLength (nC j)"
definition
FrameTransmission ::
"nat ⇒ 'a nFrame ⇒ 'a nFrame ⇒ nNat ⇒ nConfig ⇒ bool"
where
"FrameTransmission n nStore nReturn nGet nC
≡
∀ (t::nat) (k::nat). k < n ⟶
( let s = t mod (cycleLength (nC k))
in
( s mem (schedule (nC k))
⟶
(nGet k t) = [s] ∧
(∀ j. j < n ∧ j ≠ k ⟶
((nStore j) t) = ((nReturn k) t)) ))"
definition
Broadcast ::
"nat ⇒ 'a nFrame ⇒ 'a Frame istream ⇒ bool"
where
"Broadcast n nSend recv
≡
∀ (t::nat).
( if ∃ k. k < n ∧ ((nSend k) t) ≠ []
then (recv t) = ((nSend (SOME k. k < n ∧ ((nSend k) t) ≠ [])) t)
else (recv t) = [] )"
definition
Receive ::
"'a Frame istream ⇒ 'a Frame istream ⇒ nat istream ⇒ bool"
where
"Receive recv store activation
≡
∀ (t::nat).
( if (activation t) = []
then (store t) = (recv t)
else (store t) = [])"
definition
Send ::
"'a Frame istream ⇒ 'a Frame istream ⇒ nat istream ⇒ nat istream ⇒ bool"
where
"Send return send get activation
≡
∀ (t::nat).
( if (activation t) = []
then (get t) = [] ∧ (send t) = []
else (get t) = (activation t) ∧ (send t) = (return t) )"
subsection ‹Specifications of the FlexRay components›
definition
FlexRay ::
"nat ⇒ 'a nFrame ⇒ nConfig ⇒ 'a nFrame ⇒ nNat ⇒ bool"
where
"FlexRay n nReturn nC nStore nGet
≡
(CorrectSheaf n) ∧
((∀ (i::nat). i < n ⟶ (msg 1 (nReturn i))) ∧
(DisjointSchedules n nC) ∧ (IdenticCycleLength n nC)
⟶
(FrameTransmission n nStore nReturn nGet nC) ∧
(∀ (i::nat). i < n ⟶ (msg 1 (nGet i)) ∧ (msg 1 (nStore i))) )"
definition
Cable :: "nat ⇒ 'a nFrame ⇒ 'a Frame istream ⇒ bool"
where
"Cable n nSend recv
≡
(CorrectSheaf n)
∧
((inf_disj n nSend) ⟶ (Broadcast n nSend recv))"
definition
Scheduler :: "Config ⇒ nat istream ⇒ bool"
where
"Scheduler c activation
≡
∀ (t::nat).
( let s = (t mod (cycleLength c))
in
( if (s mem (schedule c))
then (activation t) = [s]
else (activation t) = []) )"
definition
BusInterface ::
"nat istream ⇒ 'a Frame istream ⇒ 'a Frame istream ⇒
'a Frame istream ⇒ 'a Frame istream ⇒ nat istream ⇒ bool"
where
"BusInterface activation return recv store send get
≡
(Receive recv store activation) ∧
(Send return send get activation)"
definition
FlexRayController ::
"'a Frame istream ⇒ 'a Frame istream ⇒ Config ⇒
'a Frame istream ⇒ 'a Frame istream ⇒ nat istream ⇒ bool"
where
"FlexRayController return recv c store send get
≡
(∃ activation.
(Scheduler c activation) ∧
(BusInterface activation return recv store send get))"
definition
FlexRayArchitecture ::
"nat ⇒ 'a nFrame ⇒ nConfig ⇒ 'a nFrame ⇒ nNat ⇒ bool"
where
"FlexRayArchitecture n nReturn nC nStore nGet
≡
(CorrectSheaf n) ∧
(∃ nSend recv.
(Cable n nSend recv) ∧
(∀ (i::nat). i < n ⟶
FlexRayController (nReturn i) recv (nC i)
(nStore i) (nSend i) (nGet i)))"
definition
FlexRayArch ::
"nat ⇒ 'a nFrame ⇒ nConfig ⇒ 'a nFrame ⇒ nNat ⇒ bool"
where
"FlexRayArch n nReturn nC nStore nGet
≡
(CorrectSheaf n) ∧
((∀ (i::nat). i < n ⟶ msg 1 (nReturn i)) ∧
(DisjointSchedules n nC) ∧ (IdenticCycleLength n nC)
⟶
(FlexRayArchitecture n nReturn nC nStore nGet))"
end