Skip to content

Commit

Permalink
Added syntax to allow programs to return exit values. The executor wi…
Browse files Browse the repository at this point in the history
…ll only show these, rather than the entire final state.
  • Loading branch information
simondfoster committed Apr 12, 2024
1 parent dbae2a1 commit 9a498cb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion UTP/ITree_Procedure.ML
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ struct

fun mk_program evT (((n, p), st), body) ctx =
let open Syntax
val ty = (check_typ ctx (Type (@{type_abbrev htree}, [evT, read_typ ctx st])))
val stT = read_typ ctx st
val ty = (check_typ ctx (Type (@{type_abbrev ktree}, [evT, stT, dummyT])))
val pat = read_term ctx p
val vs = map (fst o dest_Free) (HOLogic.strip_tuple pat)
val pat' = HOLogic.mk_tuple (map free vs)
Expand Down
11 changes: 11 additions & 0 deletions UTP/VCG/ITree_VCG.thy
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ syntax
translations
"_lens_get_pretty x s" == "CONST lens_get x s"

(* Syntax to allow programs to exit returning a value *)

definition exit_prog :: "('a, 's) expr \<Rightarrow> 's \<Rightarrow> ('e, 'a) itree" where
"exit_prog e = (\<lambda> s. Ret (e s))"

syntax "_exit_prog" :: "logic \<Rightarrow> logic" ("exit _")
translations "exit e" == "CONST exit_prog (e)\<^sub>e"

lemma hl_exit [hoare_safe]: "\<forall> s. (P)\<^sub>e s \<longrightarrow> (Q)\<^sub>e (e s) \<Longrightarrow> H{P} exit e {Q}"
by (simp add: exit_prog_def hoare_alt_def)

(* Set up the program and procedure command *)

ML \<open>
Expand Down

0 comments on commit 9a498cb

Please sign in to comment.