theory utp_pred imports
utp_expr_funcs
utp_subst
utp_meta_subst
utp_tactics begin
text‹ In this theory we begin to create an Isabelle version of the alphabetised predicate calculus
that is described in Chapter 1 of the UTP book~cite‹"Hoare&98"›. ›
subsection‹ Predicate type and syntax ›
text‹ An alphabetised predicate is a simply a boolean valued expression. ›
text‹ We want to remain as close as possible to the mathematical UTP syntax, but also
want to be conservative with HOL. For this reason we chose not to steal syntax
from HOL, but where possible use polymorphism to allow selection of the appropriate
operator (UTP vs. HOL). Thus we will first remove the standard syntax for conjunction,
disjunction, and negation, and replace these with adhoc overloaded definitions. We
similarly use polymorphic constants for the other predicate calculus operators. ›
purge_notation
conj (infixr‹∧›35) and
disj (infixr‹∨›30) and
Not (‹(‹open_block notation=‹prefix ¬››¬ _)› [40] 40)
adhoc_overloading
uconj ⇌ conj and
udisj ⇌ disj and
unot ⇌ Not
text‹ We set up two versions of each of the quantifiers: @{const uex} / @{const uall} and
@{const ushEx} / @{const ushAll}. The former pair allows quantification of UTP variables,
whilst the latter allows quantification of HOL variables in concert with the literal
expression constructor @{term "«x¬"}. Both varieties will be needed at various points.
Syntactically they are distinguished by a boldface quantifier
for the HOL versions (achieved by the "bold" escape in Isabelle). ›
translations "_uex x P" == "CONST uex x P" "_uex (_salphaset (_salphamk (x +L y))) P" <= "_uex (x +L y) P" "_uall x P" == "CONST uall x P" "_uall (_salphaset (_salphamk (x +L y))) P" <= "_uall (x +L y) P" "_ushEx x P" == "CONST ushEx (λ x. P)" "\<exists> x ∈ A ∙ P" => "\<exists> x ∙«x¬∈u A ∧ P" "_ushAll x P" == "CONST ushAll (λ x. P)" "\<forall> x ∈ A ∙ P" => "\<forall> x ∙«x¬∈u A ==> P" "\<forall> x | P ∙ Q" => "\<forall> x ∙ P ==> Q" "\<forall> x > y ∙ P" => "\<forall> x ∙«x¬ >u y ==> P" "\<forall> x < y ∙ P" => "\<forall> x ∙«x¬ <u y ==> P"
subsection‹ Predicate operators ›
text‹ We chose to maximally reuse definitions and laws built into HOL. For this reason,
when introducing the core operators we proceed by lifting operators from the
polymorphic algebraic hierarchy of HOL. Thus the initial definitions take
place in the context of type class instantiations. We first introduce our own
class called \emph{refine} that will add the refinement operator syntax to
the HOL partial order class. ›
class refine = order
abbreviation refineBy :: "'a::refine ==> 'a ==> bool" (infix‹⊑›50) where "P ⊑ Q ≡ less_eq Q P"
text‹ Since, on the whole, lattices in UTP are the opposite way up to the standard definitions
in HOL, we syntactically invert the lattice operators. This is the one exception where
we do steal HOL syntax, but I think it makes sense for UTP. Indeed we make this
inversion for all of the lattice operators. ›
text‹ Next we introduce the lattice operators, which is again done by lifting. ›
instantiation uexpr :: (lattice, type) lattice begin
lift_definition sup_uexpr :: "('a, 'b) uexpr ==> ('a, 'b) uexpr ==> ('a, 'b) uexpr" is"λP Q A. Lattices.sup (P A) (Q A)" .
lift_definition inf_uexpr :: "('a, 'b) uexpr ==> ('a, 'b) uexpr ==> ('a, 'b) uexpr" is"λP Q A. Lattices.inf (P A) (Q A)" . instance by (intro_classes) (transfer, auto)+ end
instantiation uexpr :: (bounded_lattice, type) bounded_lattice begin
lift_definition bot_uexpr :: "('a, 'b) uexpr"is"λ A. Orderings.bot" .
lift_definition top_uexpr :: "('a, 'b) uexpr"is"λ A. Orderings.top" . instance by (intro_classes) (transfer, auto)+ end
lemma top_uexpr_rep_eq [simp]: "[Orderings.bot]e b = False" by (transfer, auto)
lemma bot_uexpr_rep_eq [simp]: "[Orderings.top]e b = True" by (transfer, auto)
instance uexpr :: (distrib_lattice, type) distrib_lattice by (intro_classes) (transfer, rule ext, auto simp add: sup_inf_distrib1)
text‹ Finally we show that predicates form a Boolean algebra (under the lattice operators),
a complete lattice, a completely distribute lattice, and a complete boolean algebra. This
equip us with a very complete theory for basic logical propositions. ›
text‹ From the complete lattice, we can also define and give syntax for the fixed-point operators.
Like the lattice operators, these are reversed in UTP. ›
abbreviation Conj_upred :: "'α upred set ==> 'α upred" (‹∧_› [900] 900) where "∧ A ≡⊔ A"
abbreviation Disj_upred :: "'α upred set ==> 'α upred" (‹∨_› [900] 900) where "∨ A ≡⊓ A"
notation
conj_upred (infixr‹∧p›35) and
disj_upred (infixr‹∨p›30)
text‹ Perhaps slightly confusingly, the UTP infimum is the HOL supremum and vice-versa. This is
because, again, in UTP the lattice is inverted due to the definition of refinement and a desire
to have miracle at the top, and abort at the bottom. ›
lift_definition UINF :: "('a ==> 'α upred) ==> ('a ==> ('b::complete_lattice, 'α) uexpr) ==> ('b, 'α) uexpr" is"λ P F b. Sup {[F x]eb | x. [P x]eb}" .
lift_definition USUP :: "('a ==> 'α upred) ==> ('a ==> ('b::complete_lattice, 'α) uexpr) ==> ('b, 'α) uexpr" is"λ P F b. Inf {[F x]eb | x. [P x]eb}" .
translations "⊓ x | P ∙ F" => "CONST UINF (λ x. P) (λ x. F)" "⊓ x ∙ F" == "⊓ x | true ∙ F" "⊓ x ∙ F" == "⊓ x | true ∙ F" "⊓ x ∈ A ∙ F" => "⊓ x | «x¬∈u«A¬∙ F" "⊓ x ∈ A ∙ F" <= "⊓ x | «y¬∈u«A¬∙ F" "⊓ x | P ∙ F" <= "CONST UINF (λ y. P) (λ x. F)" "⊓ x | P ∙ F(x)" <= "CONST UINF (λ x. P) F" "⊔ x | P ∙ F" => "CONST USUP (λ x. P) (λ x. F)" "⊔ x ∙ F" == "⊔ x | true ∙ F" "⊔ x ∈ A ∙ F" => "⊔ x | «x¬∈u«A¬∙ F" "⊔ x ∈ A ∙ F" <= "⊔ x | «y¬∈u«A¬∙ F" "⊔ x | P ∙ F" <= "CONST USUP (λ y. P) (λ x. F)" "⊔ x | P ∙ F(x)" <= "CONST USUP (λ x. P) F"
text‹ We also define the other predicate operators ›
lift_definition impl::"'α upred ==> 'α upred ==> 'α upred"is "λ P Q A. P A ⟶ Q A" .
lift_definition iff_upred ::"'α upred ==> 'α upred ==> 'α upred"is "λ P Q A. P A ⟷ Q A" .
lift_definition ex :: "('a ==> 'α) ==> 'α upred ==> 'α upred"is "λ x P b. (∃ v. P(put b v))" .
lift_definition shEx ::"['β ==>'α upred] ==> 'α upred"is "λ P A. ∃ x. (P x) A" .
lift_definition all :: "('a ==> 'α) ==> 'α upred ==> 'α upred"is "λ x P b. (∀ v. P(put b v))" .
lift_definition shAll ::"['β ==>'α upred] ==> 'α upred"is "λ P A. ∀ x. (P x) A" .
text‹ We define the following operator which is dual of existential quantification. It hides the
valuation of variables other than $x$ through existential quantification. ›
lift_definition var_res :: "'α upred ==> ('a ==> 'α) ==> 'α upred"is "λ P x b. ∃ b'. P (b' ⊕L b on x)" .
syntax_consts "_uvar_res"⇌ var_res translations "_uvar_res P a"⇌"CONST var_res P a"
text‹ We have to add a u subscript to the closure operator as I don't want to override the syntax
for HOL lists (we'll be using them later). ›
lift_definition closure::"'α upred ==> 'α upred" (‹[_]u›) is "λ P A. ∀A'. P A'" .
lift_definition taut :: "'α upred ==> bool" (‹`_`›) is"λ P. ∀ A. P A" .
adhoc_overloading
utrue ⇌"true_upred"and
ufalse ⇌"false_upred"and
unot ⇌"not_upred"and
uconj ⇌"conj_upred"and
udisj ⇌"disj_upred"and
uimpl ⇌ impl and
uiff ⇌ iff_upred and
uex ⇌ ex and
uall ⇌ all and
ushEx ⇌ shEx and
ushAll ⇌ shAll
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.