src/HOL/Hoare/Separation.thy
author haftmann
Fri, 17 Jun 2005 16:12:49 +0200
changeset 16417 9bc16273c2d4
parent 14074 93dfce3b6f86
child 17781 32bb237158a5
permissions -rw-r--r--
migrated theory headers to new format
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13903
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
     1
(*  Title:      HOL/Hoare/Separation.thy
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
     2
    ID:         $Id$
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
     3
    Author:     Tobias Nipkow
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
     4
    Copyright   2003 TUM
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
     5
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
     6
A first attempt at a nice syntactic embedding of separation logic.
14074
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
     7
Already builds on the theory for list abstractions.
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
     8
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
     9
If we suppress the H parameter for "List", we have to hardwired this
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
    10
into parser and pretty printer, which is not very modular.
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
    11
Alternative: some syntax like <P> which stands for P H. No more
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
    12
compact, but avoids the funny H.
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
    13
13903
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
    14
*)
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
    15
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 14074
diff changeset
    16
theory Separation imports HoareAbort SepLogHeap begin
13857
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    17
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    18
text{* The semantic definition of a few connectives: *}
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    19
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    20
constdefs
13875
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    21
 ortho:: "heap \<Rightarrow> heap \<Rightarrow> bool" (infix "\<bottom>" 55)
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    22
"h1 \<bottom> h2 == dom h1 \<inter> dom h2 = {}"
13857
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    23
13875
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    24
 is_empty :: "heap \<Rightarrow> bool"
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    25
"is_empty h == h = empty"
13857
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    26
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    27
 singl:: "heap \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> bool"
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    28
"singl h x y == dom h = {x} & h x = Some y"
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    29
13875
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    30
 star:: "(heap \<Rightarrow> bool) \<Rightarrow> (heap \<Rightarrow> bool) \<Rightarrow> (heap \<Rightarrow> bool)"
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    31
"star P Q == \<lambda>h. \<exists>h1 h2. h = h1++h2 \<and> h1 \<bottom> h2 \<and> P h1 \<and> Q h2"
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    32
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    33
 wand:: "(heap \<Rightarrow> bool) \<Rightarrow> (heap \<Rightarrow> bool) \<Rightarrow> (heap \<Rightarrow> bool)"
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    34
"wand P Q == \<lambda>h. \<forall>h'. h' \<bottom> h \<and> P h' \<longrightarrow> Q(h++h')"
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    35
13903
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
    36
text{*This is what assertions look like without any syntactic sugar: *}
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
    37
13857
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    38
lemma "VARS x y z w h
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    39
 {star (%h. singl h x y) (%h. singl h z w) h}
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    40
 SKIP
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    41
 {x \<noteq> z}"
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    42
apply vcg
13875
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    43
apply(auto simp:star_def ortho_def singl_def)
13857
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    44
done
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    45
13903
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
    46
text{* Now we add nice input syntax.  To suppress the heap parameter
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
    47
of the connectives, we assume it is always called H and add/remove it
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
    48
upon parsing/printing. Thus every pointer program needs to have a
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
    49
program variable H, and assertions should not contain any locally
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
    50
bound Hs - otherwise they may bind the implicit H. *}
13857
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    51
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    52
syntax
13875
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    53
 "@emp" :: "bool" ("emp")
13857
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    54
 "@singl" :: "nat \<Rightarrow> nat \<Rightarrow> bool" ("[_ \<mapsto> _]")
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    55
 "@star" :: "bool \<Rightarrow> bool \<Rightarrow> bool" (infixl "**" 60)
13903
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
    56
 "@wand" :: "bool \<Rightarrow> bool \<Rightarrow> bool" (infixl "-*" 60)
