definition wand:: "(heap → bool) → (heap → bool) → (heap → bool)" where"wand P Q = (λh. ∀h'. h' ⊥ h ∧ P h' ⟶ Q(h++h'))"
text‹This is what assertions look like without any syntactic sugar:›
lemma"VARS x y z w h {star (%h. singl h x y) (%h. singl h z w) h} SKIP {x ≠ z}" apply vcg apply(auto simp:star_def ortho_def singl_def) done
text‹Now we add nice input syntax. To suppress the heap parameter
the connectives, we assume it is always called H and add/remove it
parsing/printing. Thus every pointer program needs to have a
variable H, and assertions should not contain any locally
Hs - otherwise they may bind the implicit H.›
syntax_consts "_emp"⇌ is_empty and "_singl"⇌ singl and "_star"⇌ star and "_wand"⇌ wand
(* FIXME does not handle "_idtdummy" *)
ML ‹ ―‹‹free_tr› takes care of free vars in the scope of separation logic connectives:
they are implicitly applied to the heap›
free_tr(t as Free _) = t $ Syntax.free "H" 🚫‹| free_tr((list as Free("List",_))$ p $ ps) = list $ Syntax.free "H" $ p $ ps›
| free_tr t = t
parse_translation‹
[(syntax_const‹_emp›, K emp_tr),
(syntax_const‹_singl›, K singl_tr),
(syntax_const‹_star›, K star_tr),
(syntax_const‹_wand›, K wand_tr)] ›
text‹Now it looks much better:›
lemma"VARS H x y z w {[x↦y] ** [z↦w]} SKIP {x ≠ z}" apply vcg apply(auto simp:star_def ortho_def singl_def) done
lemma"VARS H x y z w {emp ** emp} SKIP {emp}" apply vcg apply(auto simp:star_def ortho_def is_empty_def) done
text‹But the output is still unreadable. Thus we also strip the heap
upon output:›
ML ‹
strip (Abs(_,_,(t as Const("_free",_) $ Free _) $ Bound 0)) = t
| strip (Abs(_,_,(t as Free _) $ Bound 0)) = t 🚫‹| strip (Abs(_,_,((list as Const("List",_))$ Bound 0 $ p $ ps))) = list$p$ps›
| strip (Abs(_,_,(t as Const("_var",_) $ Var _) $ Bound 0)) = t
| strip (Abs(_,_,P)) = P
| strip (Const(const_syntax‹is_empty›,_)) = Syntax.const syntax_const‹_emp›
| strip t = t;
print_translation‹
[(const_syntax‹is_empty›, K is_empty_tr'),
(const_syntax‹singl›, K singl_tr'),
(const_syntax‹star›, K star_tr'),
(const_syntax‹wand›, K wand_tr')] ›
text‹Now the intermediate proof states are also readable:›
lemma"VARS H x y z w {[x↦y] ** [z↦w]} y := w {x ≠ z}" apply vcg apply(auto simp:star_def ortho_def singl_def) done
lemma"VARS H x y z w {emp ** emp} SKIP {emp}" apply vcg apply(auto simp:star_def ortho_def is_empty_def) done
text‹So far we have unfolded the separation logic connectives in
. Here comes a simple example of a program proof that uses a law
separation logic instead.›
―‹a law of separation logic› lemma star_comm: "P ** Q = Q ** P" by(auto simp add:star_def ortho_def dest: map_add_comm)
lemma"VARS H x y z w {P ** Q} SKIP {Q ** P}" apply vcg apply(simp add: star_comm) done
lemma"VARS H {p≠0 ∧ [p ↦ x] ** List H q qs} H := H(p ↦ q) {List H p (p#qs)}" apply vcg apply(simp add: star_def ortho_def singl_def) apply clarify apply(subgoal_tac "p ∉ set qs") prefer2 apply(blast dest:list_in_heap) apply simp done
lemma"VARS H p q r {List H p Ps ** List H q Qs} WHILE p ≠ 0 INV {∃ps qs. (List H p ps ** List H q qs) ∧ rev ps @ qs = rev Ps @ Qs} DO r := p; p := the(H p); H := H(r ↦ q); q := r OD {List H q (rev Ps @ Qs)}" apply vcg apply(simp_all add: star_def ortho_def singl_def)
apply fastforce
apply (clarsimp simp add:List_non_null) apply(rename_tac ps') apply(rule_tac x = ps' in exI) apply(rule_tac x = "p#qs"in exI) apply simp apply(rule_tac x = "h1(p:=None)"in exI) apply(rule_tac x = "h2(p↦q)"in exI) apply simp apply(rule conjI) apply(rule ext) apply(simp add:map_add_def split:option.split) apply(rule conjI) apply blast apply(simp add:map_add_def split:option.split) apply(rule conjI) apply(subgoal_tac "p ∉ set qs") prefer2 apply(blast dest:list_in_heap) apply(simp) apply fast
apply(fastforce) done
end
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-06-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.