Theory ParallelComposition
section‹Parallel Composition›
theory
ParallelComposition
imports
ElementaryPolicies
begin
text‹
The following combinators are based on the idea that two policies are executed in parallel.
Since both input and the output can differ, we chose to pair them.
The new input pair will often contain repetitions, which can be reduced using the
domain-restriction and domain-reduction operators. Using additional range-modifying operators
such as $\nabla$, decide which result argument is chosen; this might be the first or the latter
or, in case that $\beta = \gamma$, and $\beta$ underlies a lattice structure, the supremum or
infimum of both, or, an arbitrary combination of them.
In any case, although we have strictly speaking a pairing of decisions and not a nesting of
them, we will apply the same notational conventions as for the latter, i.e. as for
flattening.
›
subsection‹Parallel Combinators: Foundations›
text ‹
There are four possible semantics how the decision can be combined, thus there are four
parallel composition operators. For each of them, we prove several properties.
›
definition prod_orA ::"['α↦'β, 'γ ↦'δ] ⇒ ('α×'γ ↦ 'β×'δ)" (infixr ‹⨂⇩∨⇩A› 55)
where "p1 ⨂⇩∨⇩A p2 =
(λ(x,y). (case p1 x of
⌊allow d1⌋ ⇒(case p2 y of
⌊allow d2⌋ ⇒ ⌊allow(d1,d2)⌋
| ⌊deny d2⌋ ⇒ ⌊allow(d1,d2)⌋
| ⊥ ⇒ ⊥)
| ⌊deny d1⌋⇒(case p2 y of
⌊allow d2⌋ ⇒ ⌊allow(d1,d2)⌋
| ⌊deny d2⌋ ⇒ ⌊deny (d1,d2)⌋
| ⊥ ⇒ ⊥)
| ⊥ ⇒ ⊥))"
lemma prod_orA_mt[simp]:"p ⨂⇩∨⇩A ∅ = ∅"
apply (rule ext)
apply (simp add: prod_orA_def)
apply (auto)
apply (simp split: option.splits decision.splits)
done
lemma mt_prod_orA[simp]:"∅ ⨂⇩∨⇩A p = ∅"
apply (rule ext)
apply (simp add: prod_orA_def)
done
lemma prod_orA_quasi_commute: "p2 ⨂⇩∨⇩A p1 = (((λ(x,y). (y,x)) o_f (p1 ⨂⇩∨⇩A p2))) o (λ(a,b).(b,a))"
apply (rule ext)
apply (simp add: prod_orA_def policy_range_comp_def o_def)
apply (auto)[1]
apply (simp split: option.splits decision.splits)
done
definition prod_orD ::"['α ↦ 'β, 'γ ↦ 'δ] ⇒ ('α × 'γ ↦ 'β × 'δ )" (infixr ‹⨂⇩∨⇩D› 55)
where "p1 ⨂⇩∨⇩D p2 =
(λ(x,y). (case p1 x of
⌊allow d1⌋ ⇒(case p2 y of
⌊allow d2⌋ ⇒ ⌊allow(d1,d2)⌋
| ⌊deny d2⌋ ⇒ ⌊deny(d1,d2)⌋
| ⊥ ⇒ ⊥)
| ⌊deny d1⌋⇒(case p2 y of
⌊allow d2⌋ ⇒ ⌊deny(d1,d2)⌋
| ⌊deny d2⌋ ⇒ ⌊deny (d1,d2)⌋
| ⊥ ⇒ ⊥)
| ⊥ ⇒ ⊥))"
lemma prod_orD_mt[simp]:"p ⨂⇩∨⇩D ∅ = ∅"
apply (rule ext)
apply (simp add: prod_orD_def)
apply (auto)[1]
apply (simp split: option.splits decision.splits)
done
lemma mt_prod_orD[simp]:"∅ ⨂⇩∨⇩D p = ∅"
apply (rule ext)
apply (simp add: prod_orD_def)
done
lemma prod_orD_quasi_commute: "p2 ⨂⇩∨⇩D p1 = (((λ(x,y). (y,x)) o_f (p1 ⨂⇩∨⇩D p2))) o (λ(a,b).(b,a))"
apply (rule ext)
apply (simp add: prod_orD_def policy_range_comp_def o_def)
apply (auto)[1]
apply (simp split: option.splits decision.splits)
done
text‹
The following two combinators are by definition non-commutative, but still strict.
›
definition prod_1 :: "['α↦'β, 'γ ↦'δ] ⇒ ('α×'γ ↦ 'β×'δ)" (infixr ‹⨂⇩1› 55)
where "p1 ⨂⇩1 p2 ≡
(λ(x,y). (case p1 x of
⌊allow d1⌋⇒(case p2 y of
⌊allow d2⌋ ⇒ ⌊allow(d1,d2)⌋
| ⌊deny d2⌋ ⇒ ⌊allow(d1,d2)⌋
| ⊥ ⇒ ⊥)
| ⌊deny d1⌋ ⇒(case p2 y of
⌊allow d2⌋ ⇒ ⌊deny(d1,d2)⌋
| ⌊deny d2⌋ ⇒ ⌊deny(d1,d2)⌋
| ⊥ ⇒ ⊥)
|⊥ ⇒ ⊥))"
lemma prod_1_mt[simp]:"p ⨂⇩1 ∅ = ∅"
apply (rule ext)
apply (simp add: prod_1_def)
apply (auto)[1]
apply (simp split: option.splits decision.splits)
done
lemma mt_prod_1[simp]:"∅ ⨂⇩1 p = ∅"
apply (rule ext)
apply (simp add: prod_1_def)
done
definition prod_2 :: "['α↦'β, 'γ ↦'δ] ⇒ ('α×'γ ↦ 'β×'δ)" (infixr ‹⨂⇩2› 55)
where "p1 ⨂⇩2 p2 ≡
(λ(x,y). (case p1 x of
⌊allow d1⌋ ⇒(case p2 y of
⌊allow d2⌋ ⇒ ⌊allow(d1,d2)⌋
| ⌊deny d2⌋ ⇒ ⌊deny (d1,d2)⌋
| ⊥ ⇒ ⊥)
| ⌊deny d1⌋⇒(case p2 y of
⌊allow d2⌋ ⇒ ⌊allow(d1,d2)⌋
| ⌊deny d2⌋ ⇒ ⌊deny (d1,d2)⌋
| ⊥ ⇒ ⊥)
|⊥ ⇒⊥))"
lemma prod_2_mt[simp]:"p ⨂⇩2 ∅ = ∅"
apply (rule ext)
apply (simp add: prod_2_def)
apply (auto)[1]
apply (simp split: option.splits decision.splits)
done
lemma mt_prod_2[simp]:"∅ ⨂⇩2 p = ∅"
apply (rule ext)
apply (simp add: prod_2_def)
done
definition prod_1_id ::"['α↦'β, 'α↦'γ] ⇒ ('α ↦ 'β×'γ)" (infixr ‹⨂⇩1⇩I› 55)
where "p ⨂⇩1⇩I q = (p ⨂⇩1 q) o (λx. (x,x))"
lemma prod_1_id_mt[simp]:"p ⨂⇩1⇩I ∅ = ∅"
apply (rule ext)
apply (simp add: prod_1_id_def)
done
lemma mt_prod_1_id[simp]:"∅ ⨂⇩1⇩I p = ∅"
apply (rule ext)
apply (simp add: prod_1_id_def prod_1_def)
done
definition prod_2_id ::"['α↦'β, 'α↦'γ] ⇒ ('α ↦ 'β×'γ)" (infixr ‹⨂⇩2⇩I› 55)
where"p ⨂⇩2⇩I q = (p ⨂⇩2 q) o (λx. (x,x))"
lemma prod_2_id_mt[simp]:"p ⨂⇩2⇩I ∅ = ∅"
apply (rule ext)
apply (simp add: prod_2_id_def)
done
lemma mt_prod_2_id[simp]:"∅ ⨂⇩2⇩I p = ∅"
apply (rule ext)
apply (simp add: prod_2_id_def prod_2_def)
done
subsection‹Combinators for Transition Policies›
text ‹
For constructing transition policies, two additional combinators are required: one combines
state transitions by pairing the states, the other works equivalently on general maps.
›
definition parallel_map :: "('α ⇀ 'β) ⇒ ('δ ⇀ 'γ) ⇒
('α × 'δ ⇀ 'β × 'γ)" (infixr ‹⨂⇩M› 60)
where "p1 ⨂⇩M p2 = (λ (x,y). case p1 x of ⌊d1⌋ ⇒
(case p2 y of ⌊d2⌋ ⇒ ⌊(d1,d2)⌋
| ⊥ ⇒ ⊥)
| ⊥ ⇒ ⊥)"
definition parallel_st :: "('i × 'σ ⇀ 'σ) ⇒ ('i × 'σ' ⇀ 'σ') ⇒
('i × 'σ × 'σ' ⇀ 'σ × 'σ')" (infixr ‹⨂⇩S› 60)
where
"p1 ⨂⇩S p2 = (p1 ⨂⇩M p2) o (λ (a,b,c). ((a,b),a,c))"
subsection‹Range Splitting›
text‹
The following combinator is a special case of both a parallel composition operator and a
range splitting operator. Its primary use case is when combining a policy with state transitions.
›
definition comp_ran_split :: "[('α ⇀ 'γ) × ('α ⇀'γ), 'd ↦ 'β] ⇒ ('d × 'α) ↦ ('β × 'γ)"
(infixr ‹⨂⇩∇› 100)
where "P ⨂⇩∇ p ≡ λx. case p (fst x) of
⌊allow y⌋ ⇒ (case ((fst P) (snd x)) of ⊥ ⇒ ⊥ | ⌊z⌋ ⇒ ⌊allow (y,z)⌋)
| ⌊deny y⌋ ⇒ (case ((snd P) (snd x)) of ⊥ ⇒ ⊥ | ⌊z⌋ ⇒ ⌊deny (y,z)⌋)
| ⊥ ⇒ ⊥"
text‹An alternative characterisation of the operator is as follows:›
lemma comp_ran_split_charn:
"(f, g) ⨂⇩∇ p = (
(((p ▹ Allow)⨂⇩∨⇩A (A⇩p f)) ⨁
((p ▹ Deny) ⨂⇩∨⇩A (D⇩p g))))"
apply (rule ext)
apply (simp add: comp_ran_split_def map_add_def o_def ran_restrict_def image_def
Allow_def Deny_def dom_restrict_def prod_orA_def
allow_pfun_def deny_pfun_def
split:option.splits decision.splits)
apply (auto)
done
subsection ‹Distributivity of the parallel combinators›
lemma distr_or1_a: "(F = F1 ⨁ F2) ⟹ (((N ⨂⇩1 F) o f) =
(((N ⨂⇩1 F1) o f) ⨁ ((N ⨂⇩1 F2) o f))) "
apply (rule ext)
apply (simp add: prod_1_def map_add_def
split: decision.splits option.splits)
subgoal for x
apply (case_tac "f x")
apply (simp_all add: prod_1_def map_add_def
split: decision.splits option.splits)
done
done
lemma distr_or1: "(F = F1 ⨁ F2) ⟹ ((g o_f ((N ⨂⇩1 F) o f)) =
((g o_f ((N ⨂⇩1 F1) o f)) ⨁ (g o_f ((N ⨂⇩1 F2) o f)))) "
apply (rule ext)+
apply (simp add: prod_1_def map_add_def policy_range_comp_def
split: decision.splits option.splits)
subgoal for x
apply (case_tac "f x")
apply (simp_all add: prod_1_def map_add_def
split: decision.splits option.splits)
done
done
lemma distr_or2_a: "(F = F1 ⨁ F2) ⟹ (((N ⨂⇩2 F) o f) =
(((N ⨂⇩2 F1) o f) ⨁ ((N ⨂⇩2 F2) o f))) "
apply (rule ext)
apply (simp add: prod_2_id_def prod_2_def map_add_def
split: decision.splits option.splits)
subgoal for x
apply (case_tac "f x")
apply (simp_all add: prod_2_def map_add_def
split: decision.splits option.splits)
done
done
lemma distr_or2: "(F = F1 ⨁ F2) ⟹ ((r o_f ((N ⨂⇩2 F) o f)) =
((r o_f ((N ⨂⇩2 F1) o f)) ⨁ (r o_f ((N ⨂⇩2 F2) o f)))) "
apply (rule ext)
apply (simp add: prod_2_id_def prod_2_def map_add_def policy_range_comp_def
split: decision.splits option.splits)
subgoal for x
apply (case_tac "f x")
apply (simp_all add: prod_2_def map_add_def
split: decision.splits option.splits)
done
done
lemma distr_orA: "(F = F1 ⨁ F2) ⟹ ((g o_f ((N ⨂⇩∨⇩A F) o f)) =
((g o_f ((N ⨂⇩∨⇩A F1) o f)) ⨁ (g o_f ((N ⨂⇩∨⇩A F2) o f)))) "
apply (rule ext)+
apply (simp add: prod_orA_def map_add_def policy_range_comp_def
split: decision.splits option.splits)
subgoal for x
apply (case_tac "f x")
apply (simp_all add: map_add_def
split: decision.splits option.splits)
done
done
lemma distr_orD: "(F = F1 ⨁ F2) ⟹ ((g o_f ((N ⨂⇩∨⇩D F) o f)) =
((g o_f ((N ⨂⇩∨⇩D F1) o f)) ⨁ (g o_f ((N ⨂⇩∨⇩D F2) o f)))) "
apply (rule ext)+
apply (simp add: prod_orD_def map_add_def policy_range_comp_def
split: decision.splits option.splits)
subgoal for x
apply (case_tac "f x")
apply (simp_all add: map_add_def
split: decision.splits option.splits)
done
done
lemma coerc_assoc: "(r o_f P) o d = r o_f (P o d)"
apply (simp add: policy_range_comp_def)
apply (rule ext)
apply (simp split: option.splits decision.splits)
done
lemmas ParallelDefs = prod_orA_def prod_orD_def prod_1_def prod_2_def parallel_map_def
parallel_st_def comp_ran_split_def
end