theory HS0Certificate = HS0:
defs
isMergePoint_def: "isMergePoint f == f \<in> {HeapSort'siftdown'f_13, HeapSort'siftdown'f_6}"
dominates_def: "dominates f == (if f = HeapSort'insert'f_1 then List.filter isMergePoint [HeapSort'insert'f_2, HeapSort'insert'f_3] else
                 if f = HeapSort'insert'f_insert then List.filter isMergePoint [HeapSort'insert'f_0, HeapSort'insert'f_1] else
                 if f = HeapSort'siftdown'f_12 then List.filter isMergePoint [HeapSort'siftdown'f_13, HeapSort'siftdown'f_14, HeapSort'siftdown'f_15] else
                 if f = HeapSort'siftdown'f_siftdown then List.filter isMergePoint [HeapSort'siftdown'f_0, HeapSort'siftdown'f_1] else
                 if f = HeapSort'siftdown'f_13 then List.filter isMergePoint [HeapSort'siftdown'f_18, HeapSort'siftdown'f_19] else
                 if f = HeapSort'siftdown'f_14 then List.filter isMergePoint [HeapSort'siftdown'f_16, HeapSort'siftdown'f_17] else
                 if f = HeapSort'siftdown'f_1 then List.filter isMergePoint [HeapSort'siftdown'f_2, HeapSort'siftdown'f_3] else
                 if f = HeapSort'siftdown'f_2 then List.filter isMergePoint [HeapSort'siftdown'f_4, HeapSort'siftdown'f_5] else
                 if f = HeapSort'siftdown'f_3 then List.filter isMergePoint [HeapSort'siftdown'f_6, HeapSort'siftdown'f_7, HeapSort'siftdown'f_8] else
                 if f = HeapSort'siftdown'f_6 then List.filter isMergePoint [HeapSort'siftdown'f_11, HeapSort'siftdown'f_12] else
                 if f = HeapSort'siftdown'f_7 then List.filter isMergePoint [HeapSort'siftdown'f_10, HeapSort'siftdown'f_9] else
                 if f = HeapSort'removesome'f_1 then List.filter isMergePoint [HeapSort'removesome'f_2, HeapSort'removesome'f_3] else
                 if f = HeapSort'removesome'f_removesome then List.filter isMergePoint [HeapSort'removesome'f_0, HeapSort'removesome'f_1] else
                 if f = HeapSort'removetop'f_1 then List.filter isMergePoint [HeapSort'removetop'f_2, HeapSort'removetop'f_3] else
                 if f = HeapSort'removetop'f_removetop then List.filter isMergePoint [HeapSort'removetop'f_0, HeapSort'removetop'f_1] else
                 if f = HeapSort'make_heap'f_make_heap then List.filter isMergePoint [HeapSort'make_heap'f_0, HeapSort'make_heap'f_1] else
                 if f = HeapSort'extract'f_extract then List.filter isMergePoint [HeapSort'extract'f_0, HeapSort'extract'f_1] else [])"
defs SPEC_def: " SPEC M == (
  if M = HeapSort'insert then \<lbrace> {HeapSort'insert't}, 1, (emptyfinmap(HeapSort'insert't \<mapsto>\<^sub>f(ItreeET 0 0))) \<ggreater> (ItreeET 0 0), 0\<rbrace>
 else
  if M = HeapSort'siftdown then \<lbrace> {HeapSort'siftdown't1, HeapSort'siftdown't2}, 1, (emptyfinmap(HeapSort'siftdown't1 \<mapsto>\<^sub>f(ItreeET 0 0))(HeapSort'siftdown't2 \<mapsto>\<^sub>f(ItreeET 0 0))) \<ggreater> (ItreeET 0 0), 0\<rbrace>
 else
  if M = HeapSort'removesome then \<lbrace> {HeapSort'removesome't}, 0, (emptyfinmap(HeapSort'removesome't \<mapsto>\<^sub>f(ItreeET 0 0))) \<ggreater> (IresultET 0 (ItreeET 0 0) 0), 0\<rbrace>
 else
  if M = HeapSort'removetop then \<lbrace> {HeapSort'removetop't}, 0, (emptyfinmap(HeapSort'removetop't \<mapsto>\<^sub>f(ItreeET 0 0))) \<ggreater> (IresultET 0 (ItreeET 0 0) 0), 0\<rbrace>
 else
  if M = HeapSort'make_heap then \<lbrace> {HeapSort'make_heap'l}, 0, (emptyfinmap(HeapSort'make_heap'l \<mapsto>\<^sub>f(IlistET 0 0))) \<ggreater> (ItreeET 0 0), 0\<rbrace>
 else
  if M = HeapSort'extract then \<lbrace> {HeapSort'extract'h}, 0, (emptyfinmap(HeapSort'extract'h \<mapsto>\<^sub>f(ItreeET 0 0))) \<ggreater> (IlistET 0 0), 0\<rbrace>
 else
  if M = HeapSort'sort then \<lbrace> {HeapSort'sort'l}, 0, (emptyfinmap(HeapSort'sort'l \<mapsto>\<^sub>f(IlistET 0 0))) \<ggreater> (IlistET 0 0), 0\<rbrace>
 else
  (\<lambda> E h hh v p . False))"
