diff --git a/lib/Heap_List.thy b/lib/Heap_List.thy index 80aabd2d2..e8bae311d 100644 --- a/lib/Heap_List.thy +++ b/lib/Heap_List.thy @@ -172,6 +172,38 @@ lemma sym_heap_symmetric: lemma sym_heap_None: "\sym_heap hp hp'; hp p = None\ \ \p'. hp' p' \ Some p" unfolding sym_heap_def by force +lemma sym_heap_remove_only: + "\sym_heap hp hp'; hp' y = Some x\ \ sym_heap (hp(x := None)) (hp'(y := None))" + apply (clarsimp simp: sym_heap_def) + apply (metis option.inject) + done + +lemma sym_heap_remove_only': + "\sym_heap hp hp'; hp y = Some x\ \ sym_heap (hp(y := None)) (hp'(x := None))" + apply (clarsimp simp: sym_heap_def) + apply (metis option.inject) + done + +lemma sym_heap_remove_middle_from_chain: + "\sym_heap hp hp'; before \ middle; middle \ after; + hp before = Some middle; hp middle = Some after\ + \ sym_heap (hp(before := Some after, middle := None)) + (hp'(after := Some before, middle := None))" + apply (clarsimp simp: sym_heap_def) + apply (metis option.simps(1)) + done + +lemma sym_heap_connect: + "\sym_heap hp hp'; hp a = None; hp' b = None \ \ sym_heap (hp(a \ b)) (hp'(b \ a))" + by (force simp: sym_heap_def) + +lemma sym_heap_insert_into_middle_of_chain: + "\sym_heap hp hp'; hp before = Some after; hp middle = None; hp' middle = None\ + \ sym_heap (hp(before \ middle, middle \ after)) (hp'(after \ middle, middle \ before))" + apply (clarsimp simp: sym_heap_def) + apply (metis option.simps) + done + lemma sym_heap_path_reverse: "sym_heap hp hp' \ heap_path hp (Some p) (p#ps) (Some p')