src/HOL/IMP/Procs_Stat_Vars_Stat.thy
author wenzelm
Sat, 07 Apr 2012 16:41:59 +0200
changeset 47389 e8552cba702d
parent 45212 e87feee00a4c
child 47818 151d137f1095
permissions -rw-r--r--
explicit checks stable_finished_theory/stable_command allow parallel asynchronous command transactions; tuned;
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_Stat_Vars_Stat 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 "Static Scoping of Procedures and Variables"
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
     5
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
     6
type_synonym addr = nat
45212
e87feee00a4c renamed name -> vname
nipkow
parents: 44923
diff changeset
     7
type_synonym venv = "vname \<Rightarrow> addr"
43158
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
     8
type_synonym store = "addr \<Rightarrow> val"
45212
e87feee00a4c renamed name -> vname
nipkow
parents: 44923
diff changeset
     9
type_synonym penv = "(pname \<times> com \<times> venv) list"
43158
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    10
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    11
fun venv :: "penv \<times> venv \<times> nat \<Rightarrow> venv" where
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    12
"venv(_,ve,_) = ve"
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    13
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    14
inductive
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    15
  big_step :: "penv \<times> venv \<times> nat \<Rightarrow> com \<times> store \<Rightarrow> store \<Rightarrow> bool"
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    16
  ("_ \<turnstile> _ \<Rightarrow> _" [60,0,60] 55)
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    17
where
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    18
Skip:    "e \<turnstile> (SKIP,s) \<Rightarrow> s" |
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    19
Assign:  "(pe,ve,f) \<turnstile> (x ::= a,s) \<Rightarrow> s(ve x := aval a (s o ve))" |
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    20
Semi:    "\<lbrakk> e \<turnstile> (c\<^isub>1,s\<^isub>1) \<Rightarrow> s\<^isub>2;  e \<turnstile> (c\<^isub>2,s\<^isub>2) \<Rightarrow> s\<^isub>3 \<rbrakk> \<Longrightarrow>
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    21
          e \<turnstile> (c\<^isub>1;c\<^isub>2, s\<^isub>1) \<Rightarrow> s\<^isub>3" |
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    22
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    23
IfTrue:  "\<lbrakk> bval b (s \<circ> venv e);  e \<turnstile> (c\<^isub>1,s) \<Rightarrow> t \<rbrakk> \<Longrightarrow>
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    24
         e \<turnstile> (IF b THEN c\<^isub>1 ELSE c\<^isub>2, s) \<Rightarrow> t" |
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    25
IfFalse: "\<lbrakk> \<not>bval b (s \<circ> venv e);  e \<turnstile> (c\<^isub>2,s) \<Rightarrow> t \<rbrakk> \<Longrightarrow>
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    26
         e \<turnstile> (IF b THEN c\<^isub>1 ELSE c\<^isub>2, s) \<Rightarrow> t" |
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    27
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    28
WhileFalse: "\<not>bval b (s \<circ> venv e) \<Longrightarrow> e \<turnstile> (WHILE b DO c,s) \<Rightarrow> s" |
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    29
WhileTrue:
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    30
  "\<lbrakk> bval b (s\<^isub>1 \<circ> venv e);  e \<turnstile> (c,s\<^isub>1) \<Rightarrow> s\<^isub>2;
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    31
     e \<turnstile> (WHILE b DO c, s\<^isub>2) \<Rightarrow> s\<^isub>3 \<rbrakk> \<Longrightarrow>
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    32
   e \<turnstile> (WHILE b DO c, s\<^isub>1) \<Rightarrow> s\<^isub>3" |
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    33
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    34
Var: "(pe,ve(x:=f),f+1) \<turnstile> (c,s) \<Rightarrow> t  \<Longrightarrow>
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    35
      (pe,ve,f) \<turnstile> ({VAR x;; c}, s) \<Rightarrow> t(f := s f)" |
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    36
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    37
Call1: "((p,c,ve)#pe,ve,f) \<turnstile> (c, s) \<Rightarrow> t  \<Longrightarrow>
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    38
        ((p,c,ve)#pe,ve',f) \<turnstile> (CALL p, s) \<Rightarrow> t" |
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    39
Call2: "\<lbrakk> p' \<noteq> p;  (pe,ve,f) \<turnstile> (CALL p, s) \<Rightarrow> t \<rbrakk> \<Longrightarrow>
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    40
       ((p',c,ve')#pe,ve,f) \<turnstile> (CALL p, s) \<Rightarrow> t" |
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    41
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    42
Proc: "((p,cp,ve)#pe,ve,f) \<turnstile> (c,s) \<Rightarrow> t
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    43
      \<Longrightarrow>  (pe,ve,f) \<turnstile> ({PROC p = cp;; c}, s) \<Rightarrow> t"
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    44
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    45
code_pred big_step .
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    46
44923
b80108b346a9 cleand up AbsInt fixpoint iteration; tuned syntax
nipkow
parents: 44177
diff changeset
    47
b80108b346a9 cleand up AbsInt fixpoint iteration; tuned syntax
nipkow
parents: 44177
diff changeset
    48
values "{map t [0,1] |t. ([], <>, 0) \<turnstile> (CALL ''p'', nth [42, 43]) \<Rightarrow> t}"
43158
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    49
44923
b80108b346a9 cleand up AbsInt fixpoint iteration; tuned syntax
nipkow
parents: 44177
diff changeset
    50
values "{map t [0, 1, 2] |t.
b80108b346a9 cleand up AbsInt fixpoint iteration; tuned syntax
nipkow
parents: 44177
diff changeset
    51
  ([], <''x'' := 0, ''y'' := 1,''z'' := 2>, 0)
b80108b346a9 cleand up AbsInt fixpoint iteration; tuned syntax
nipkow
parents: 44177
diff changeset
    52
  \<turnstile> (test_com, <>) \<Rightarrow> t}"
43158
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    53
686fa0a0696e imported rest of new IMP
kleing
parents:
diff changeset
    54
end