Theory SML_Simple_Orders
section‹Relativization of the results about orders›
theory SML_Simple_Orders
imports
"../../Introduction"
"../Foundations/SML_Relations"
Complex_Main
begin
subsection‹Class \<^class>‹ord››
subsubsection‹Definitions and common properties›
locale ord_ow =
fixes U :: "'ao set"
and le :: "['ao, 'ao] ⇒ bool" (infix ‹≤⇩o⇩w› 50)
and ls :: "['ao, 'ao] ⇒ bool" (infix ‹<⇩o⇩w› 50)
begin
notation le (‹'(≤⇩o⇩w')›)
and le (infix ‹≤⇩o⇩w› 50)
and ls (‹'(<⇩o⇩w')›)
and ls (infix ‹<⇩o⇩w› 50)
abbreviation (input) ge (infix ‹≥⇩o⇩w› 50) where "x ≥⇩o⇩w y ≡ y ≤⇩o⇩w x"
abbreviation (input) gt (infix ‹>⇩o⇩w› 50) where "x >⇩o⇩w y ≡ y <⇩o⇩w x"
notation ge (‹'(≥⇩o⇩w')›)
and ge (infix ‹≥⇩o⇩w› 50)
and gt (‹'(>⇩o⇩w')›)
and gt (infix ‹>⇩o⇩w› 50)
tts_register_sbts ‹(≤⇩o⇩w)› | U
proof-
assume "Domainp AOA = (λx. x ∈ U)" "bi_unique AOA" "right_total AOA"
from tts_AA_eq_transfer[OF this] show ?thesis by auto
qed
tts_register_sbts ‹(<⇩o⇩w)› | U
proof-
assume "Domainp AOA = (λx. x ∈ U)" "bi_unique AOA" "right_total AOA"
from tts_AA_eq_transfer[OF this] show ?thesis by auto
qed
end
locale ord_pair_ow = ord⇩1: ord_ow U⇩1 le⇩1 ls⇩1 + ord⇩2: ord_ow U⇩2 le⇩2 ls⇩2
for U⇩1 :: "'ao set" and le⇩1 ls⇩1 and U⇩2 :: "'bo set" and le⇩2 ls⇩2
begin
notation le⇩1 (‹'(≤⇩o⇩w⇩.⇩1')›)
and le⇩1 (infix ‹≤⇩o⇩w⇩.⇩1› 50)
and ls⇩1 (‹'(<⇩o⇩w⇩.⇩1')›)
and ls⇩1 (infix ‹<⇩o⇩w⇩.⇩1› 50)
and le⇩2 (‹'(≤⇩o⇩w⇩.⇩2')›)
and le⇩2 (infix ‹≤⇩o⇩w⇩.⇩2› 50)
and ls⇩2 (‹'(<⇩o⇩w⇩.⇩2')›)
and ls⇩2 (infix ‹<⇩o⇩w⇩.⇩2› 50)
notation ord⇩1.ge (‹'(≥⇩o⇩w⇩.⇩1')›)
and ord⇩1.ge (infix ‹≥⇩o⇩w⇩.⇩1› 50)
and ord⇩1.gt (‹'(>⇩o⇩w⇩.⇩1')›)
and ord⇩1.gt (infix ‹>⇩o⇩w⇩.⇩1› 50)
and ord⇩2.ge (‹'(≥⇩o⇩w⇩.⇩2')›)
and ord⇩2.ge (infix ‹≥⇩o⇩w⇩.⇩2› 50)
and ord⇩2.gt (‹'(>⇩o⇩w⇩.⇩2')›)
and ord⇩2.gt (infix ‹>⇩o⇩w⇩.⇩2› 50)
end
ud ‹ord.lessThan› (‹(with _ : ({..<_}))› [1000] 10)
ud lessThan' ‹lessThan›
ud ‹ord.atMost› (‹(with _ : ({.._}))› [1000] 10)
ud atMost' ‹atMost›
ud ‹ord.greaterThan› (‹(with _ : ({_<..}))› [1000] 10)
ud greaterThan' ‹greaterThan›
ud ‹ord.atLeast› (‹(with _ : ({_..}))› [1000] 10)
ud atLeast' ‹atLeast›
ud ‹ord.greaterThanLessThan› (‹(with _ : ({_<..<_}))› [1000, 999, 1000] 10)
ud greaterThanLessThan' ‹greaterThanLessThan›
ud ‹ord.atLeastLessThan› (‹(with _ _ : ({_..<_}))› [1000, 999, 1000, 1000] 10)
ud atLeastLessThan' ‹atLeastLessThan›
ud ‹ord.greaterThanAtMost› (‹(with _ _ : ({_<.._}))› [1000, 999, 1000, 999] 10)
ud greaterThanAtMost' ‹greaterThanAtMost›
ud ‹ord.atLeastAtMost› (‹(with _ : ({_.._}))› [1000, 1000, 1000] 10)
ud atLeastAtMost' ‹atLeastAtMost›
ud ‹ord.min› (‹(with _ : «min» _ _)› [1000, 1000, 999] 10)
ud min' ‹min›
ud ‹ord.max› (‹(with _ : «max» _ _)› [1000, 1000, 999] 10)
ud max' ‹max›
ctr relativization
synthesis ctr_simps
assumes [transfer_domain_rule, transfer_rule]: "Domainp A = (λx. x ∈ U)"
and [transfer_rule]: "right_total A"
trp (?'a A)
in lessThan_ow: lessThan.with_def
(‹(on _ with _ : ({..<_}))› [1000, 1000, 1000] 10)
and atMost_ow: atMost.with_def
(‹(on _ with _ : ({.._}))› [1000, 1000, 1000] 10)
and greaterThan_ow: greaterThan.with_def
(‹(on _ with _: ({_<..}))› [1000, 1000, 1000] 10)
and atLeast_ow: atLeast.with_def
(‹(on _ with _ : ({_..}))› [1000, 1000, 1000] 10)
ctr relativization
synthesis ctr_simps
assumes [transfer_domain_rule, transfer_rule]: "Domainp A = (λx. x ∈ U)"
and [transfer_rule]: "bi_unique A" "right_total A"
trp (?'a A)
in greaterThanLessThan_ow: greaterThanLessThan.with_def
(‹(on _ with _ : ({_<..<_}))› [1000, 1000, 1000, 1000] 10)
and atLeastLessThan_ow: atLeastLessThan.with_def
(‹(on _ with _ _ : ({_..<_}))› [1000, 1000, 999, 1000, 1000] 10)
and greaterThanAtMost_ow: greaterThanAtMost.with_def
(‹(on _ with _ _ : ({_<.._}))› [1000, 1000, 999, 1000, 1000] 10)
and atLeastAtMost_ow: atLeastAtMost.with_def
(‹(on _ with _ : ({_.._}))› [1000, 1000, 1000, 1000] 10)
ctr parametricity
in min_ow: min.with_def
and max_ow: max.with_def
context ord_ow
begin
abbreviation lessThan :: "'ao ⇒ 'ao set" ("(1{..<⇩o⇩w_})")
where "{..<⇩o⇩w u} ≡ on U with (<⇩o⇩w) : {..<u}"
abbreviation atMost :: "'ao ⇒ 'ao set" ("(1{..⇩o⇩w_})")
where "{..⇩o⇩w u} ≡ on U with (≤⇩o⇩w) : {..u}"
abbreviation greaterThan :: "'ao ⇒ 'ao set" ("(1{_<⇩o⇩w..})")
where "{l<⇩o⇩w..} ≡ on U with (<⇩o⇩w) : {l<..}"
abbreviation atLeast :: "'ao ⇒ 'ao set" ("(1{_..⇩o⇩w})")
where "atLeast l ≡ on U with (≤⇩o⇩w) : {l..}"
abbreviation greaterThanLessThan :: "'ao ⇒ 'ao ⇒ 'ao set" ("(1{_<⇩o⇩w..<⇩o⇩w_})")
where "{l<⇩o⇩w..<⇩o⇩wu} ≡ on U with (<⇩o⇩w) : {l<..<u}"
abbreviation atLeastLessThan :: "'ao ⇒ 'ao ⇒ 'ao set" ("(1{_..<⇩o⇩w_})")
where "{l..<⇩o⇩w u} ≡ on U with (≤⇩o⇩w) (<⇩o⇩w) : {l<..u}"
abbreviation greaterThanAtMost :: "'ao ⇒ 'ao ⇒ 'ao set" ("(1{_<⇩o⇩w.._})")
where "{l<⇩o⇩w..u} ≡ on U with (≤⇩o⇩w) (<⇩o⇩w) : {l<..u}"
abbreviation atLeastAtMost :: "'ao ⇒ 'ao ⇒ 'ao set" ("(1{_..⇩o⇩w_})")
where "{l..⇩o⇩wu} ≡ on U with (≤⇩o⇩w) : {l..u}"
abbreviation min :: "'ao ⇒ 'ao ⇒ 'ao" where "min ≡ min.with (≤⇩o⇩w)"
abbreviation max :: "'ao ⇒ 'ao ⇒ 'ao" where "max ≡ max.with (≤⇩o⇩w)"
end
context ord_pair_ow
begin
notation ord⇩1.lessThan ("(1{..<⇩o⇩w⇩.⇩1_})")
notation ord⇩1.atMost ("(1{..⇩o⇩w⇩.⇩1_})")
notation ord⇩1.greaterThan ("(1{_<⇩o⇩w⇩.⇩1..})")
notation ord⇩1.atLeast ("(1{_..⇩o⇩w⇩.⇩1})")
notation ord⇩1.greaterThanLessThan ("(1{_<⇩o⇩w⇩.⇩1..<⇩o⇩w⇩.⇩1_})")
notation ord⇩1.atLeastLessThan ("(1{_..<⇩o⇩w⇩.⇩1_})")
notation ord⇩1.greaterThanAtMost ("(1{_<⇩o⇩w⇩.⇩1.._})")
notation ord⇩1.atLeastAtMost ("(1{_..⇩o⇩w⇩.⇩1_})")
notation ord⇩2.lessThan ("(1{..<⇩o⇩w⇩.⇩2_})")
notation ord⇩2.atMost ("(1{..⇩o⇩w⇩.⇩2_})")
notation ord⇩2.greaterThan ("(1{_<⇩o⇩w⇩.⇩2..})")
notation ord⇩2.atLeast ("(1{_..⇩o⇩w⇩.⇩2})")
notation ord⇩2.greaterThanLessThan ("(1{_<⇩o⇩w⇩.⇩2..<⇩o⇩w⇩.⇩2_})")
notation ord⇩2.atLeastLessThan ("(1{_..<⇩o⇩w⇩.⇩2_})")
notation ord⇩2.greaterThanAtMost ("(1{_<⇩o⇩w⇩.⇩2.._})")
notation ord⇩2.atLeastAtMost ("(1{_..⇩o⇩w⇩.⇩2_})")
end
subsection‹Preorders›
subsubsection‹Definitions and common properties›
locale partial_preordering_ow =
fixes U :: "'ao set"
and le :: "'ao ⇒ 'ao ⇒ bool" (infix "❙≤⇩o⇩w" 50)
assumes refl: "a ∈ U ⟹ a ❙≤⇩o⇩w a"
and trans: "⟦ a ∈ U; b ∈ U; c ∈ U; a ❙≤⇩o⇩w b; b ❙≤⇩o⇩w c ⟧ ⟹ a ❙≤⇩o⇩w c"
begin
notation le (infix "❙≤⇩o⇩w" 50)
end
locale preordering_ow = partial_preordering_ow U le
for U :: "'ao set"
and le :: "'ao ⇒ 'ao ⇒ bool" (infix "❙≤⇩o⇩w" 50) +
fixes ls :: ‹'ao ⇒ 'ao ⇒ bool› (infix "❙<⇩o⇩w" 50)
assumes strict_iff_not:
"⟦ a ∈ U; b ∈ U ⟧ ⟹ a ❙<⇩o⇩w b ⟷ a ❙≤⇩o⇩w b ∧ ¬ b ❙≤⇩o⇩w a"
locale preorder_ow = ord_ow U le ls
for U :: "'ao set" and le ls +
assumes less_le_not_le:
"⟦ x ∈ U; y ∈ U ⟧ ⟹ x <⇩o⇩w y ⟷ x ≤⇩o⇩w y ∧ ¬ (y ≤⇩o⇩w x)"
and order_refl[iff]: "x ∈ U ⟹ x ≤⇩o⇩w x"
and order_trans: "⟦ x ∈ U; y ∈ U; z ∈ U; x ≤⇩o⇩w y; y ≤⇩o⇩w z ⟧ ⟹ x ≤⇩o⇩w z"
begin
sublocale
order: preordering_ow U ‹(≤⇩o⇩w)› ‹(<⇩o⇩w)› +
dual_order: preordering_ow U ‹(≥⇩o⇩w)› ‹(>⇩o⇩w)›
apply unfold_locales
subgoal by auto
subgoal by (meson order_trans)
subgoal using less_le_not_le by simp
subgoal by (meson order_trans)
subgoal by (metis less_le_not_le)
done
end
locale ord_preorder_ow =
ord⇩1: ord_ow U⇩1 le⇩1 ls⇩1 + ord⇩2: preorder_ow U⇩2 le⇩2 ls⇩2
for U⇩1 :: "'ao set" and le⇩1 ls⇩1 and U⇩2 :: "'bo set" and le⇩2 ls⇩2
begin
sublocale ord_pair_ow .
end
locale preorder_pair_ow =
ord⇩1: preorder_ow U⇩1 le⇩1 ls⇩1 + ord⇩2: preorder_ow U⇩2 le⇩2 ls⇩2
for U⇩1 :: "'ao set" and le⇩1 and ls⇩1 and U⇩2 :: "'bo set" and le⇩2 and ls⇩2
begin
sublocale ord_preorder_ow ..
end
ud ‹preordering_bdd.bdd›
ud ‹preorder.bdd_above›
ud bdd_above' ‹bdd_above›
ud ‹preorder.bdd_below›
ud bdd_below' ‹bdd_below›
ctr relativization
synthesis ctr_simps
assumes [transfer_domain_rule, transfer_rule]: "Domainp A = (λx. x ∈ U)"
and [transfer_rule]: "right_total A"
trp (?'a A)
in bdd_ow: bdd.with_def
(‹(on _ with _ : «bdd» _)› [1000, 1000, 1000] 10)
and bdd_above_ow: bdd_above.with_def
(‹(on _ with _ : «bdd'_above» _)› [1000, 1000, 1000] 10)
and bdd_below_ow: bdd_below.with_def
(‹(on _ with _ : «bdd'_below» _)› [1000, 1000, 1000] 10)
declare bdd.with[ud_with del]
context preorder_ow
begin
abbreviation bdd_above :: "'ao set ⇒ bool"
where "bdd_above ≡ bdd_above_ow U (≤⇩o⇩w)"
abbreviation bdd_below :: "'ao set ⇒ bool"
where "bdd_below ≡ bdd_below_ow U (≤⇩o⇩w)"
end
subsubsection‹Transfer rules›
context
includes lifting_syntax
begin
lemma partial_preordering_transfer[transfer_rule]:
assumes [transfer_rule]: "right_total A"
shows
"((A ===> A ===> (=)) ===> (=))
(partial_preordering_ow (Collect (Domainp A))) partial_preordering"
unfolding partial_preordering_ow_def partial_preordering_def
apply transfer_prover_start
apply transfer_step+
by blast
lemma preordering_transfer[transfer_rule]:
assumes [transfer_rule]: "right_total A"
shows
"((A ===> A ===> (=)) ===> (A ===> A ===> (=)) ===> (=))
(preordering_ow (Collect (Domainp A))) preordering"
unfolding
preordering_ow_def preordering_ow_axioms_def
preordering_def preordering_axioms_def
apply transfer_prover_start
apply transfer_step+
by blast
lemma preorder_transfer[transfer_rule]:
assumes [transfer_rule]: "right_total A"
shows
"((A ===> A ===> (=)) ===> (A ===> A ===> (=)) ===> (=))
(preorder_ow (Collect (Domainp A))) class.preorder"
unfolding preorder_ow_def class.preorder_def
apply transfer_prover_start
apply transfer_step+
by blast
end
subsubsection‹Relativization›
context preordering_ow
begin
tts_context
tts: (?'a to U)
rewriting ctr_simps
substituting preordering_ow_axioms
eliminating through auto
begin
tts_lemma strict_implies_order:
assumes "a ∈ U" and "b ∈ U" and "a ❙<⇩o⇩w b"
shows "a ❙≤⇩o⇩w b"
is preordering.strict_implies_order.
tts_lemma irrefl:
assumes "a ∈ U"
shows "¬a ❙<⇩o⇩w a"
is preordering.irrefl.
tts_lemma asym:
assumes "a ∈ U" and "b ∈ U" and "a ❙<⇩o⇩w b" and "b ❙<⇩o⇩w a"
shows False
is preordering.asym.
tts_lemma strict_trans1:
assumes "a ∈ U" and "b ∈ U" and "c ∈ U" and "a ❙≤⇩o⇩w b" and "b ❙<⇩o⇩w c"
shows "a ❙<⇩o⇩w c"
is preordering.strict_trans1.
tts_lemma strict_trans2:
assumes "a ∈ U" and "b ∈ U" and "c ∈ U" and "a ❙<⇩o⇩w b" and "b ❙≤⇩o⇩w c"
shows "a ❙<⇩o⇩w c"
is preordering.strict_trans2.
tts_lemma strict_trans:
assumes "a ∈ U" and "b ∈ U" and "c ∈ U" and "a ❙<⇩o⇩w b" and "b ❙<⇩o⇩w c"
shows "a ❙<⇩o⇩w c"
is preordering.strict_trans.
end
end
context preorder_ow
begin
tts_context
tts: (?'a to U)
rewriting ctr_simps
substituting preorder_ow_axioms
eliminating through