13857
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    57
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    58
ML{*
13875
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    59
(* free_tr takes care of free vars in the scope of sep. logic connectives:
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    60
   they are implicitly applied to the heap *)
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    61
fun free_tr(t as Free _) = t $ Syntax.free "H"
14074
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
    62
(*
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
    63
  | free_tr((list as Free("List",_))$ p $ ps) = list $ Syntax.free "H" $ p $ ps
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
    64
*)
13875
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    65
  | free_tr t = t
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    66
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    67
fun emp_tr [] = Syntax.const "is_empty" $ Syntax.free "H"
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    68
  | emp_tr ts = raise TERM ("emp_tr", ts);
13857
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    69
fun singl_tr [p,q] = Syntax.const "singl" $ Syntax.free "H" $ p $ q
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    70
  | singl_tr ts = raise TERM ("singl_tr", ts);
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    71
fun star_tr [P,Q] = Syntax.const "star" $
13875
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    72
      absfree("H",dummyT,free_tr P) $ absfree("H",dummyT,free_tr Q) $
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    73
      Syntax.free "H"
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    74
  | star_tr ts = raise TERM ("star_tr", ts);
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    75
fun wand_tr [P,Q] = Syntax.const "wand" $
13857
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    76
      absfree("H",dummyT,P) $ absfree("H",dummyT,Q) $ Syntax.free "H"
13875
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    77
  | wand_tr ts = raise TERM ("wand_tr", ts);
13857
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    78
*}
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    79
13875
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    80
parse_translation
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    81
 {* [("@emp", emp_tr), ("@singl", singl_tr),
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    82
     ("@star", star_tr), ("@wand", wand_tr)] *}
13857
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    83
13903
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
    84
text{* Now it looks much better: *}
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
    85
13857
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    86
lemma "VARS H x y z w
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    87
 {[x\<mapsto>y] ** [z\<mapsto>w]}
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    88
 SKIP
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    89
 {x \<noteq> z}"
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
    90
apply vcg
13875
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    91
apply(auto simp:star_def ortho_def singl_def)
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    92
done
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    93
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    94
lemma "VARS H x y z w
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    95
 {emp ** emp}
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    96
 SKIP
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    97
 {emp}"
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    98
apply vcg
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
    99
apply(auto simp:star_def ortho_def is_empty_def)
13857
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
   100
done
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
   101
13903
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
   102
text{* But the output is still unreadable. Thus we also strip the heap
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
   103
parameters upon output: *}
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
   104
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
   105
(* debugging code:
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
   106
fun sot(Free(s,_)) = s
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
   107
  | sot(Var((s,i),_)) = "?" ^ s ^ string_of_int i
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
   108
  | sot(Const(s,_)) = s
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
   109
  | sot(Bound i) = "B." ^ string_of_int i
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
   110
  | sot(s $ t) = "(" ^ sot s ^ " " ^ sot t ^ ")"
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
   111
  | sot(Abs(_,_,t)) = "(% " ^ sot t ^ ")";
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
   112
*)
13857
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
   113
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
   114
ML{*
13875
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   115
local
13903
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
   116
fun strip (Abs(_,_,(t as Const("_free",_) $ Free _) $ Bound 0)) = t
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
   117
  | strip (Abs(_,_,(t as Free _) $ Bound 0)) = t
14074
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   118
(*
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   119
  | strip (Abs(_,_,((list as Const("List",_))$ Bound 0 $ p $ ps))) = list$p$ps
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   120
*)
13903
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
   121
  | strip (Abs(_,_,(t as Const("_var",_) $ Var _) $ Bound 0)) = t
13875
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   122
  | strip (Abs(_,_,P)) = P
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   123
  | strip (Const("is_empty",_)) = Syntax.const "@emp"
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   124
  | strip t = t;
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   125
in
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   126
fun is_empty_tr' [_] = Syntax.const "@emp"
13857
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
   127
fun singl_tr' [_,p,q] = Syntax.const "@singl" $ p $ q
13875
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   128
fun star_tr' [P,Q,_] = Syntax.const "@star" $ strip P $ strip Q
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   129
fun wand_tr' [P,Q,_] = Syntax.const "@wand" $ strip P $ strip Q
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   130
end
13857
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
   131
*}
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
   132
13875
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   133
print_translation
13903
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
   134
 {* [("is_empty", is_empty_tr'),("singl", singl_tr'),
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
   135
     ("star", star_tr'),("wand", wand_tr')] *}
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
   136
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
   137
