Up to index of Isabelle/HOL/HOL-IMP
theory Procs_Dyn_Vars_Dyntheory Procs_Dyn_Vars_Dyn imports Procs
begin
subsubsection "Dynamic Scoping of Procedures and Variables"
type_synonym penv = "pname => com"
inductive
big_step :: "penv => com × state => state => bool" ("_ \<turnstile> _ => _" [60,0,60] 55)
where
Skip: "pe \<turnstile> (SKIP,s) => s" |
Assign: "pe \<turnstile> (x ::= a,s) => s(x := aval a s)" |
Seq: "[| pe \<turnstile> (c⇣1,s⇣1) => s⇣2; pe \<turnstile> (c⇣2,s⇣2) => s⇣3 |] ==>
pe \<turnstile> (c⇣1;c⇣2, s⇣1) => s⇣3" |
IfTrue: "[| bval b s; pe \<turnstile> (c⇣1,s) => t |] ==>
pe \<turnstile> (IF b THEN c⇣1 ELSE c⇣2, s) => t" |
IfFalse: "[| ¬bval b s; pe \<turnstile> (c⇣2,s) => t |] ==>
pe \<turnstile> (IF b THEN c⇣1 ELSE c⇣2, s) => t" |
WhileFalse: "¬bval b s ==> pe \<turnstile> (WHILE b DO c,s) => s" |
WhileTrue:
"[| bval b s⇣1; pe \<turnstile> (c,s⇣1) => s⇣2; pe \<turnstile> (WHILE b DO c, s⇣2) => s⇣3 |] ==>
pe \<turnstile> (WHILE b DO c, s⇣1) => s⇣3" |
Var: "pe \<turnstile> (c,s) => t ==> pe \<turnstile> ({VAR x;; c}, s) => t(x := s x)" |
Call: "pe \<turnstile> (pe p, s) => t ==> pe \<turnstile> (CALL p, s) => t" |
Proc: "pe(p := cp) \<turnstile> (c,s) => t ==> pe \<turnstile> ({PROC p = cp;; c}, s) => t"
code_pred big_step .
values "{map t [''x'',''y'',''z''] |t.
(λp. SKIP) \<turnstile> (CALL ''p'', <''x'' := 42, ''y'' := 43>) => t}"
values "{map t [''x'',''y'',''z''] |t. (λp. SKIP) \<turnstile> (test_com, <>) => t}"
end