(* Title: HOL/NanoJava/Equivalence.thy Author: David von Oheimb Copyright 2001 Technische Universitaet Muenchen *)
section"Equivalence of Operational and Axiomatic Semantics"
theory Equivalence imports OpSem AxSem begin
subsection"Validity"
definition valid :: "[assn,stmt, assn] => bool" (‹⊨ {(1_)}/ (_)/ {(1_)}› [3,90,3] 60) where "⊨ {P} c {Q} ≡∀s t. P s --> (∃n. s -c -n→ t) --> Q t"
definition evalid :: "[assn,expr,vassn] => bool" (‹⊨🪙e {(1_)}/ (_)/ {(1_)}› [3,90,3] 60) where "⊨🪙e {P} e {Q} ≡∀s v t. P s --> (∃n. s -e≻v-n→ t) --> Q v t"
definition nvalid :: "[nat, triple ] => bool" (‹⊨_: _› [61,61] 60) where "⊨n: t ≡ let (P,c,Q) = t in ∀s t. s -c -n→ t --> P s --> Q t"
definition envalid :: "[nat,etriple ] => bool" (‹⊨_:🪙e _› [61,61] 60) where "⊨n:🪙e t ≡ let (P,e,Q) = t in ∀s v t. s -e≻v-n→ t --> P s --> Q v t"
definition nvalids :: "[nat, triple set] => bool" (‹|⊨_: _› [61,61] 60) where "|⊨n: T ≡∀t∈T. ⊨n: t"
definition cnvalids :: "[triple set,triple set] => bool" (‹_ |⊨/ _› [61,61] 60) where "A |⊨ C ≡∀n. |⊨n: A --> |⊨n: C"
definition cenvalid :: "[triple set,etriple ] => bool" (‹_ |⊨🪙e/ _›[61,61] 60) where "A |⊨🪙e t ≡∀n. |⊨n: A --> ⊨n:🪙e t"
lemma nvalid_def2: "⊨n: (P,c,Q) ≡∀s t. s -c-n→ t ⟶ P s ⟶ Q t" by (simp add: nvalid_def Let_def)
lemma nvalids_SucD: "Ball A (nvalid (Suc n)) ==> Ball A (nvalid n)" by (fast intro: nvalid_SucD)
lemma Loop_sound_lemma [rule_format (no_asm)]: "∀s t. s -c-n→ t ⟶ P s ∧ s≠ Null ⟶ P t ==> (s -c0-n0→ t ⟶ P s ⟶ c0 = While (x) c ⟶ n0 = n ⟶ P t ∧ t = Null)" apply (rule_tac ?P2.1="%s e v n t. True"in exec_eval.induct [THEN conjunct1]) apply clarsimp+ done
lemma Impl_sound_lemma: "[∀z n. Ball (A ∪ B) (nvalid n) ⟶ Ball (f z ` Ms) (nvalid n); Cm∈Ms; Ball A (nvalid na); Ball B (nvalid na)]==> nvalid na (f z Cm)" by blast
lemma all_conjunct2: "∀l. P' l ∧ P l ==>∀l. P l" by fast
lemma all3_conjunct2: "∀a p l. (P' a p l ∧ P a p l) ==>∀a p l. P a p l" by fast
lemma cnvalid1_eq: "A |⊨ {(P,c,Q)} ≡∀n. |⊨n: A ⟶ (∀s t. s -c-n→ t ⟶ P s ⟶ Q t)" by(simp add: cnvalids_def nvalids_def nvalid_def2)
lemma hoare_sound_main:"∧t. (A |⊨ C ⟶ A |⊨ C) ∧ (A |⊨🪙e t ⟶ A |⊨🪙e t)" apply (tactic "split_all_tac 🍋 1", rename_tac P e Q) apply (rule hoare_ehoare.induct) (*18*) apply (tactic ‹ALLGOALS (REPEAT o dresolve_tac 🍋 [@{thm all_conjunct2}, @{thm all3_conjunct2}])›) apply (tactic ‹ALLGOALS (REPEAT o Rule_Insts.thin_tac 🍋 "hoare _ _" [])›) apply (tactic ‹ALLGOALS (REPEAT o Rule_Insts.thin_tac 🍋 "ehoare _ _" [])›) apply (simp_all only: cnvalid1_eq cenvalid_def2) apply fast apply fast apply fast apply (clarify,tactic "smp_tac 🍋 1 1",erule(2) Loop_sound_lemma,(rule HOL.refl)+) apply fast apply fast apply fast apply fast apply fast apply fast apply (clarsimp del: Meth_elim_cases) (* Call *) apply (force del: Impl_elim_cases) defer prefer 4 apply blast (* Conseq *) prefer 4 apply blast (* eConseq *) apply (simp_all (no_asm_use) only: cnvalids_def nvalids_def) apply blast apply blast apply blast apply (rule allI) apply (rule_tac x=Z in spec) apply (induct_tac "n") apply (clarify intro!: Impl_nvalid_0) apply (clarify intro!: Impl_nvalid_Suc) apply (drule nvalids_SucD) apply (simp only: HOL.all_simps) apply (erule (1) impE) apply (drule (2) Impl_sound_lemma) apply blast apply assumption done
theorem hoare_sound: "{} ⊨ {P} c {Q} ==>⊨ {P} c {Q}" apply (simp only: valid_def2) apply (drule hoare_sound_main [THEN conjunct1, rule_format]) apply (unfold cnvalids_def nvalids_def) apply fast done
theorem ehoare_sound: "{} ⊨🪙e {P} e {Q} ==>⊨🪙e {P} e {Q}" apply (simp only: evalid_def2) apply (drule hoare_sound_main [THEN conjunct2, rule_format]) apply (unfold cenvalid_def nvalids_def) apply fast done
subsection"(Relative) Completeness"
definition MGT :: "stmt => state => triple"where "MGT c Z ≡ (λs. Z = s, c, λ t. ∃n. Z -c- n→ t)"
definition MGT🪙e :: "expr => state => etriple"where "MGT🪙e e Z ≡ (λs. Z = s, e, λv t. ∃n. Z -e≻v-n→ t)"
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.