theory ClockView imports
KBPsAlg
Eval
List_local
ODList
Trie2 "Transitive-Closure.Transitive_Closure_List_Impl" "HOL-Library.Mapping" begin (*>*)
subsection‹The Clock View›
text‹
label{sec:kbps-theory-clock-view}
\emph{clock view} records the current time and the observation for
most recent state:
›
definition (in Environment)
clock_jview :: "('a, 's, nat × 'obs) JointView" where "clock_jview ≡ λa t. (tLength t, envObs a (tLast t))" (*<*)
context Environment begin
lemma clock_jview_tInit: "clock_jview a (tInit s) = (0, envObs a s)" unfolding clock_jview_def by simp
lemma clock_jview_tStep: "clock_jview a (t ↝ s) = (Suc (tLength t), envObs a s)" unfolding clock_jview_def by simp
lemma clock_jview_tStepI[intro]: "[ tLength t = Suc n; envObs a (tLast t) = obs ] ==> clock_jview a t = (Suc n, obs)" unfolding clock_jview_def by (cases t) simp_all
lemma clock_jview_inv: "clock_jview a t = (n, obs) ==> envObs a (tLast t) = obs" unfolding clock_jview_def by (cases t) simp_all
lemma clock_jview_eq_inv[iff]: "clock_jview a t' = clock_jview a t ⟷ tLength t' = tLength t ∧ envObs a (tLast t') = envObs a (tLast t)" by (fastforce simp: clock_jview_def)
end(*>*)
text‹
is the least-information synchronous view, given the requirements \S\ref{sec:kbps-views}. We show that finite-state implementations
for all environments with respect to this view as per 🍋‹"Ron:1996"›.
corresponding incremental view simply increments the counter
the new observation.
›
definition (in Environment)
clock_jviewInit :: "'a ==> 'obs ==> nat × 'obs" where "clock_jviewInit ≡ λa obs. (0, obs)"
this set contains the states that the agents commonly
possible at time @{term "n"}, which is sufficient for
knowledge as the clock view ignores paths. Therefore we
simulate trace @{term "t"} by pairing this abstraction of @{term
t"} with its final state:
›
type_synonym (in -) 's clock_simWorlds = "'s set × 's"
the Kripke structure for our simulation, we relate worlds for
{term "a"} if the sets of commonly-held states coincide, and the
of the final states of the traces is the
. Propositions are evaluated at the final state.
›
definition clock_simRels :: "'a ==> 's clock_simWorlds Relation"where "clock_simRels ≡ λa. { ((X, s), (X', s')) |X X' s s'. X = X' ∧ {s, s'} ⊆ X ∧ envObs a s = envObs a s' }"
now turn to the issue of how to represent equivalence classes of
. As these are used as map keys, it is easiest to represent them
. A simple approach is to use \emph{ordered distinct lists}
type @{typ "'a odlist"} for the sets and \emph{tries} for the
. Therefore we ask that environment states @{typ "'s"} belong to
class ‹linorder› of linearly-ordered types, and moreover
the set ‹agents› be effectively presented. We introduce a
locale capturing these requirements:
a fixed agent @{term "a"}, we can reduce the number of worlds in
{term "clock_simMC"} by taking its quotient with respect to the
relation for @{term "a"}. In other words, we represent a
equivalence class by a pair of the set of all states
at a particular time, and the subset of these that @{term
a"} considers possible. The worlds in our representational Kripke
are therefore a pair of ordered, distinct lists:
can readily abstract a representation to a set of simulated
classes:
›
definition (in -)
clock_simAbs :: "'s::linorder clock_simWorldsRep ==> 's clock_simWorlds set" where "clock_simAbs X ≡ { (ODList.toSet (fst X), s) |s. s ∈ ODList.toSet (snd X) }"
text‹
@{term "X"} represents a simulated equivalence class for
{term "t ∈ jkbpC"}, @{term "clock_simAbs X"} decomposes into these
functions:
›
definition
agent_abs :: "'a ==> 's Trace ==> 's set" where "agent_abs a t ≡ { tLast t' |t'. t' ∈ Clock.jkbpC ∧ clock_jview a t' = clock_jview a t}"
definition
common_abs :: "'s Trace ==> 's set" where "common_abs t ≡ tLast ` Clock.jkbpCn (tLength t)" (*<*)
lemma aec_refl[intro, simp]: "t ∈ Clock.jkbpC ==> tLast t ∈ agent_abs a t" unfolding agent_abs_def by auto
lemma aec_cec_subset: assumes tC: "t ∈ Clock.jkbpC" and aec: "ODList.toSet aec = agent_abs a t" and cec: "ODList.toSet cec = common_abs t" shows"x ∈ ODList.toSet aec ==> x ∈ ODList.toSet cec" using assms unfolding agent_abs_def common_abs_def by fastforce
lemma clock_simAbs_refl: assumes tC: "t ∈ Clock.jkbpC" and ec: "clock_simAbs ec = Clock.sim_equiv_class a t" shows"clock_sim t ∈ clock_simAbs ec" using assms by simp
representation is canonical on the domain of interest (though not
general):
›
lemma clock_simAbs_inj_on: "inj_on clock_simAbs { x . clock_simAbs x ∈ Clock.jkbpSEC }" (*<*) proof(rule inj_onI) fix x y assume x: "x ∈ { x . clock_simAbs x ∈ Clock.jkbpSEC }" and y: "y ∈ { x . clock_simAbs x ∈ Clock.jkbpSEC }" and xy: "clock_simAbs x = clock_simAbs y" from x obtain a t where tC: "t ∈ Clock.jkbpC" and ec: "clock_simAbs x = Clock.sim_equiv_class a t" by auto from common_abs[OF tC ec] common_abs[OF tC trans[OF xy[symmetric] ec], symmetric] have"fst x = fst y"by (blast intro: injD[OF toSet_inj]) moreover from agent_abs[OF tC ec] agent_abs[OF tC trans[OF xy[symmetric] ec], symmetric] have"snd x = snd y"by (blast intro: injD[OF toSet_inj]) ultimatelyshow"x = y"by (simp add: prod_eqI) qed (*>*) text‹
could further compress this representation by labelling each
of the set of states reachable at time $n$ with a bit to
whether the agent considers that state possible. Note,
, that the representation would be non-canonical: if ‹(s, True)› is in the representation, indicating that the agent ‹s› possible, then ‹(s, False)› may or may
be. The associated abstraction function is not injective and hence
obfuscate the following. Repairing this would entail introducing
new type, which would again complicate this development.
following lemmas make use of this Kripke structure, constructed
the set of final states of a temporal slice @{term "X"}:
›
definition
clock_repRels :: "'a ==> ('s × 's) set" where "clock_repRels ≡ λa. { (s, s'). envObs a s = envObs a s' }"
abbreviation
clock_repMC :: "'s set ==> ('a, 'p, 's) KripkeStructure" where "clock_repMC ≡ λX. mkKripke X clock_repRels envVal" (*<*)
lemma clock_repMC_kripke[intro, simp]: "kripke (clock_repMC X)" by (rule kripkeI) simp
lemma clock_repMC_S5n[intro, simp]: "S5n (clock_repMC X)" unfolding clock_repRels_def by (intro S5nI equivI refl_onI symI transI) auto
(*>*) text‹
can show that this Kripke structure retains sufficient information
@{term "Clock.MCS"} by showing simulation. This is eased by
an intermediary structure that focusses on a particular
:
›
abbreviation
clock_jkbpCSt :: "'b Trace ==> 's clock_simWorlds set" where "clock_jkbpCSt t ≡ clock_sim ` Clock.jkbpCn (tLength t)"
abbreviation
clock_simMCt :: "'b Trace ==> ('a, 'p, 's clock_simWorlds) KripkeStructure" where "clock_simMCt t ≡ mkKripke (clock_jkbpCSt t) clock_simRels clock_simVal"
lemma clock_repSim: assumes tC: "t ∈ Clock.jkbpC" shows"sim (clock_simMCt t) ((clock_repMC ∘ fst) (clock_sim t)) clock_repSim" (*<*) (is "sim ?M ?M' ?f") proof show"sim_range ?M ?M' ?f" proof show"worlds ?M' = ?f ` worlds ?M" unfolding clock_sim_def clock_repSim_def by force next fix a show"relations ?M' a ⊆ worlds ?M' × worlds ?M'" by (simp add: clock_sim_def clock_repSim_def) qed next show"sim_val ?M ?M' ?f" by (rule, simp add: clock_sim_def clock_simVal_def clock_repSim_def split: prod.split) next show"sim_f ?M ?M' ?f" apply rule unfolding clock_repRels_def clock_repSim_def clock_simRels_def apply (auto iff: clock_sim_def) done next show"sim_r ?M ?M' ?f" apply rule unfolding clock_repRels_def clock_repSim_def clock_simRels_def clock_sim_def apply clarsimp done qed
(*>*) text‹
following sections show how we satisfy the remaining requirements
the ‹Algorithm› locale of
~\ref{fig:kbps-alg-alg-locale}. Where the proof is routine, we
present the lemma without proof or comment.
to a limitation in the code generator in the present version of
(2011), we need to define the equations we wish to execute
of a locale; the syntax ‹(in -)› achieves this by
definitons at the theory top-level. We then define (but elide)
-local abbreviations that supply the locale-bound variables to
definitions.
›
(* **************************************** *)
subsubsection‹Initial states›
text‹
initial states of the automaton for an agent is simply @{term
envInit"} paired with the partition of @{term "envInit"} under the
's observation.
›
definition (in -)
clock_simInit :: "('s::linorder) list ==> ('a ==> 's ==> 'obs) ==> 'a ==> 'obs ==> 's clock_simWorldsRep" where "clock_simInit envInit envObs ≡ λa iobs. let cec = ODList.fromList envInit in (cec, ODList.filter (λs. envObs a s = iobs) cec)" (*<*)
lemma clock_simObs: assumes tC: "t ∈ Clock.jkbpC" and ec: "clock_simAbs ec = Clock.sim_equiv_class a t" shows"clock_simObs a ec = envObs a (tLast t)" (*<*) proof - have A: "∀s ∈ set (toList (snd ec)). envObs a s = envObs a (tLast t)" using agent_abs[OF tC ec] by (clarsimp simp: agent_abs_def toSet_def) have B: "tLast t ∈ set (toList (snd ec))" using clock_simAbs_refl[OF assms] unfolding clock_simAbs_def clock_sim_def by (simp add: toSet_def snd_def) show ?thesis unfolding clock_simObs_def by (simp add: list_choose_hd[OF A B] ODList.hd_def) qed (*>*)
(* **************************************** *)
subsubsection‹Evaluation›
text‹
label{sec:kbps-theory-clock-view-eval}
define our ‹eval› function in terms of @{term "evalS"},
implements boolean logic over @{typ "'s odlist"} in the usual
-- see \S\ref{sec:kbps-spr-single-agent-eval} for the relevant
. It requires three functions specific to the representation:
each for propositions, knowledge and common knowledge.
define subsets of the worlds considered possible:
›
abbreviation (in -)
clock_evalProp :: "(('s::linorder) ==> 'p ==> bool) ==> 's odlist ==> 'p ==> 's odlist" where "clock_evalProp envVal ≡ λX p. ODList.filter (λs. envVal s p) X"
text‹
knowledge relation computes the subset of the
-held-possible worlds ‹cec› that agent @{term "a"}
possible at world @{term "s"}:
›
definition (in -)
clock_knowledge :: "('a ==> ('s :: linorder) ==> 'obs) ==> 's odlist ==> 'a ==> 's ==> 's odlist" where "clock_knowledge envObs cec ≡ λa s. ODList.filter (λs'. envObs a s = envObs a s') cec"
text‹
the common knowledge operation computes the transitive
of the union of the knowledge relations for the agents ‹as›:
›
definition (in -)
clock_commonKnowledge :: "('a ==> ('s :: linorder) ==> 'obs) ==> 's odlist ==> 'a list ==> 's ==> 's odlist" where "clock_commonKnowledge envObs cec ≡ λas s. let r = λa. ODList.fromList [ (s', s'') . s' ← toList cec, s'' ← toList cec, envObs a s' = envObs a s'' ]; R = toList (ODList.big_union r as) in ODList.fromList (memo_list_trancl R s)"
text‹
function ‹memo_list_trancl› comes from the executable
closure theory of 🍋‹"AFP:TRANCL"›.
evaluation function evaluates a subjective knowledge formula on
representation of an equivalence class:
lemma clock_coEC_relation_image: "s ∈ ODList.toSet Y ==> ODList.toSet (clock_knowledge envObs Y a s) = relations (clock_repMC (ODList.toSet Y)) a `` {s}" unfolding clock_knowledge_def clock_repRels_def Image_def by auto
lemma clock_commonKnowledge_relation_image_aux: "(∪x∈set as. ∪a∈ODList.toSet Y. ∪aa∈ODList.toSet Y ∩ {s''. envObs x a = envObs x s''}. {(a, aa)}) = ((∪a∈set as. {(s, s'). envObs a s = envObs a s'}) ∩ ODList.toSet Y × ODList.toSet Y)" by auto
lemma clock_commonKnowledge_relation_image: "s ∈ ODList.toSet Y ==> ODList.toSet (clock_commonKnowledge envObs Y as s) = (∪a ∈ set as. relations (clock_repMC (ODList.toSet Y)) a)+ `` {s}" unfolding clock_commonKnowledge_def clock_repRels_def Let_def apply (simp add: memo_list_trancl toSet_def[symmetric] Image_def clock_commonKnowledge_relation_image_aux) done
lemma eval_rec_models: assumes XY: "ODList.toSet X ⊆ ODList.toSet Y" and s: "s ∈ ODList.toSet X" shows"s ∈ ODList.toSet (eval_rec (clock_evalProp envVal) (clock_knowledge envObs Y) (clock_commonKnowledge envObs Y) X φ) ⟷ clock_repMC (ODList.toSet Y), s ⊨ φ" using XY s proof(induct φ arbitrary: X s) case (Kknows a' φ X s) from‹s ∈ ODList.toSet X› clock_coEC_relation_image[OF subsetD[OF Kknows(2) Kknows(3)], where a=a'] show ?case apply simp apply rule apply (drule arg_cong[where f="ODList.toSet"]) apply (clarsimp simp: odlist_all_iff) apply (cut_tac s3="w'"and X3="clock_knowledge envObs Y a' s"in Kknows.hyps) using Kknows(2) Kknows(3) apply (auto simp add: S5n_rels_closed[OF clock_repMC_S5n])[3]
apply (clarsimp simp: toSet_eq_iff odlist_all_iff) apply (subst Kknows.hyps) using Kknows(2) Kknows(3) apply (auto simp add: S5n_rels_closed[OF clock_repMC_S5n]) done next case (Kcknows as φ X s) show ?case proof(cases "as = Nil") case True with‹s ∈ ODList.toSet X›show ?thesis by clarsimp next case False with‹s ∈ ODList.toSet X› clock_commonKnowledge_relation_image[OF subsetD[OF Kcknows(2) Kcknows(3)], where as=as] show ?thesis apply simp apply rule apply (drule arg_cong[where f="ODList.toSet"]) apply (clarsimp simp: odlist_all_iff) apply (cut_tac s3="w'"and X3="clock_commonKnowledge envObs Y as s"in Kcknows.hyps) using Kcknows(2) Kcknows(3) apply (auto simp add: S5n_rels_closed[OF clock_repMC_S5n])[3] apply (subst (asm) trancl_unfold) backbackback apply auto[1] (* FIXME disgusting *)
the above result about evaluation, we can relate ‹clock_simAction› to @{term "jAction"}. Firstly, ‹clock_simAction› behaves the same as @{term "jAction"} using the
{term "clock_repMC"} structure:
lemma clock_submodel_aux: assumes tC: "t ∈ Clock.jkbpC" and s: "s ∈ worlds (clock_simMCt t)" shows"gen_model Clock.MCS s = gen_model (clock_simMCt t) s" proof(rule gen_model_subset[where T="clock_jkbpCSt t"]) fix a let ?X = "clock_sim ` Clock.jkbpCn (tLength t)" show"relations Clock.MCS a ∩ ?X × ?X = relations (clock_simMCt t) a ∩ ?X × ?X" by (simp add: Int_ac Int_absorb1
relation_mono[OF jkbpCSt_jkbpCS_subset jkbpCSt_jkbpCS_subset]) next let ?X = "clock_sim ` Clock.jkbpCn (tLength t)" from s show"(∪a. relations (clock_simMCt t) a)* `` {s} ⊆ ?X" apply (clarsimp simp del: mkKripke_simps) apply (erule kripke_rels_trc_worlds) apply auto done next let ?Y = "Clock.jkbpCn (tLength t)" let ?X = "clock_sim ` ?Y" from s obtain t' where st': "s = clock_sim t'" and t'C: "t' ∈ Clock.jkbpC" and t'O: "tLength t = tLength t'" by fastforce
{ fix t'' assume tt': "(t', t'') ∈ (∪a. relations Clock.MC a)*" from t'C tt' have t''C: "t'' ∈ Clock.jkbpC" by - (erule kripke_rels_trc_worlds, simp_all) from t'O tt' have t''O: "tLength t = tLength t''" by (simp add: Clock.sync_tLength_eq_trc) from t''C t''O have"t'' ∈ ?Y"by fastforce } hence"(∪a. relations Clock.MC a)* `` {t'} ⊆ ?Y" by clarsimp hence"clock_sim ` ((∪a. relations Clock.MC a)* `` {t'}) ⊆ ?X" by (rule image_mono) with st' t'C show"(∪a. relations Clock.MCS a)* `` {s} ⊆ ?X" using sim_trc_commute[OF Clock.mkM_kripke clock_sim, where t=t'] by simp qed (insert s, auto)
(*>*) text‹
can connect the agent's choice of actions on the ‹clock_repMC› structure to those on the ‹Clock.MC›
using our earlier results about actions being preserved by
models and simulations.
›
lemma clock_simAction': assumes tC: "t ∈ Clock.jkbpC" assumes aec: "ODList.toSet aec = agent_abs a t" assumes cec: "ODList.toSet cec = common_abs t" shows"set (clock_simAction a (cec, aec)) = set (jAction Clock.MC t a)" (*<*) (is "?lhs = ?rhs") proof - from tC aec cec have"?lhs = set (jAction (clock_repMC (ODList.toSet cec)) (tLast t) a)" by (rule clock_simAction_jAction) alsofrom tC aec cec have"... = set (jAction (clock_simMCt t) (clock_sim t) a)" by (simp add: simulation_jAction_eq[OF _ clock_repSim] common_abs_def) alsofrom tC have"... = set (jAction Clock.MCS (clock_sim t) a)" using gen_model_jAction_eq[OF clock_submodel_aux[OF tC, where s="clock_sim t"], where w'="clock_sim t"]
gen_model_world_refl[where w="clock_sim t"and M="clock_simMCt t"] by simp alsofrom tC have"... = set (jAction Clock.MC t a)" by (simp add: simulation_jAction_eq[OF _ clock_sim]) finallyshow ?thesis . qed
(*>*) text‹
@{term "Algorithm"} locale requires a specialisation of this
:
›
lemma clock_simAction: assumes tC: "t ∈ Clock.jkbpC" assumes ec: "clock_simAbs ec = Clock.sim_equiv_class a t" shows"set (clock_simAction a ec) = set (jAction Clock.MC t a)" (*<*) using assms clock_simAction'[OF tC, where cec="fst ec"and aec="snd ec"] apply (simp add: common_abs agent_abs) done (*>*)
(* **************************************** *)
subsubsection‹Simulated transitions›
text‹
need to determine the image of the set of commonly-held-possible
under the transition function, and also for the agent's
equivalence class. We do this with the ‹clock_trans› function:
that the clock semantics disregards paths, so we simply compute
successors of the temporal slice and partition that. Similarly the
of the agent's subjective equivalence class tell us what
set of possible observations are:
mentioned above, the canonicity of our ordered, distinct list
of automaton states allows us to use them as keys in a
trie; a value of type @{typ "('key, 'val) trie"} maps keys of
@{typ "'key list"} to values of type @{typ "'val"}.
this specific case we track automaton transitions using a two-level
mapping sets of states to an association list mapping
to sets of states, and for actions automaton states map
to agent actions.
lemma (in FiniteLinorderEnvironment) acts_MapOps: "MapOps clock_simAbs Clock.jkbpSEC acts_MapOps" proof fix k show"MapOps.lookup acts_MapOps (MapOps.empty acts_MapOps) k = None" unfolding acts_MapOps_def acts_MapOps_lookup_def trie_odlist_lookup_def by auto next fix e k k' M assume k: "clock_simAbs k ∈ Clock.jkbpSEC" and k': "clock_simAbs k' ∈ Clock.jkbpSEC" show"MapOps.lookup acts_MapOps (MapOps.update acts_MapOps k e M) k' = (if clock_simAbs k' = clock_simAbs k then Some e else MapOps.lookup acts_MapOps M k')" proof(cases "clock_simAbs k' = clock_simAbs k") case True hence"k = k'" using inj_onD[OF clock_simAbs_inj_on] k k' by (auto iff: prod_eqI) thus ?thesis unfolding acts_MapOps_def acts_MapOps_lookup_def acts_MapOps_update_def by (auto simp: lookup_trie_update lookup_trie_update_with
trie_odlist_update_with_def trie_odlist_update_def trie_odlist_lookup_def) next case False thus ?thesis unfolding acts_MapOps_def acts_MapOps_lookup_def acts_MapOps_update_def by (auto simp: lookup_trie_update lookup_trie_update_with
trie_odlist_update_with_def trie_odlist_update_def trie_odlist_lookup_def
dest: prod_eqI
split: option.split) qed qed
(*>*) text‹
define two records @{term "acts_MapOps"} and @{term "trans_MapOps"}
the @{term "MapOps"} predicate \S\ref{sec:kbps-theory-map-ops}). Discharging the obligations in the
{term "Algorithm"} locale is routine, leaning on the work of 🍋‹"DBLP:conf/itp/LammichL10"›.
›
subsubsection‹Locale instantiation›
text‹
we assemble the algorithm and discharge the proof obligations.
discuss the clock semantics further in \S\ref{sec:kbps-alg-clock}.
›
(*<*) end (*>*)
Messung V0.5 in Prozent
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.13Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-06-10)
¤
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.