Theory UC
theory UC
imports
RobustCompilation
begin
text "Note that we axiomatise some properties about probabilities and sums, for different reasons.
We axiomatize probabilities because HOL.Probability is difficult to use and may be to heavy-weight for simple probabilistic
languages that only have discrete probabilities. This makes it easier to plug them in, and the axioms are few and uncontroversial.
We axiomatise sums because HOL's builtin sum function guarantees (lemma infinite) to give 1 for infinite sets. This is unsuited, e.g., if a subset only consists
of zero probability traces or of traces with rapidly lowering probabilities. HOL does not yet include a sum function over infinite sets.
Countable_Set provides function to map to naturals and lemmas for closure properties, e.g., to show subsets are countable,
and perhaps this could be combined with infinite series to define such a sum and prove the necessary properties. Alas, we list those as
axioms here and proved them on paper.
"
locale UC =
fixes PrExec :: "'env ⇒ 'uc ctxt ⇒ 'uc prgm ⇒ bool ⇒ nat ⇒ real"
fixes PrExecT :: "'env ⇒ 'uc ctxt ⇒ 'uc prgm ⇒ 't ⇒ nat ⇒ real"
fixes β :: "'t ⇒ bool"
fixes Zcan :: "'t ⇒ 'env"
fixes nonprobabilistic :: "'env ⇒ bool"
fixes possible :: "'env ⇒ 't ⇒ nat ⇒ bool"
fixes csum :: "('t ⇒ real) ⇒ ('t set) ⇒ real option"
fixes csum2 :: "(('t×real×nat) ⇒ real) ⇒ (('t×real×nat) set) ⇒ real option"
assumes relation_uc:
"(A >< P) ↝ (t,p,n) ≡ (PrExecT (Zcan t) A P t n) = p ∧ p > 0"
and prefix_iff_trace_is_prefix:
"prefix (t::'t,p::real,n::int) ≡ prefix t"
assumes prefixes_contain_final_bit:
"PrExec Z A P b n = (case
(csum (λt. PrExecT Z A P t n) {t. prefix t ∧ β t = b}) of
None ⇒ -1 | Some x ⇒ x)"
and nonprobabilistic_envs_are_complete:
"(∃ Z b. PrExec Z A P b n ≠ PrExec Z S F b n) ⟶ (∃ Z' . PrExec Z' A P True n ≠ PrExec Z' S F True n ∧ nonprobabilistic Z')"
and construct_canonical_env:
"⟦nonprobabilistic Z; prefix t; possible Z t n ⟧ ⟹ PrExecT Z A P t n = PrExecT (Zcan t) A P t n"
and construct_canonical_env2:
"⟦prefix t ⟧ ⟹ PrExecT (Zcan t) A P t n = PrExec (Zcan t) A P True n"
and csum_reindex:
"∀ f g A B . bij_betw f A B ⟶ csum2 (g ∘ f) A = csum g B"
and csum2_cong:
"∀ A f g . (∀ x ∈ A :: ('t×real×nat) set . f x = g x) ⟶ (csum2 f A = csum2 g A)"
and csum_mono:
"∀ A f g fx gx . (∀ x ∈ A :: 't set . f x ≤ g x) ⟶
(csum f A = Some fx) ⟶ (csum g A = Some gx) ⟶ fx ≤ gx"
and unit_interval: "PrExec Z A P True n = 1- PrExec Z A P False n"
and unit_interval_min: "PrExec Z A P b n ≥ 0"
and PrExecT_unit_interval_min: "PrExecT Z A P t n≥ 0"
and possible: "⟦ PrExecT (Z::'env) (A::'uc ctxt) (P::'uc prgm) (t::'t) n > 0 ⟧ ⟹ possible Z t n"
and possible2: "⟦ possible Z t n ⟧ ⟹ PrExecT Z A P t n > 0 "
abbreviation comp_ind :: "(nat ⇒ real) ⇒ (nat ⇒ real) ⇒ bool" (infix "≈" 46)
where "f ≈ g ≡ (∀ (k::nat) . ∃ (N::nat) . ∀ (n::nat) > N . abs((f n) - (g n)) < 1/(n^k))"
locale compUC = UC +
fixes uct::"'uc itself"
fixes ZClass :: "'env set"
assumes env_fixes_io: "⟦nonprobabilistic Z; nonprobabilistic Z'; possible Z t n; possible Z t n⟧ ⟹
PrExecT (Z::'env) (A::'uc ctxt) (P::'uc prgm) (t::'t) n = PrExecT Z' A P t n"
and Zcan_nonprob: "nonprobabilistic (Zcan t)"
and Zcan_possible: "possible (Zcan t) t n"
and nonprobabilistic_envs_are_complete_comp:
"(∃ Z∈ZClass . ∃ b. PrExec Z A P b ≈ PrExec Z S F b) ⟶ (∃ Z'∈ZClass . PrExec Z' A P True ≈ PrExec Z' S F True ∧ nonprobabilistic Z')"
and nonprobabilistic_envs_are_sound_comp:
"(∃ Z∈ZClass . ∃ b. ¬(PrExec Z A P b ≈ PrExec Z S F b)) ⟶ (∃ Z'∈ZClass . ¬(PrExec Z' A P True ≈ PrExec Z' S F True) ∧ nonprobabilistic Z')"
locale compUCisRC = compUC +
fixes C :: "('uc,'uc) comp"
assumes "uct = (uct'::'uc itself)"
end