(* Author: David Cock - David.Cock@nicta.com.au *)
section‹Determinism›
theory Determinism imports WellDefined begin
text_raw‹\label{s:prog_determ}›
text‹We provide a set of lemmas for establishing that
appropriately restricted programs are fully additive, and
maximal in the refinement order. This is particularly useful
with data refinement, as it implies correspondence.›
from addb sP sQ have"wp b (λs. P s + Q s) = (λs. wp b P s + wp b Q s)" by(blast dest:additiveD) with adda sP sQ hb show"wp a (wp b (λs. P s + Q s)) s = wp a (wp b P) s + (wp a (wp b Q)) s" by(auto intro:fun_cong[OF additiveD]) qed
lemma additive_wp_repeat: "additive (wp a) ==> well_def a ==> additive (wp (repeat n a))" by(induct n, auto simp:additive_wp_Skip intro:additive_wp_Seq wd_intros)
lemma max_wp_DC: "[ maximal (wp a); maximal (wp b) ]==> maximal (wp (a ⊓ b))" by(rule maximalI, simp add:wp_eval maximalD)
lemma max_wp_SetPC: "[∧s a. a ∈ supp (P s) ==> maximal (wp (p a)); ∧s. (∑a∈supp (P s). P s a) = 1 ]==> maximal (wp (SetPC p P))" by(auto simp:maximalD wp_def SetPC_def sum_distrib_right[symmetric])
lemma max_wp_SetDC: fixes p::"'a ==> 's prog" assumes mp: "∧s a. a ∈ S s ==> maximal (wp (p a))" and ne: "∧s. S s ≠ {}" shows"maximal (wp (SetDC p S))" proof(rule maximalI, rule ext, unfold wp_eval) fix c::real and s::'s assume"0 ≤ c" hence"Inf ((λa. wp (p a) (λ_. c) s) ` S s) = Inf ((λ_. c) ` S s)" using mp by(simp add:maximalD cong:image_cong) also { from ne obtain a where"a ∈ S s"by blast hence"Inf ((λ_. c) ` S s) = c" by (auto simp add: image_constant_conv cong del: INF_cong_simp)
} finallyshow"Inf ((λa. wp (p a) (λ_. c) s) ` S s) = c" . qed
lemma max_wp_repeat: "maximal (wp a) ==> maximal (wp (repeat n a))" by(induct n, simp_all add:max_wp_Skip max_wp_Seq)
lemma max_wp_Bind: assumes ma: "∧s. maximal (wp (a (f s)))" shows"maximal (wp (Bind f a))" proof(rule maximalI, rule ext, simp add:wp_eval) fix c::real and s assume"0 ≤ c" with ma have"wp (a (f s)) (λ_. c) = (λ_. c)"by(blast) thus"wp (a (f s)) (λ_. c) s = c"by(auto) qed
text‹A healthy transformer that terminates is maximal.› lemma healthy_term_max: assumes ht: "healthy t" and trm: "λs. 1 ⊨!!! t (λs. 1)" shows"maximal t" proof(intro maximalI ext) fix c::real and s assume nnc: "0 ≤ c"
have"t (λs. c) s = t (λs. 1 * c) s"by(simp) alsofrom nnc healthy_scalingD[OF ht] have"... = c * t (λs. 1) s"by(simp add:scalingD) also { from ht have"t (λs. 1) ⊨!!! λs. 1"by(auto) with trm have"t (λs. 1) = (λs. 1)"by(auto) hence"c * t (λs. 1) s = c"by(simp)
} finallyshow"t (λs. c) s = c" . qed
subsection‹Determinism›
lemma det_wp_Skip: "determ (wp Skip)" using max_intros fa_intros by(blast)
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.