lemma shEx_lift_seq_1 [uquant_lift]: "((\<exists> x ∙ P x) ;; Q) = (\<exists> x ∙ (P x ;; Q))" by rel_auto
lemma shEx_mem_lift_seq_1 [uquant_lift]: assumes"outα ♯ A" shows"((\<exists> x ∈ A ∙ P x) ;; Q) = (\<exists> x ∈ A ∙ (P x ;; Q))" using assms by rel_blast
lemma shEx_lift_seq_2 [uquant_lift]: "(P ;; (\<exists> x ∙ Q x)) = (\<exists> x ∙ (P ;; Q x))" by rel_auto
lemma shEx_mem_lift_seq_2 [uquant_lift]: assumes"inα ♯ A" shows"(P ;; (\<exists> x ∈ A ∙ Q x)) = (\<exists> x ∈ A ∙ (P ;; Q x))" using assms by rel_blast
lemma assign_vacuous_skip: assumes"vwb_lens x" shows"(x := &x) = II" using assms by rel_auto
text‹ The following law shows the case for the above law when $x$ is only mainly-well behaved. We
require that the state is one of those in which $x$ is well defined using and assumption. ›
lemma assign_vacuous_assume: assumes"mwb_lens x" shows"[(&v∈u«S¬)]\<top> ;; (x := &x) = [(&v∈u«S¬)]\<top>" using assms by rel_auto
lemma frame_to_antiframe [frame]: "[ x ⋈ y; x +L y = 1L]==> x:[P] = y:[P]" by (rel_auto, metis lens_indep_def, metis lens_indep_def surj_pair)
lemma rel_frext_miracle [frame]: "a:[false]+ = false" by (rel_auto)
lemma rel_frext_skip [frame]: "vwb_lens a ==> a:[II]+ = II" by (rel_auto)
lemma rel_frext_seq [frame]: "vwb_lens a ==> a:[P ;; Q]+ = (a:[P]+ ;; a:[Q]+)" apply (rel_auto) apply (rename_tac s s' s0) apply (rule_tac x="put s s0"in exI) apply (auto) apply (metis mwb_lens.put_put vwb_lens_mwb) done
lemma rel_frext_assigns [frame]: "vwb_lens a ==> a:[⟨σ⟩a]+ = ⟨σ ⊕s a⟩a" by (rel_auto)
lemma rel_frext_rcond [frame]: "a:[P ◃ b ▹r Q]+ = (a:[P]+◃ b ⊕p a ▹r a:[Q]+)" by (rel_auto)
lemma rel_frext_commute: "x ⋈ y ==> x:[P]+ ;; y:[Q]+ = y:[Q]+ ;; x:[P]+" apply (rel_auto) apply (rename_tac a c b) apply (subgoal_tac "∧b a. get (put b a) = get b") apply (metis (no_types, opaque_lifting) lens_indep_comm lens_indep_get) apply (simp add: lens_indep.lens_put_irr2) apply (subgoal_tac "∧b c. get (put b c) = get b") apply (subgoal_tac "∧b a. get (put b a) = get b") apply (metis (mono_tags, lifting) lens_indep_comm) apply (simp_all add: lens_indep.lens_put_irr2) done
lemma nameset_skip: "vwb_lens x ==> (ns x ∙ II) = II" by (rel_auto, meson vwb_lens_wb wb_lens.get_put)
lemma nameset_skip_ra: "vwb_lens x ==> (ns x ∙ II) = II" by (rel_auto)
declare sublens_def [lens_defs]
subsection‹ While Loop Laws ›
theorem while_unfold: "while b do P od = ((P ;; while b do P od) ◃ b ▹r II)" proof - have m:"mono (λX. (P ;; X) ◃ b ▹r II)" by (auto intro: monoI seqr_mono cond_mono) have"(while b do P od) = (ν X ∙ (P ;; X) ◃ b ▹r II)" by (simp add: while_top_def) alsohave"... = ((P ;; (ν X ∙ (P ;; X) ◃ b ▹r II)) ◃ b ▹r II)" by (subst lfp_unfold, simp_all add: m) alsohave"... = ((P ;; while b do P od) ◃ b ▹r II)" by (simp add: while_top_def) finallyshow ?thesis . qed
theorem while_false: "while false do P od = II" by (subst while_unfold, rel_auto)
theorem while_true: "while true do P od = false" apply (simp add: while_top_def alpha) apply (rule antisym) apply (simp_all) apply (rule lfp_lowerbound) apply (rel_auto) done
theorem while_bot_unfold: "while\<bottom> b do P od = ((P ;; while\<bottom> b do P od) ◃ b ▹r II)" proof - have m:"mono (λX. (P ;; X) ◃ b ▹r II)" by (auto intro: monoI seqr_mono cond_mono) have"(while\<bottom> b do P od) = (μ X ∙ (P ;; X) ◃ b ▹r II)" by (simp add: while_bot_def) alsohave"... = ((P ;; (μ X ∙ (P ;; X) ◃ b ▹r II)) ◃ b ▹r II)" by (subst gfp_unfold, simp_all add: m) alsohave"... = ((P ;; while\<bottom> b do P od) ◃ b ▹r II)" by (simp add: while_bot_def) finallyshow ?thesis . qed
theorem while_bot_false: "while\<bottom> false do P od = II" by (simp add: while_bot_def mu_const alpha)
theorem while_bot_true: "while\<bottom> true do P od = (μ X ∙ P ;; X)" by (simp add: while_bot_def alpha)
text‹ An infinite loop with a feasible body corresponds to a program error (non-termination). ›
theorem while_infinite: "P ;; trueh = true ==> while\<bottom> true do P od = true" apply (simp add: while_bot_true) apply (rule antisym) apply (simp) apply (rule gfp_upperbound) apply (simp) done
subsection‹ Algebraic Properties ›
interpretation upred_semiring: semiring_1 where times = seqr and one = skip_r and zero = falsehand plus = Lattices.sup by (unfold_locales, (rel_auto)+)
declare upred_semiring.power_Suc [simp del]
text‹ We introduce the power syntax derived from semirings ›
abbreviation upower :: "'α hrel ==> nat ==> 'α hrel" (infixr‹^›80) where "upower P n ≡ upred_semiring.power P n"
translations "P ^ i" <= "CONST power.power II op ;; P i" "P ^ i" <= "(CONST power.power II op ;; P) i"
text‹ Set up transfer tactic for powers ›
lemma upower_rep_eq: "[P ^ i]e = (λ b. b ∈ ({p. [P]e p} ^^ i))" proof (induct i arbitrary: P) case0 thenshow ?case by (auto, rel_auto) next case (Suc i) show ?case by (simp add: Suc seqr.rep_eq relpow_commute upred_semiring.power_Suc) qed
lemma upower_rep_eq_alt: "[power.power ⟨id⟩a (;;) P i]e = (λb. b ∈ ({p. [P]e p} ^^ i))" by (metis skip_r_def upower_rep_eq)
update_uexpr_rep_eq_thms
lemma Sup_power_expand: fixes P :: "nat ==> 'a::complete_lattice" shows"P(0) ⊓ (⊓i. P(i+1)) = (⊓i. P(i))" proof - have"UNIV = insert (0::nat) {1..}" by auto moreoverhave"(⊓i. P(i)) = ⊓ (P ` UNIV)" by (blast) moreoverhave"⊓ (P ` insert 0 {1..}) = P(0) ⊓⊓ (P ` {1..})" by (simp) moreoverhave"⊓ (P ` {1..}) = (⊓i. P(i+1))" by (simp add: atLeast_Suc_greaterThan greaterThan_0) ultimatelyshow ?thesis by (simp only:) qed
lemma Sup_upto_Suc: "(⊓i∈{0..Suc n}. P ^ i) = (⊓i∈{0..n}. P ^ i) ⊓ P ^ Suc n" proof - have"(⊓i∈{0..Suc n}. P ^ i) = (⊓i∈insert (Suc n) {0..n}. P ^ i)" by (simp add: atLeast0_atMost_Suc) alsohave"... = P ^ Suc n ⊓ (⊓i∈{0..n}. P ^ i)" by (simp) finallyshow ?thesis by (simp add: Lattices.sup_commute) qed
lemma upower_inductl: "Q ⊑ ((P ;; Q) ⊓ R) ==> Q ⊑ P ^ n ;; R" proof (induct n) case0 thenshow ?caseby (auto) next case (Suc n) thenshow ?case by (auto simp add: upred_semiring.power_Suc, metis (no_types, opaque_lifting) dual_order.trans order_refl seqr_assoc seqr_mono) qed
lemma upower_inductr: assumes"Q ⊑ R ⊓ (Q ;; P)" shows"Q ⊑ R ;; (P ^ n)" using assms proof (induct n) case0 thenshow ?caseby auto next case (Suc n) have"R ;; P ^ Suc n = (R ;; P ^ n) ;; P" by (metis seqr_assoc upred_semiring.power_Suc2) alsohave"Q ;; P ⊑ ..." by (meson Suc.hyps assms eq_iff seqr_mono) alsohave"Q ⊑ ..." using assms by auto finallyshow ?case . qed
text‹ While loop can be expressed using Kleene star ›
lemma while_star_form: "while b do P od = (P ◃ b ▹r II)\<star> ;; [(¬b)]\<top>" proof - have1: "Continuous (λX. P ;; X ◃ b ▹r II)" by (rel_auto) have"while b do P od = (⊓i. ((λX. P ;; X ◃ b ▹r II) ^^ i) false)" by (simp add: "1" false_upred_def sup_continuous_Continuous sup_continuous_lfp while_top_def) alsohave"... = ((λX. P ;; X ◃ b ▹r II) ^^ 0) false ⊓ (⊓i. ((λX. P ;; X ◃ b ▹r II) ^^ (i+1)) false)" by (subst Sup_power_expand, simp) alsohave"... = (⊓i. ((λX. P ;; X ◃ b ▹r II) ^^ (i+1)) false)" by (simp) alsohave"... = (⊓i. (P ◃ b ▹r II)^i ;; (false ◃ b ▹r II))" proof (rule SUP_cong, simp_all) fix i show"P ;; ((λX. P ;; X ◃ b ▹r II) ^^ i) false ◃ b ▹r II = (P ◃ b ▹r II) ^ i ;; (false ◃ b ▹r II)" proof (induct i) case0 thenshow ?caseby simp next case (Suc i) thenshow ?case by (simp add: upred_semiring.power_Suc)
(metis (no_types, lifting) RA1 comp_cond_left_distr cond_L6 upred_semiring.mult.left_neutral) qed qed alsohave"... = (⊓i∈{0..} ∙ (P ◃ b ▹r II)^i ;; [(¬b)]\<top>)" by (rel_auto) alsohave"... = (P ◃ b ▹r II)\<star> ;; [(¬b)]\<top>" by (metis seq_UINF_distr ustar_def) finallyshow ?thesis . qed
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.