constdefs  Context:: vdmcontext
 " Context == {(HeapSort\<bullet>HeapSort'insert([INarg HeapSort'insert'x, RNarg HeapSort'insert'r2]), sMST HeapSort HeapSort'insert [INarg HeapSort'insert'x, RNarg HeapSort'insert'r2]) ,(HeapSort\<bullet>HeapSort'insert([INarg HeapSort'insert'v4, RNarg HeapSort'insert'r2]), sMST HeapSort HeapSort'insert [INarg HeapSort'insert'v4, RNarg HeapSort'insert'r2]) ,
(HeapSort\<bullet>HeapSort'siftdown([INarg HeapSort'siftdown'w, RNarg HeapSort'siftdown'r8, RNarg HeapSort'siftdown'r7]), sMST HeapSort HeapSort'siftdown [INarg HeapSort'siftdown'w, RNarg HeapSort'siftdown'r8, RNarg HeapSort'siftdown'r7]) ,(HeapSort\<bullet>HeapSort'siftdown([INarg HeapSort'siftdown'w, RNarg HeapSort'siftdown'r5, RNarg HeapSort'siftdown'r4]), sMST HeapSort HeapSort'siftdown [INarg HeapSort'siftdown'w, RNarg HeapSort'siftdown'r5, RNarg HeapSort'siftdown'r4]) ,
(HeapSort\<bullet>HeapSort'removesome([RNarg HeapSort'removesome'r1]), sMST HeapSort HeapSort'removesome [RNarg HeapSort'removesome'r1]) ,
(HeapSort\<bullet>HeapSort'siftdown([INarg HeapSort'removetop'v2, RNarg HeapSort'removetop'r3, RNarg HeapSort'removetop'r1]), sMST HeapSort HeapSort'siftdown [INarg HeapSort'removetop'v2, RNarg HeapSort'removetop'r3, RNarg HeapSort'removetop'r1]) ,(HeapSort\<bullet>HeapSort'removesome([RNarg HeapSort'removetop'r1]), sMST HeapSort HeapSort'removesome [RNarg HeapSort'removetop'r1]) ,
(HeapSort\<bullet>HeapSort'make_heap([RNarg HeapSort'make_heap'r1]), sMST HeapSort HeapSort'make_heap [RNarg HeapSort'make_heap'r1]) ,(HeapSort\<bullet>HeapSort'insert([INarg HeapSort'make_heap'v2, RNarg HeapSort'make_heap'l]), sMST HeapSort HeapSort'insert [INarg HeapSort'make_heap'v2, RNarg HeapSort'make_heap'l]) ,
(HeapSort\<bullet>HeapSort'extract([RNarg HeapSort'extract'r1]), sMST HeapSort HeapSort'extract [RNarg HeapSort'extract'r1]) ,(HeapSort\<bullet>HeapSort'removetop([RNarg HeapSort'extract'h]), sMST HeapSort HeapSort'removetop [RNarg HeapSort'extract'h]) ,
(HeapSort\<bullet>HeapSort'make_heap([RNarg HeapSort'sort'l]), sMST HeapSort HeapSort'make_heap [RNarg HeapSort'sort'l]) ,(HeapSort\<bullet>HeapSort'extract([RNarg HeapSort'sort'r1]), sMST HeapSort HeapSort'extract [RNarg HeapSort'sort'r1]) }" 
lemma Context_finite[simp]: "finite Context" by (simp add: Context_def)
lemmas dmp_defs = dominates_def isMergePoint_def
lemmas ctxt_def  = Context_def
lemmas meth_defs = SPEC_def Meth_HeapSort'insert Meth_HeapSort'siftdown Meth_HeapSort'removesome Meth_HeapSort'removetop Meth_HeapSort'make_heap Meth_HeapSort'extract Meth_HeapSort'sort
lemmas insert_pdefs = SPEC_def  Fun_HeapSort'insert'f_0 Fun_HeapSort'insert'f_1 Fun_HeapSort'insert'f_2 Fun_HeapSort'insert'f_3 Fun_HeapSort'insert'f_insert  Meth_HeapSort'insert 
lemmas siftdown_pdefs = SPEC_def  Fun_HeapSort'siftdown'f_0 Fun_HeapSort'siftdown'f_1 Fun_HeapSort'siftdown'f_10 Fun_HeapSort'siftdown'f_11 Fun_HeapSort'siftdown'f_12 Fun_HeapSort'siftdown'f_13 Fun_HeapSort'siftdown'f_14 Fun_HeapSort'siftdown'f_15 Fun_HeapSort'siftdown'f_16 Fun_HeapSort'siftdown'f_17 Fun_HeapSort'siftdown'f_18 Fun_HeapSort'siftdown'f_19 Fun_HeapSort'siftdown'f_2 Fun_HeapSort'siftdown'f_3 Fun_HeapSort'siftdown'f_4 Fun_HeapSort'siftdown'f_5 Fun_HeapSort'siftdown'f_6 Fun_HeapSort'siftdown'f_7 Fun_HeapSort'siftdown'f_8 Fun_HeapSort'siftdown'f_9 Fun_HeapSort'siftdown'f_siftdown  Meth_HeapSort'siftdown 
lemmas removesome_pdefs = SPEC_def  Fun_HeapSort'removesome'f_0 Fun_HeapSort'removesome'f_1 Fun_HeapSort'removesome'f_2 Fun_HeapSort'removesome'f_3 Fun_HeapSort'removesome'f_removesome  Meth_HeapSort'removesome 
lemmas removetop_pdefs = SPEC_def  Fun_HeapSort'removetop'f_0 Fun_HeapSort'removetop'f_1 Fun_HeapSort'removetop'f_2 Fun_HeapSort'removetop'f_3 Fun_HeapSort'removetop'f_removetop  Meth_HeapSort'removesome Meth_HeapSort'removetop Meth_HeapSort'siftdown 
lemmas make_heap_pdefs = SPEC_def  Fun_HeapSort'make_heap'f_0 Fun_HeapSort'make_heap'f_1 Fun_HeapSort'make_heap'f_make_heap  Meth_HeapSort'insert Meth_HeapSort'make_heap 
lemmas extract_pdefs = SPEC_def  Fun_HeapSort'extract'f_0 Fun_HeapSort'extract'f_1 Fun_HeapSort'extract'f_extract  Meth_HeapSort'extract Meth_HeapSort'removetop 
lemmas sort_pdefs = SPEC_def  Fun_HeapSort'sort'f_sort  Meth_HeapSort'extract Meth_HeapSort'make_heap Meth_HeapSort'sort 

