(* Title: HOL/UNITY/Simple/Reach.thy Author: Lawrence C Paulson, Cambridge University Computer Laboratory Copyright 1998 University of Cambridge
Reachability in Directed Graphs. From Chandy and Misra, section 6.4. [this example took only four days!]
*)
theory Reach imports"../UNITY_Main"begin
typedecl vertex
type_synonym state = "vertex=>bool"
consts
init :: "vertex"
edges :: "(vertex*vertex) set"
definition asgt :: "[vertex,vertex] => (state*state) set" where"asgt u v = {(s,s'). s' = s(v:= s u | s v)}"
definition Rprg :: "state program" where"Rprg = mk_total_program ({%v. v=init}, \(u,v)\edges. {asgt u v}, UNIV)"
definition reach_invariant :: "state set" where"reach_invariant = {s. (\v. s v --> (init, v) \ edges\<^sup>*) & s init}"
definition fixedpoint :: "state set" where"fixedpoint = {s. \(u,v)\edges. s u --> s v}"
definition metric :: "state => nat" where"metric s = card {v. ~ s v}"
text\<open>*We assume that the set of vertices is finite\<close> axiomatizationwhere
finite_graph: "finite (UNIV :: vertex set)"
(*TO SIMPDATA.ML?? FOR CLASET?? *) lemma ifE [elim!]: "[| if P then Q else R;
[| P; Q |] ==> S;
[| ~ P; R |] ==> S |] ==> S" by (simp split: if_split_asm)
(*If we haven't reached a fixedpoint then there is some edge for which u but not v holds. Progress will be proved via an ENSURES assertion that the metric will decrease for each suitable edge. A union over all edges proves a LEADSTO assertion that the metric decreases if we are not at a fixedpoint.
*)
(*Execution in any state leads to a fixedpoint (i.e. can terminate)*) lemma LeadsTo_fixedpoint: "Rprg \ UNIV LeadsTo fixedpoint" apply (rule LessThan_induct, auto) apply (rule LeadsTo_Un_fixedpoint) done
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 ist noch experimentell.