text{* Now the intermediate proof states are also readable: *}
13857
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
   138
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
   139
lemma "VARS H x y z w
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
   140
 {[x\<mapsto>y] ** [z\<mapsto>w]}
13867
1fdecd15437f just a few mods to a few thms
nipkow
parents: 13857
diff changeset
   141
 y := w
13857
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
   142
 {x \<noteq> z}"
11d7c5a8dbb7 *** empty log message ***
nipkow
parents:
diff changeset
   143
apply vcg
13875
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   144
apply(auto simp:star_def ortho_def singl_def)
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   145
done
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   146
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   147
lemma "VARS H x y z w
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   148
 {emp ** emp}
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   149
 SKIP
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   150
 {emp}"
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   151
apply vcg
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   152
apply(auto simp:star_def ortho_def is_empty_def)
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   153
done
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   154
13903
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
   155
text{* So far we have unfolded the separation logic connectives in
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
   156
proofs. Here comes a simple example of a program proof that uses a law
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
   157
of separation logic instead. *}
ad1c28671a93 First working version
nipkow
parents: 13875
diff changeset
   158
13875
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   159
(* a law of separation logic *)
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   160
lemma star_comm: "P ** Q = Q ** P"
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   161
apply(simp add:star_def ortho_def)
14028
ff6eb32b30a1 eparation logic - a beginning.
nipkow
parents: 13903
diff changeset
   162
apply(blast intro:map_add_comm)
13875
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   163
done
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   164
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   165
lemma "VARS H x y z w
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   166
 {P ** Q}
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   167
 SKIP
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   168
 {Q ** P}"
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   169
apply vcg
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   170
apply(simp add: star_comm)
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   171
done
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   172
14074
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   173
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   174
lemma "VARS H
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   175
 {p\<noteq>0 \<and> [p \<mapsto> x] ** List H q qs}
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   176
 H := H(p \<mapsto> q)
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   177
 {List H p (p#qs)}"
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   178
apply vcg
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   179
apply(simp add: star_def ortho_def singl_def)
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   180
apply clarify
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   181
apply(subgoal_tac "p \<notin> set qs")
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   182
 prefer 2
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   183
 apply(blast dest:list_in_heap)
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   184
apply simp
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   185
done
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   186
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   187
lemma "VARS H p q r
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   188
  {List H p Ps ** List H q Qs}
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   189
  WHILE p \<noteq> 0
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   190
  INV {\<exists>ps qs. (List H p ps ** List H q qs) \<and> rev ps @ qs = rev Ps @ Qs}
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   191
  DO r := p; p := the(H p); H := H(r \<mapsto> q); q := r OD
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   192
  {List H q (rev Ps @ Qs)}"
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   193
apply vcg
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   194
apply(simp_all add: star_def ortho_def singl_def)
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   195
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   196
apply fastsimp
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   197
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   198
apply (clarsimp simp add:List_non_null)
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   199
apply(rename_tac ps')
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   200
apply(rule_tac x = ps' in exI)
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   201
apply(rule_tac x = "p#qs" in exI)
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   202
apply simp
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   203
apply(rule_tac x = "h1(p:=None)" in exI)
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   204
apply(rule_tac x = "h2(p\<mapsto>q)" in exI)
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   205
apply simp
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   206
apply(rule conjI)
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   207
 apply(rule ext)
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   208
 apply(simp add:map_add_def split:option.split)
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   209
apply(rule conjI)
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   210
 apply blast
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   211
apply(simp add:map_add_def split:option.split)
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   212
apply(rule conjI)
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   213
apply(subgoal_tac "p \<notin> set qs")
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   214
 prefer 2
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   215
 apply(blast dest:list_in_heap)
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   216
apply(simp)
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   217
apply fast
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   218
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   219
apply(fastsimp)
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   220
done
93dfce3b6f86 *** empty log message ***
nipkow
parents: 14028
diff changeset
   221
13875
12997e3ddd8d *** empty log message ***
nipkow
parents: 13867
diff changeset
   222
end