Theory UML_Void
theory UML_Void
imports "../UML_PropertyProfiles"
begin
section‹Basic Type Void: Operations›
text ‹This \emph{minimal} OCL type contains only two elements:
@{term "invalid"} and @{term "null"}.
@{term "Void"} could initially be defined as @{typ "unit option option"},
however the cardinal of this type is more than two, so it would have the cost to consider
‹Some None› and ‹Some (Some ())› seemingly everywhere.›
subsection‹Fundamental Properties on Voids: Strict Equality›
subsubsection‹Definition›
instantiation Void⇩b⇩a⇩s⇩e :: bot
begin
definition bot_Void_def: "(bot_class.bot :: Void⇩b⇩a⇩s⇩e) ≡ Abs_Void⇩b⇩a⇩s⇩e None"
instance proof show "∃x:: Void⇩b⇩a⇩s⇩e. x ≠ bot"
apply(rule_tac x="Abs_Void⇩b⇩a⇩s⇩e ⌊None⌋" in exI)
apply(simp add:bot_Void_def, subst Abs_Void⇩b⇩a⇩s⇩e_inject)
apply(simp_all add: null_option_def bot_option_def)
done
qed
end
instantiation Void⇩b⇩a⇩s⇩e :: null
begin
definition null_Void_def: "(null::Void⇩b⇩a⇩s⇩e) ≡ Abs_Void⇩b⇩a⇩s⇩e ⌊ None ⌋"
instance proof show "(null:: Void⇩b⇩a⇩s⇩e) ≠ bot"
apply(simp add:null_Void_def bot_Void_def, subst Abs_Void⇩b⇩a⇩s⇩e_inject)
apply(simp_all add: null_option_def bot_option_def)
done
qed
end
text‹The last basic operation belonging to the fundamental infrastructure
of a value-type in OCL is the weak equality, which is defined similar
to the @{typ "('𝔄)Void"}-case as strict extension of the strong equality:›
overloading StrictRefEq ≡ "StrictRefEq :: [('𝔄)Void,('𝔄)Void] ⇒ ('𝔄)Boolean"
begin
definition StrictRefEq⇩V⇩o⇩i⇩d[code_unfold] :
"(x::('𝔄)Void) ≐ y ≡ λ τ. if (υ x) τ = true τ ∧ (υ y) τ = true τ
then (x ≜ y) τ
else invalid τ"
end
text‹Property proof in terms of @{term "profile_bin⇩S⇩t⇩r⇩o⇩n⇩g⇩E⇩q_⇩v_⇩v"}›
interpretation StrictRefEq⇩V⇩o⇩i⇩d : profile_bin⇩S⇩t⇩r⇩o⇩n⇩g⇩E⇩q_⇩v_⇩v "λ x y. (x::('𝔄)Void) ≐ y"
by unfold_locales (auto simp: StrictRefEq⇩V⇩o⇩i⇩d)
subsection‹Basic Void Constants›
subsection‹Validity and Definedness Properties›
lemma "δ(null::('𝔄)Void) = false" by simp
lemma "υ(null::('𝔄)Void) = true" by simp
lemma [simp,code_unfold]: "δ (λ_. Abs_Void⇩b⇩a⇩s⇩e None) = false"
apply(simp add:defined_def true_def
bot_fun_def bot_option_def)
apply(rule ext, simp split:, intro conjI impI)
by(simp add: bot_Void_def)
lemma [simp,code_unfold]: "υ (λ_. Abs_Void⇩b⇩a⇩s⇩e None) = false"
apply(simp add:valid_def true_def
bot_fun_def bot_option_def)
apply(rule ext, simp split:, intro conjI impI)
by(simp add: bot_Void_def)
lemma [simp,code_unfold]: "δ (λ_. Abs_Void⇩b⇩a⇩s⇩e ⌊None⌋) = false"
apply(simp add:defined_def true_def
bot_fun_def bot_option_def null_fun_def null_option_def)
apply(rule ext, simp split:, intro conjI impI)
by(simp add: null_Void_def)
lemma [simp,code_unfold]: "υ (λ_. Abs_Void⇩b⇩a⇩s⇩e ⌊None⌋) = true"
apply(simp add:valid_def true_def
bot_fun_def bot_option_def)
apply(rule ext, simp split:, intro conjI impI)
by(metis null_Void_def null_is_valid, simp add: true_def)
subsection‹Test Statements›
Assert "τ ⊨ ((null::('𝔄)Void) ≐ null)"
end