Theory utp_simple_time
section ‹ Simple UTP real-time theory ›
theory utp_simple_time imports "../utp" begin
text ‹ In this section we give a small example UTP theory, and show how Isabelle/UTP can be
used to automate production of programming laws. ›
subsection ‹ Observation Space and Signature ›
text ‹ We first declare the observation space for our theory of timed relations. It consists
of two variables, to denote time and the program state, respectively. ›
alphabet 's st_time =
clock :: nat st :: 's
text ‹ A timed relation is a homogeneous relation over the declared observation space. ›
type_synonym 's time_rel = "'s st_time hrel"
text ‹ We introduce the following operator for adding an $n$-unit delay to a timed relation. ›
definition Wait :: "nat ⇒ 's time_rel" where
[upred_defs]: "Wait(n) = ($clock´ =⇩u $clock + «n» ∧ $st´ =⇩u $st)"
subsection ‹ UTP Theory ›
text ‹ We define a single healthiness condition which ensures that the clock monotonically
advances, and so forbids reverse time travel. ›
definition HT :: "'s time_rel ⇒ 's time_rel" where
[upred_defs]: "HT(P) = (P ∧ $clock ≤⇩u $clock´)"
text ‹ This healthiness condition is idempotent, monotonic, and also continuous, meaning it
distributes through arbitary non-empty infima. ›
theorem HT_idem: "HT(HT(P)) = HT(P)" by rel_auto
theorem HT_mono: "P ⊑ Q ⟹ HT(P) ⊑ HT(Q)" by rel_auto
theorem HT_continuous: "Continuous HT" by rel_auto
text ‹ We now create the UTP theory object for timed relations. This is done using a local
interpretation @{term "utp_theory_continuous HT"}. This raises the proof obligations
that @{term HT} is both idempotent and continuous, which we have proved already.
The result of this command is a collection of theorems that can be derived from these
facts. Notably, we obtain a complete lattice of timed relations via the Knaster-Tarski theorem.
We also apply some locale rewrites so that the theorems that are exports have a more intuitive
form. ›