Theory UPPAAL_State_Networks_Impl
theory UPPAAL_State_Networks_Impl
imports Munta_Base.Normalized_Zone_Semantics_Impl UPPAAL_State_Networks
begin
section ‹Implementation of UPPAAL Style Networks›
no_notation OR (infix "or" 60)
lemma step_resets:
"∀ c ∈ set r'. ∃ x pc. Some (INSTR (STOREC c x)) = P pc"
if "stepc cmd u (pc, st, s, f, r) = Some (pc', st', s', f', r')"
"∀ c ∈ set r. ∃ x pc. Some (INSTR (STOREC c x)) = P pc" "P pc = Some cmd"
using that
apply -
apply (erule stepc.elims)
by (auto split: option.splits if_splits elim!: step.elims) metis+
lemma step_resets':
"∀ c ∈ set r'. ∃ x pc. Some (INSTR (STOREC c x)) = P pc"
if "step instr (pc, st, s, f, r) = Some (pc', st', s', f', r')"
"∀ c ∈ set r. ∃ x pc. Some (INSTR (STOREC c x)) = P pc" "P pc = Some (INSTR instr)"
using that
by (auto split: option.splits if_splits elim!: step.elims) metis+
lemma step_resets'':
"∀ c ∈ set r'. ∃ x pc. Some (STOREC c x) = P pc"
if "step instr (pc, st, s, f, r) = Some (pc', st', s', f', r')"
"∀ c ∈ set r. ∃ x pc. Some (STOREC c x) = P pc" "P pc = Some instr"
using that
by (auto split: option.splits if_splits elim!: step.elims) metis+
lemma steps_reset:
"∀ c ∈ set r'. ∃ x pc. Some (STOREC c x) = P pc"
if "steps P n (pc, st, s, f, r) (pc', st', s', f', r')" "∀ c ∈ set r. ∃ x pc. Some (STOREC c x) = P pc"
using that
by (induction P ≡ P n "(pc, st, s, f, r :: nat list)" "(pc', st', s', f', r')" arbitrary: pc st s f r rule: steps.induct)
(auto dest!: step_resets''[where P = P])
lemma exec_reset:
"∀ c ∈ set r'. ∃ x pc. Some (STOREC c x) = P pc"
if "Some ((pc', st', s', f', r'), pcs') = exec P n (pc, st, s, f, []) pcs"
using exec_steps[OF that[symmetric]] steps_reset by force
lemma exec_pointers:
"∀ pc ∈ set pcs'. ∃ pc instr. Some instr = P pc"
if "Some ((pc', st', s', f', r'), pcs') = exec P n (pc, st, s, f, r) pcs"
"∀ pc ∈ set pcs. ∃ pc instr. Some instr = P pc"
using that
apply (induction rule: exec.induct)
by (auto split: option.splits if_splits) metis+
lemma exec_pointers':
"∀ pc ∈ set pcs'. ∃ pc instr. Some instr = P pc"
if "Some ((pc', st', s', f', r'), pcs') = exec P n (pc, st, s, f, r) []"
using that exec_pointers by fastforce
context Prod_TA_Defs
begin
lemma finite_range_I':
assumes "∀A∈{0..<p}. finite (range (snd (N ! A)))"
shows "finite (range (I' s))"
using assms unfolding inv_of_def Product_TA_Defs.product_ta_def N_s_def
by (auto simp: inv_of_def p_def intro!: Product_TA_Defs.finite_invariant_of_product)
lemma range_prod_invariant:
"range prod_invariant = range (I' s)"
unfolding prod_invariant_def using I'_simp by auto
lemma finite_rangeI:
assumes "∀A∈{0..<p}. finite (range (snd (N ! A)))"
shows "finite (range prod_invariant)"
using assms by (metis finite_range_I' range_prod_invariant)
end
context Equiv_TA_Defs
begin
lemma states'_len_simp[simp]:
"length L = p" if "L ∈ defs.states' s"
using that
using Product_TA_Defs.states_length defs.N_s_def state_ta_def by fastforce
lemma defs_N_p[simp]:
"length defs.N = p"
unfolding state_ta_def by simp
lemma defs_p[simp]:
"defs.p = p"
unfolding defs.p_def by simp
lemma P_Storec_iff:
"(Some (INSTR (STOREC x xa)) = P pc) ⟷ (Some (STOREC x xa) = PF pc)"
unfolding stripfp_def apply (cases "P pc")
apply force
subgoal for a
by (cases a) auto
done
lemma product_trans_i_resets:
"collect_clkvt (Product_TA_Defs.product_trans_i (defs.N_s s))
⊆ {c. ∃ x pc. Some (INSTR (STOREC c x)) = P pc}"
unfolding collect_clkvt_def
unfolding Product_TA_Defs.product_trans_i_def
apply clarsimp
unfolding defs.N_s_def
unfolding trans_of_def
unfolding defs.T_s_def
unfolding state_ta_def
unfolding state_trans_t_def
unfolding make_f_def
apply (clarsimp split: option.split_asm)
by (auto dest: exec_reset simp: P_Storec_iff)
lemma product_trans_s_resets:
"collect_clkvt (Product_TA_Defs.product_trans_s (defs.N_s s))
⊆ {c. ∃ x pc. Some (INSTR (STOREC c x)) = P pc}"
unfolding collect_clkvt_def
unfolding Product_TA_Defs.product_trans_s_def
apply clarsimp
unfolding defs.N_s_def
unfolding trans_of_def
unfolding defs.T_s_def
unfolding state_ta_def
unfolding state_trans_t_def
unfolding make_f_def
apply (clarsimp split: option.split_asm)
by (auto dest: exec_reset simp: P_Storec_iff)
lemma product_trans_resets:
"collect_clkvt (⋃s. defs.T' s) ⊆ {c. ∃ x pc. Some (INSTR (STOREC c x)) = P pc}"
unfolding trans_of_def
unfolding Product_TA_Defs.product_ta_def
apply simp
unfolding Product_TA_Defs.product_trans_def
unfolding collect_clkvt_def
apply safe
unfolding Product_TA_Defs.product_trans_i_def Product_TA_Defs.product_trans_s_def
apply clarsimp_all
unfolding defs.N_s_def
unfolding trans_of_def
unfolding defs.T_s_def
unfolding state_ta_def
unfolding state_trans_t_def
unfolding make_f_def
apply (clarsimp_all split: option.split_asm)
by (auto dest: exec_reset simp: P_Storec_iff)
lemma product_trans_guards:
"Timed_Automata.collect_clkt (⋃s. defs.T' s)
⊆ {constraint_pair ac | ac. ∃ pc. Some (CEXP ac) = P pc}"
unfolding trans_of_def
unfolding Product_TA_Defs.product_ta_def
apply simp
unfolding Product_TA_Defs.product_trans_def
unfolding Timed_Automata.collect_clkt_def collect_clock_pairs_def
apply safe
unfolding Product_TA_Defs.product_trans_i_def Product_TA_Defs.product_trans_s_def
apply clarsimp_all
unfolding defs.N_s_def
unfolding trans_of_def
unfolding defs.T_s_def
unfolding state_ta_def
unfolding state_trans_t_def
unfolding make_g_def
apply (clarsimp_all split: option.split_asm)
subgoal premises prems
using prems(1,3-)
unfolding set_map_filter
by (smt (verit, best) instrc.simps(5,6) is_instr.cases
mem_Collect_eq option.exhaust option.inject
option.simps(3,4,5))+
subgoal premises prems
using prems(1,2,4-)
apply safe
unfolding set_map_filter
apply (drule exec_pointers')
by (smt (verit, best) instrc.simps(5,6) is_instr.cases
mem_Collect_eq option.exhaust option.inject
option.simps(3,4,5))+
done
end