src/HOL/IMP/Procs_Dyn_Vars_Dyn.thy
author nipkow
Sat, 28 Apr 2012 07:38:22 +0200
changeset 47818 151d137f1095
parent 45212 e87feee00a4c
child 51019 146f63c3f024
permissions -rw-r--r--
renamed Semi to Seq
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
44177
b4b5cbca2519 IMP/Util distinguishes between sets and functions again; imported only where used.
kleing
parents: 43158
diff changeset
     1
theory Procs_Dyn_Vars_Dyn imports Procs
43158
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
     2
begin
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
     3
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
     4
subsubsection "Dynamic Scoping of Procedures and Variables"
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
     5
45212
e87feee00a4c renamed name -> vname
nipkow
parents: 44923
diff changeset
     6
type_synonym penv = "pname \<Rightarrow> com"
43158
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
     7
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
     8
inductive
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
     9
  big_step :: "penv \<Rightarrow> com \<times> state \<Rightarrow> state \<Rightarrow> bool" ("_ \<turnstile> _ \<Rightarrow> _" [60,0,60] 55)
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    10
where
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    11
Skip:    "pe \<turnstile> (SKIP,s) \<Rightarrow> s" |
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    12
Assign:  "pe \<turnstile> (x ::= a,s) \<Rightarrow> s(x := aval a s)" |
47818
151d137f1095 renamed Semi to Seq
nipkow
parents: 45212
diff changeset
    13
Seq:     "\<lbrakk> pe \<turnstile> (c\<^isub>1,s\<^isub>1) \<Rightarrow> s\<^isub>2;  pe \<turnstile> (c\<^isub>2,s\<^isub>2) \<Rightarrow> s\<^isub>3 \<rbrakk> \<Longrightarrow>
43158
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    14
          pe \<turnstile> (c\<^isub>1;c\<^isub>2, s\<^isub>1) \<Rightarrow> s\<^isub>3" |
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    15
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    16
IfTrue:  "\<lbrakk> bval b s;  pe \<turnstile> (c\<^isub>1,s) \<Rightarrow> t \<rbrakk> \<Longrightarrow>
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    17
         pe \<turnstile> (IF b THEN c\<^isub>1 ELSE c\<^isub>2, s) \<Rightarrow> t" |
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    18
IfFalse: "\<lbrakk> \<not>bval b s;  pe \<turnstile> (c\<^isub>2,s) \<Rightarrow> t \<rbrakk> \<Longrightarrow>
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    19
         pe \<turnstile> (IF b THEN c\<^isub>1 ELSE c\<^isub>2, s) \<Rightarrow> t" |
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    20
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    21
WhileFalse: "\<not>bval b s \<Longrightarrow> pe \<turnstile> (WHILE b DO c,s) \<Rightarrow> s" |
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    22
WhileTrue:
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    23
  "\<lbrakk> bval b s\<^isub>1;  pe \<turnstile> (c,s\<^isub>1) \<Rightarrow> s\<^isub>2;  pe \<turnstile> (WHILE b DO c, s\<^isub>2) \<Rightarrow> s\<^isub>3 \<rbrakk> \<Longrightarrow>
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    24
   pe \<turnstile> (WHILE b DO c, s\<^isub>1) \<Rightarrow> s\<^isub>3" |
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    25
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    26
Var: "pe \<turnstile> (c,s) \<Rightarrow> t  \<Longrightarrow>  pe \<turnstile> ({VAR x;; c}, s) \<Rightarrow> t(x := s x)" |
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    27
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    28
Call: "pe \<turnstile> (pe p, s) \<Rightarrow> t  \<Longrightarrow>  pe \<turnstile> (CALL p, s) \<Rightarrow> t" |
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    29
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    30
Proc: "pe(p := cp) \<turnstile> (c,s) \<Rightarrow> t  \<Longrightarrow>  pe \<turnstile> ({PROC p = cp;; c}, s) \<Rightarrow> t"
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    31
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    32
code_pred big_step .
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    33
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    34
values "{map t [''x'',''y'',''z''] |t. 
44923
b80108b346a9 cleand up AbsInt fixpoint iteration; tuned syntax
nipkow
parents: 44177
diff changeset
    35
          (\<lambda>p. SKIP) \<turnstile> (CALL ''p'', <''x'' := 42, ''y'' := 43>) \<Rightarrow> t}"
43158
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    36
44923
b80108b346a9 cleand up AbsInt fixpoint iteration; tuned syntax
nipkow
parents: 44177
diff changeset
    37
values "{map t [''x'',''y'',''z''] |t. (\<lambda>p. SKIP) \<turnstile> (test_com, <>) \<Rightarrow> t}"
43158
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    38
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    39
end