lemmas fun_defs = sort_pdefs extract_pdefs make_heap_pdefs removetop_pdefs removesome_pdefs siftdown_pdefs insert_pdefs 

(* 
 insert :: \<lbrace> {HeapSort'insert't}, 1, (emptyfinmap(HeapSort'insert't \<mapsto>\<^sub>f(ItreeET 0 0))) \<ggreater> (ItreeET 0 0), 0\<rbrace>

 siftdown :: \<lbrace> {HeapSort'siftdown't1, HeapSort'siftdown't2}, 1, (emptyfinmap(HeapSort'siftdown't1 \<mapsto>\<^sub>f(ItreeET 0 0))(HeapSort'siftdown't2 \<mapsto>\<^sub>f(ItreeET 0 0))) \<ggreater> (ItreeET 0 0), 0\<rbrace>

 removesome :: \<lbrace> {HeapSort'removesome't}, 0, (emptyfinmap(HeapSort'removesome't \<mapsto>\<^sub>f(ItreeET 0 0))) \<ggreater> (IresultET 0 (ItreeET 0 0) 0), 0\<rbrace>

 removetop :: \<lbrace> {HeapSort'removetop't}, 0, (emptyfinmap(HeapSort'removetop't \<mapsto>\<^sub>f(ItreeET 0 0))) \<ggreater> (IresultET 0 (ItreeET 0 0) 0), 0\<rbrace>

 make_heap :: \<lbrace> {HeapSort'make_heap'l}, 0, (emptyfinmap(HeapSort'make_heap'l \<mapsto>\<^sub>f(IlistET 0 0))) \<ggreater> (ItreeET 0 0), 0\<rbrace>

 extract :: \<lbrace> {HeapSort'extract'h}, 0, (emptyfinmap(HeapSort'extract'h \<mapsto>\<^sub>f(ItreeET 0 0))) \<ggreater> (IlistET 0 0), 0\<rbrace>

 sort :: \<lbrace> {HeapSort'sort'l}, 0, (emptyfinmap(HeapSort'sort'l \<mapsto>\<^sub>f(IlistET 0 0))) \<ggreater> (IlistET 0 0), 0\<rbrace>

*)

ML {* 
 val global_v_insert = 3
 val global_v_siftdown = 3
 val global_v_removesome = 3
 val global_v_removetop = 3
 val global_v_make_heap = 3
 val global_v_extract = 3
 val global_v_sort = 3
*}

end
