(* Title: HOL/Bali/AxExample.thy Author: David von Oheimb *)
subsection‹Example of a proof based on the Bali axiomatic semantics›
theory AxExample imports AxSem Example begin
definition
arr_inv :: "st ==> bool"where "arr_inv = (λs. ∃obj a T el. globs s (Stat Base) = Some obj ∧ values obj (Inl (arr, Base)) = Some (Addr a) ∧ heap s a = Some (tag=Arr T 2,values=el))"
ML ‹ fun inst1_tac ctxt s t xs st = (case AList.lookup (op =) (rev (Term.add_var_names (Thm.prop_of st) [])) s of SOME i => PRIMITIVE (Rule_Insts.read_instantiate ctxt [(((s, i), Position.none), t)] xs) st | NONE => Seq.empty); fun ax_tac ctxt = REPEAT o resolve_tac ctxt [allI] THEN' resolve_tac ctxt @{thms ax_Skip ax_StatRef ax_MethdN ax_Alloc ax_Alloc_Arr ax_SXAlloc_Normal ax_derivs.intros(8-)}; ›
theorem ax_test: "tprg,({}::'a triple set)⊨ {Normal (λY s Z::'a. heap_free four s ∧¬initd Base s ∧¬ initd Ext s)} .test [Class Base]. {λY s Z. abrupt s = Some (Xcpt (Std IndOutBound))}" apply (unfold test_def arr_viewed_from_def) apply (tactic "ax_tac 🍋 1"(*;;*)) defer(* We begin with the last assertion, to synthesise the intermediate assertions, like in the fashion of the weakest precondition. *) apply (tactic "ax_tac 🍋 1"(* Try *)) defer apply (tactic ‹inst1_tac 🍋 "Q" "λY s Z. arr_inv (snd s) ∧ tprg,s⊨catch SXcpt NullPointer" []›) prefer 2 apply simp apply (rule_tac P' = "Normal (λY s Z. arr_inv (snd s))"in conseq1) prefer 2 apply clarsimp apply (rule_tac Q' = "(λY s Z. Q Y s Z)←=False↓=♢"and Q = Q for Q in conseq2) prefer 2 apply simp apply (tactic "ax_tac 🍋 1"(* While *)) prefer 2 apply (rule ax_impossible [THEN conseq1], clarsimp) apply (rule_tac P' = "Normal P"and P = P for P in conseq1) prefer 2 apply clarsimp apply (tactic "ax_tac 🍋 1") apply (tactic "ax_tac 🍋 1"(* AVar *)) prefer 2 apply (rule ax_subst_Val_allI) apply (tactic ‹inst1_tac 🍋 "P'" "λa. Normal (PP a←x)" ["PP", "x"]›) apply (simp del: avar_def2 peek_and_def2) apply (tactic "ax_tac 🍋 1") apply (tactic "ax_tac 🍋 1") (* just for clarification: *) apply (rule_tac Q' = "Normal (λVar:(v, f) u ua. fst (snd (avar tprg (Intg 2) v u)) = Some (Xcpt (Std IndOutBound)))"in conseq2) prefer 2 apply (clarsimp simp add: split_beta) apply (tactic "ax_tac 🍋 1"(* FVar *)) apply (tactic "ax_tac 🍋 2"(* StatRef *)) apply (rule ax_derivs.Done [THEN conseq1]) apply (clarsimp simp add: arr_inv_def inited_def in_bounds_def) defer apply (rule ax_SXAlloc_catch_SXcpt) apply (rule_tac Q' = "(λY (x, s) Z. x = Some (Xcpt (Std NullPointer)) ∧ arr_inv s) ∧. heap_free two"in conseq2) prefer 2 apply (simp add: arr_inv_new_obj) apply (tactic "ax_tac 🍋 1") apply (rule_tac C = "Ext"in ax_Call_known_DynT) apply (unfold DynT_prop_def) apply (simp (no_asm)) apply (intro strip) apply (rule_tac P' = "Normal P"and P = P for P in conseq1) apply (tactic "ax_tac 🍋 1"(* Methd *)) apply (rule ax_thin [OF _ empty_subsetI]) apply (simp (no_asm) add: body_def2) apply (tactic "ax_tac 🍋 1"(* Body *)) (* apply (rule_tac [2] ax_derivs.Abrupt) *) defer apply (simp (no_asm)) apply (tactic "ax_tac 🍋 1") (* Comp *) (* The first statement in the composition ((Ext)z).vee = 1; Return Null will throw an exception (since z is null). So we can handle Return Null with the Abrupt rule *) apply (rule_tac [2] ax_derivs.Abrupt)
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.