Theory IDE_CP_Applications1
chapter βΉIDE-CP Functions \& Applications - Part IβΊ
theory IDE_CP_Applications1
imports IDE_CP_Core
keywords "val" :: quasi_command
abbrevs "<orelse>" = "πππΎπ
ππΎ"
and "<pattern>" = "ππΊπππΎππ"
and "<traverse>" = "πππΊππΎπππΎ"
and "<split>" = "πππ
ππ"
and "<strip>" = "πππππ"
and "<then>" = "πππΎπ"
and "<commute>" = "πΌππππππΎ"
and "<bubbling>" = "π»ππ»π»π
πππ"
and "<assoc>" = "πΊππππΌ"
and "<scalar>" = "ππΌπΊπ
πΊπ"
and "<open>" = "πππΎπ"
and "<makes>" = "ππΊππΎπ"
begin
text βΉ
Note: Our reasoning is a calculus of sequents, but not the sequent calculus.
The \<^prop>βΉX πππΊπππΏππππ YβΊ is a sequent βΉX β’ YβΊ.
TODO: Maybe we should rename the word 'sequent' in MLs to 'state' as it is proof state instead of a sequent.
TODO: move me somewhere
There are essentially two transformation mechanism in the system, β-free ToA and the To-Transformation.
β-free ToA is the major reasoning process in the system. It is between BI assertions and limited in
introducing existential quantification, i.e., it cannot open an abstraction.
This limitation is reasonable and also due to technical reasons.
When a transformation from βΉx β¦ TβΊ introduces existentially quantification, e.g., to βΉ{ y β¦ U |y. P y }βΊ,
it opens the abstraction of βΉx β¦ TβΊ.
The βΉxβΊ has no enough information to determine a unique value of βΉyβΊ but only a set of candidates,
which means the representation of βΉy β¦ UβΊ is more specific and therefore in a lower abstraction level.
For example, βΉx β¦ QβΊ is a rational number and βΉ{ (a,b) β¦ β€ Γ β€ |a b. a/b = x }βΊ is its representation.
As the major reasoning process in the system, the ToA reasoning should maintain the abstraction level,
and degenerate to a lower abstraction only when users ask so.
Reducing to a lower abstraction, should only happen when building the interfaces or internal
operations of the data structure.
Manually writing two annotations to open and to close the abstraction at the beginning and the ending
of the building of the interface, does not bring any thinking burden to users because the users of course
know, he is going to enter the representation of the abstraction in order to make the internal operation.
To-Transformation has capability to open an abstraction, as it supports the transformation introducing
existential quantification.
The technical difficulty to support introducing existential quantification is that, we instantiate
the existential quantification in the right side of a transformation goal to schematic variables
that can be instantiated to whatever later, so that we can enter the existential quantification
in the right and let the inner structure guide the next reasoning (like a goal-directed proof search).
The existential quantification at the left side is fixed before instantiating those in the right,
so the schematic variable can capture, i.e., can instantiate to any expression containing the fixed
existentially quantified variable of the left.
However, later when an existential quantification is introduced at the left side after
the instantiation of the right, the schematic variables cannot capture the new introduced existentially
quantified variables.
It is a deficiency of the current reasoning because it should not instantiate the right existential
quantification that early, but if we remain them, the quantifier brings a lot of troubles in the pattern
matching and the resolution of Ο-LPR. Just like the meta universal quantifier is specially processed
by the resolution of Isabelle's kernel, the handling of the existential quantification should also
be integrated in our resolution kernel, but it is hard and the performance would be a problem as
we cannot enter the kernel as what Isabelle's resolution does.
The expected resolution:
βΉA a βΉ X πππΊπππΏππππ Y aβΊ βΉX πππΊπππΏππππ βa. Y a βΉ BβΊ
-------------------------------------------------------
βΉβa. A a βΉ BβΊ
The To-Transformation is about a single Ο-type term βΉx β¦ TβΊ. Given a Ο-type βΉUβΊ, it transforms βΉx β¦ TβΊ
to a Ο-type term βΉy β¦ UβΊ with whatever βΉyβΊ it could be, or even a set βΉ{ y β¦ U | y. P y }βΊ.
-------------------------------------------------------------------------------------
ToA reasoning in the system by default does not change the abstraction level. Therefore, they are
writen in a function form βΉx β¦ T πππΊπππΏππππ f(x) β¦ UβΊ instead of a relation form
βΉx β¦ T πππΊπππΏππππ y β¦ U πππ»π y. r yβΊ. We also call this function form βΉββΊ-free ToA.
To open an abstraction, you can use To-Transformation:
β©βΉto βΉList OPENβΊβΊ, in order to open βΉList TβΊ into βΉList RepβΊ
you can also use β©βΉopen_abstraction βΉList _βΊβΊ which is a syntax sugar of βΉto βΉList OPENβΊβΊ
To make an abstraction, just give the desired form and it invokes the synthesis process,
β©βΉ βΉ_ β¦ MAKE UβΊ βΊ
Note you should not use To-Transformation to make an abstraction if the target βΉUβΊ that you want to make
requires to be assembled from more than one Ο-type terms. It is because To-Transformation is used
to transform the first Ο-type term βΉx β¦ TβΊ on your state sequent to whatever.
It considers the first Ο-type term only.
--------------------------------------------------------------------------------------
Ο-system provides 5 syntax to annotate Ο-types, or in another words, to invoke transformation.
βͺ to βΉthe target Ο-type you wantβΊ, it transforms the leading Ο-type term βΉx β¦ TβΊ to βΉ{ y β¦ U |y. P y}βΊ
for the given βΉUβΊ and a set of object βΉyβΊ it can be.
It can also generate program code to achieve the target.
For example, if the leading term is βΉx β¦ ββΊ, the βΉto FloatβΊ can
generate the program casting the integer.
βͺ is βΉthe expected objectβΊ, it transforms the leading Ο-type term βΉx β¦ TβΊ to βΉy β¦ TβΊ for the given y.
βͺ as βΉthe expected object β¦ the target Ο-typeβΊ, as βΉy β¦ UβΊ is a syntax sugar of
β©βΉto UβΊ followed by β©βΉis yβΊ.
βͺ assert βΉBI assertionβΊ, asserts the entire of the current state is what. It is pure transformation
and never generates code.
βͺ βΉx β¦ TβΊ, (directly giving a BI assertion without a leading keyword),
synthesis βΉx β¦ TβΊ using whatever terms in the current state.
It may generate program code.
βΊ
section βΉConventionβΊ
text βΉPriority:
βͺ 59: Fallback of Make Abstraction
βΊ
section βΉElements of ActionsβΊ
subsubsection βΉActions only for implication onlyβΊ
consts π_transformation :: βΉaction β actionβΊ
declare [[Οreason_default_pattern
βΉ?X πππΊπππΏππππ _ ππππ _ @tag π_transformation _βΊ β
βΉ?X πππΊπππΏππππ _ ππππ _ @tag π_transformation _βΊ (100)
and βΉ?X ππππΏππ _ ππππ _ @tag π_transformation _βΊ β
βΉ?X ππππΏππ _ ππππ _ @tag π_transformation _βΊ (100)
]]
lemma [Οreason 1010]:
βΉ X πππΊπππΏππππ Y ππππ P @tag action
βΉ X ππππΏππ Y ππππ P @tag π_transformation actionβΊ
unfolding Action_Tag_def
using view_shift_by_implication .
lemma [Οreason 1000]:
βΉ X πππΊπππΏππππ Y ππππ P @tag action
βΉ X πππΊπππΏππππ Y ππππ P @tag π_transformation actionβΊ
unfolding Action_Tag_def .
lemma [Οreason 1100]:
βΉ X πππΊπππΏππππ Y ππππ P @tag action
βΉ PROP Do_Action (π_transformation action)
(Trueprop (CurrentConstruction mode s H X))
(ππ»π
πππΊππππ True βΉ CurrentConstruction mode s H Y β§ P )βΊ
unfolding Do_Action_def Action_Tag_def Action_Tag_def
using Οapply_implication by blast
lemma [Οreason 1100]:
βΉ X πππΊπππΏππππ Y ππππ P @tag action
βΉ PROP Do_Action (π_transformation action)
(Trueprop (πΊπ»ππππΊπΌππππ(s) ππ X))
(ππ»π
πππΊππππ True βΉ (πΊπ»ππππΊπΌππππ(s) ππ Y) β§ P )βΊ
unfolding Do_Action_def Action_Tag_def Transformation_def ToA_Construction_def
by blast
subsubsection βΉView ShiftβΊ
consts π_view_shift_or_imp :: βΉaction β actionβΊ
lemma [Οreason 1100]:
βΉ X πππΊπππΏππππ Y ππππ P @tag action
βΉ PROP Do_Action (π_view_shift_or_imp action)
(Trueprop (πΊπ»ππππΊπΌππππ(s) ππ X))
(ππ»π
πππΊππππ True βΉ (πΊπ»ππππΊπΌππππ(s) ππ Y) β§ P )βΊ
unfolding Do_Action_def Action_Tag_def Transformation_def ToA_Construction_def
by blast
lemma do_π_view_shift_or_imp_VS:
βΉ X ππππΏππ Y ππππ P @tag action
βΉ PROP Do_Action (π_view_shift_or_imp action)
(Trueprop (CurrentConstruction mode s H X))
(ππ»π
πππΊππππ True βΉ CurrentConstruction mode s H Y β§ P )βΊ
unfolding Do_Action_def Action_Tag_def Action_Tag_def
using Οapply_view_shift by blast
lemma do_π_view_shift_or_imp_VS_degrade:
βΉ X πππΊπππΏππππ Y ππππ P @tag action
βΉ PROP Do_Action (π_view_shift_or_imp action)
(Trueprop (CurrentConstruction mode s H X))
(ππ»π
πππΊππππ True βΉ CurrentConstruction mode s H Y β§ P )βΊ
unfolding Do_Action_def Action_Tag_def Action_Tag_def
using Οapply_implication by blast
declare [[Οreason 1100 do_π_view_shift_or_imp_VS do_π_view_shift_or_imp_VS_degrade
for βΉPROP Do_Action (π_view_shift_or_imp ?action)
(Trueprop (CurrentConstruction ?mode ?s ?H ?X))
(PROP ?Result)βΊ]]
hide_fact do_π_view_shift_or_imp_VS do_π_view_shift_or_imp_VS_degrade
subsubsection βΉMorphismβΊ
consts π_morphism :: βΉaction β actionβΊ
lemma [Οreason 1100]:
βΉ X πππΊπππΏππππ Y ππππ P @tag π
βΉ PROP Do_Action (π_morphism π)
(Trueprop (πΊπ»ππππΊπΌππππ(s) ππ X))
(ππ»π
πππΊππππ True βΉ (πΊπ»ππππΊπΌππππ(s) ππ Y) β§ P )βΊ
unfolding Do_Action_def Action_Tag_def Transformation_def ToA_Construction_def
by blast
context begin
private lemma do_π_morphism_proc:
βΉ ππππΌ f β¦ S βΌ T' β¦ ππππππ E' @tag π
βΉ PROP Do_Action (π_morphism π)
(Trueprop (πΌππππΎππ blk [H] ππΎπππ
ππ ππ S))
( ππ»π
πππΊππππ True
βΉ PROP ΟApplication (Trueprop (ππππΌ f β¦ S βΌ T' β¦ ππππππ E' ))
(Trueprop (πΌππππΎππ blk [H] ππΎπππ
ππ ππ S)) (PROP Result)
βΉ PROP Result) βΊ
unfolding Do_Action_def Action_Tag_def ΟApplication_def
subgoal premises prems
by (rule prems(4), rule prems(2), rule prems(1)) .
private lemma do_π_morphism_VS:
βΉ X ππππΏππ Y ππππ P @tag π
βΉ PROP Do_Action (π_morphism π)
(Trueprop (CurrentConstruction mode s H X))
(ππ»π
πππΊππππ True βΉ CurrentConstruction mode s H Y β§ P )βΊ
unfolding Do_Action_def Action_Tag_def Action_Tag_def
using Οapply_view_shift by blast
private lemma do_π_morphism_ToA:
βΉ X πππΊπππΏππππ Y ππππ P @tag action
βΉ PROP Do_Action (π_morphism action)
(Trueprop (CurrentConstruction mode s H X))
(ππ»π
πππΊππππ True βΉ CurrentConstruction mode s H Y β§ P )βΊ
unfolding Do_Action_def Action_Tag_def Action_Tag_def
using Οapply_implication by blast
declare [[Οreason 1100 do_π_morphism_proc do_π_morphism_VS do_π_morphism_ToA
for βΉPROP Do_Action (π_morphism ?action)
(Trueprop (CurrentConstruction ?mode ?s ?H ?X))
(PROP ?Result)βΊ]]
end
subsubsection βΉNap, a space for injectionβΊ
consts πnap :: βΉaction β actionβΊ
lemma [Οreason 10]:
βΉ P @tag A
βΉ P @tag πnap AβΊ
unfolding Action_Tag_def .
subsubsection βΉActions for βΉββ§βΊ-free MTFβΊ
consts π_simple_MTF :: βΉaction β actionβΊ
declare [[Οreason_default_pattern
βΉ?X πππΊπππΏππππ _ ππππ _ @tag π_simple_MTF _βΊ β
βΉ?X πππΊπππΏππππ _ ππππ _ @tag π_simple_MTF _βΊ (100)
and βΉ?X ππππΏππ _ ππππ _ @tag π_simple_MTF _βΊ β
βΉ?X ππππΏππ _ ππππ _ @tag π_simple_MTF _βΊ (100)
]]
paragraph βΉImplicationβΊ
lemma [Οreason 1010]:
βΉ (πππΎππππΎ Q βΉ X πππΊπππΏππππ Y ππππ P @tag π_simple_MTF A)
βΉ X πππ»π Q πππΊπππΏππππ Y πππ»π Q ππππ P @tag π_simple_MTF AβΊ
unfolding Action_Tag_def Transformation_def
by (simp, blast)
lemma [Οreason 1010]:
βΉ (βx. X x πππΊπππΏππππ Y x ππππ P @tag π_simple_MTF A)
βΉ ExBI X πππΊπππΏππππ ExBI Y ππππ P @tag π_simple_MTF AβΊ
unfolding Action_Tag_def Transformation_def
by (simp, blast)
paragraph βΉView ShiftβΊ
lemma [Οreason 1010]:
βΉ (πππΎππππΎ Q βΉ X ππππΏππ Y ππππ P @tag π_simple_MTF A)
βΉ X πππ»π Q ππππΏππ Y πππ»π Q ππππ P @tag π_simple_MTF AβΊ
unfolding Action_Tag_def View_Shift_def
by (simp add: INTERP_SPEC_subj, blast)
lemma [Οreason 1010]:
βΉ (βx. X x ππππΏππ Y x ππππ P @tag π_simple_MTF A)
βΉ ExBI X ππππΏππ ExBI Y ππππ P @tag π_simple_MTF AβΊ
unfolding Action_Tag_def View_Shift_def
by (clarsimp simp add: INTERP_SPEC_ex, metis)
paragraph βΉFinishβΊ
lemma [Οreason 1000]:
βΉ XXX @tag A
βΉ XXX @tag π_simple_MTF AβΊ
unfolding Action_Tag_def .
subsubsection βΉActions for the leading item onlyβΊ
consts π_leading_item' :: βΉaction β actionβΊ
abbreviation βΉπ_leading_item A β‘ π_simple_MTF (π_leading_item' A)βΊ
declare [[Οreason_default_pattern
βΉ?X πππΊπππΏππππ _ ππππ _ @tag π_leading_item' _βΊ β
βΉ?X πππΊπππΏππππ _ ππππ _ @tag π_leading_item' _βΊ (100)
and βΉ?X ππππΏππ _ ππππ _ @tag π_leading_item' _βΊ β
βΉ?X ππππΏππ _ ππππ _ @tag π_leading_item' _βΊ (100)
]]
paragraph βΉImplicationβΊ
lemma [Οreason 1050]:
βΉ ERROR TEXT(βΉThere is no item!βΊ)
βΉ TECHNICAL X πππΊπππΏππππ Any ππππ P @tag π_leading_item' AβΊ
unfolding Action_Tag_def ERROR_def by blast
lemma [Οreason 1050]:
βΉ ERROR TEXT(βΉThere is no item!βΊ)
βΉ Void πππΊπππΏππππ Any ππππ P @tag π_leading_item' AβΊ
unfolding Action_Tag_def ERROR_def by blast
lemma [Οreason 1020]:
βΉ R πππΊπππΏππππ R' ππππ P @tag π_leading_item' A
βΉ (TECHNICAL X) * R πππΊπππΏππππ (TECHNICAL X) * R' ππππ P @tag π_leading_item' AβΊ
unfolding Action_Tag_def
using transformation_left_frame .
lemma [Οreason 1010]:
βΉ X πππΊπππΏππππ Y ππππ P @tag A
βΉ X * R πππΊπππΏππππ Y * R ππππ P @tag π_leading_item' AβΊ
unfolding Action_Tag_def
using transformation_right_frame .
lemma [Οreason 1000]:
βΉ X πππΊπππΏππππ Y ππππ P @tag A
βΉ X πππΊπππΏππππ Y ππππ P @tag π_leading_item' AβΊ
unfolding Action_Tag_def .
lemma [Οreason 1010]:
βΉ X πππΊπππΏππππ Y ππππ Q @tag A
βΉ X πππ»π P πππΊπππΏππππ Y πππ»π P ππππ Q @tag π_leading_item' AβΊ
unfolding Action_Tag_def Transformation_def
by clarsimp
paragraph βΉView ShiftβΊ
lemma [Οreason 1010]:
βΉ X ππππΏππ Y ππππ P @tag A
βΉ Xβ R ππππΏππ Yβ R ππππ P @tag π_leading_item' AβΊ
unfolding Action_Tag_def
using Οview_shift_intro_frame .
lemma [Οreason 1000]:
βΉ X ππππΏππ Y ππππ P @tag A
βΉ X ππππΏππ Y ππππ P @tag π_leading_item' AβΊ
unfolding Action_Tag_def .
lemma [Οreason 1010]:
βΉ X ππππΏππ Y ππππ Q @tag A
βΉ X πππ»π P ππππΏππ Y πππ»π P ππππ Q @tag π_leading_item' AβΊ
unfolding Action_Tag_def View_Shift_def
by (simp add: INTERP_SPEC_subj, blast)
subsubsection βΉMapping Ο-Type Items by View ShiftβΊ
declare [[Οreason_default_pattern
βΉ?X ππππΏππ _ ππππ _ @tag π_map_each_item _βΊ β
βΉ?X ππππΏππ _ ππππ _ @tag π_map_each_item _βΊ (100)
]]
paragraph βΉSupplemantaryβΊ
lemma [Οreason %π_map_each_item]:
βΉ TECHNICAL X πππΊπππΏππππ TECHNICAL X @tag π_map_each_item πβΊ
unfolding Action_Tag_def Technical_def
by simp
section βΉBasic ApplicationsβΊ
subsection βΉGeneral SyntaxβΊ
consts synt_orelse :: βΉ'a β 'b β 'aβΊ (infixr "πππΎπ
ππΎ" 30)
subsection βΉIs \& AssertβΊ
lemma is_Οapp:
βΉ ππΊππΊπ y
βΉ Object_Equiv T eq
βΉ πππΎππππΎ eq x y
βΉ x β¦ T πππΊπππΏππππ y β¦ T βΊ
unfolding Premise_def Object_Equiv_def
by blast
lemma assert_Οapp:
βΉππΊππΊπ Y βΉ π½π X πππΊπππΏππππ Y ππππ Any βΉ X πππΊπππΏππππ YβΊ
unfolding Action_Tag_def Do_def
using transformation_weaken by blast
subsection βΉSimplificationβΊ
subsubsection βΉBubblingβΊ
definition Bubbling :: βΉ'a β 'aβΊ ("π»ππ»π»π
πππ _" [61] 60) where βΉBubbling x = xβΊ
paragraph βΉGeneral RulesβΊ
lemma [Οreason default %Οsimp_fallback]:
βΉ x β¦ π»ππ»π»π
πππ T πππΊπππΏππππ x' β¦ T πππ»π x'. x' = x @tag πsimp βΊ
unfolding Action_Tag_def Bubbling_def Transformation_def
by simp
lemma [Οreason default %Οsimp_fallback]:
βΉ x β¦ T πππΊπππΏππππ x' β¦ π»ππ»π»π
πππ T πππ»π x'. x' = x @tag πbackward_simp βΊ
unfolding Action_Tag_def Bubbling_def Transformation_def
by simp
paragraph βΉBubbling ΟSepβΊ
abbreviation Bubbling_ΟSep (infixr "ββ©π" 70)
where "A ββ©π B β‘ π»ππ»π»π
πππ ΟProd A B"
lemma [Οreason %Οsimp_cut]:
βΉ NO_MATCH (Ua ββ©π Ub) U
βΉ x β¦ (Ta ββ©π Tb) β U πππΊπππΏππππ y β¦ (Ta β U) ββ©π Tb πππ»π y. y = ((fst (fst x), snd x), snd (fst x)) @tag πsimp βΊ
for U :: βΉ('c::sep_ab_semigroup,'a) ΟβΊ
unfolding Bubbling_def Action_Tag_def Transformation_def
by (cases x; clarsimp;
metis sep_disj_commuteI sep_disj_multD1 sep_disj_multI2 sep_mult_assoc sep_mult_commute)
lemma [Οreason %Οsimp_cut]:
βΉ NO_MATCH (Ta ββ©π Tb) T
βΉ x β¦ T β (Ua ββ©π Ub) πππΊπππΏππππ y β¦ (T β Ua) ββ©π Ub πππ»π y. y = ((fst x, fst (snd x)), snd (snd x)) @tag πsimp βΊ
for T :: βΉ('c::sep_semigroup,'a) ΟβΊ
unfolding Bubbling_def Action_Tag_def Transformation_def
by (cases x; clarsimp; insert sep_disj_multD1 sep_disj_multI1 sep_mult_assoc'; blast)
lemma [Οreason %Οsimp_cut+10]:
βΉ x β¦ (Ta ββ©π Tb) β (Ua ββ©π Ub) πππΊπππΏππππ y β¦ (Ta β Ua) ββ©π (Tb β Ub) πππ»π y.
y = ((fst (fst x), fst (snd x)), (snd (fst x), snd (snd x))) @tag πsimp βΊ
for Ta :: βΉ('c::sep_ab_semigroup,'a) ΟβΊ
unfolding Bubbling_def Action_Tag_def Transformation_def
by (cases x; clarsimp; smt (verit, ccfv_threshold) sep_disj_commuteI sep_disj_multD1
sep_disj_multI1 sep_mult_assoc' sep_mult_commute)
paragraph βΉTransformationβΊ
subparagraph βΉReduction in SourceβΊ
lemma [Οreason %ToA_red]:
βΉ x β¦ T πππΊπππΏππππ Y ππππ P
βΉ x β¦ π»ππ»π»π
πππ T πππΊπππΏππππ Y ππππ P βΊ
unfolding Bubbling_def .
lemma [Οreason %ToA_red]:
βΉ (x β¦ T) * R πππΊπππΏππππ Y ππππ P
βΉ (x β¦ π»ππ»π»π
πππ T) * R πππΊπππΏππππ Y ππππ P βΊ
unfolding Bubbling_def .
lemma [Οreason %ToA_red]:
βΉ x β¦ T βΌ W πππΊπππΏππππ Y ππππ P
βΉ x β¦ (π»ππ»π»π
πππ T) βΌ W πππΊπππΏππππ Y ππππ P βΊ
unfolding Bubbling_def .
subparagraph βΉReduction in TargetβΊ
lemma [Οreason %ToA_red]:
βΉ X πππΊπππΏππππ x β¦ T ππππ P
βΉ X πππΊπππΏππππ x β¦ π»ππ»π»π
πππ T ππππ P βΊ
unfolding Bubbling_def .
lemma [Οreason %ToA_red]:
βΉ X πππΊπππΏππππ x β¦ T ππΎππΊπππ R ππππ P
βΉ X πππΊπππΏππππ x β¦ π»ππ»π»π
πππ T ππΎππΊπππ R ππππ P βΊ
unfolding Bubbling_def .
lemma [Οreason %ToA_red]:
βΉ X πππΊπππΏππππ x β¦ T βΌ W ππππ P
βΉ X πππΊπππΏππππ x β¦ (π»ππ»π»π
πππ T) βΌ W ππππ P βΊ
unfolding Bubbling_def .
paragraph βΉVarious Properties of Bubbling TagβΊ
lemma [Οreason %abstract_domain]:
βΉ Abstract_Domain T D
βΉ Abstract_Domain (π»ππ»π»π
πππ T) D βΊ
unfolding Bubbling_def .
lemma [Οreason %abstract_domain]:
βΉ Abstract_Domainβ©L T D
βΉ Abstract_Domainβ©L (π»ππ»π»π
πππ T) D βΊ
unfolding Bubbling_def .
lemma [Οreason %identity_element_cut]:
βΉ Identity_Elementsβ©I T D P
βΉ Identity_Elementsβ©I (π»ππ»π»π
πππ T) D P βΊ
unfolding Bubbling_def .
lemma [Οreason %identity_element_cut]:
βΉ Identity_Elementsβ©E T D
βΉ Identity_Elementsβ©E (π»ππ»π»π
πππ T) D βΊ
unfolding Bubbling_def .
subsection βΉToβΊ
consts to :: βΉ('a,'b) Ο β actionβΊ
πpattern :: βΉ'redex β 'residue β ('c,'d) ΟβΊ ("ππΊπππΎππ _ β _" [42,42] 41)
πtraverse :: βΉ('a,'b) Ο β ('c,'d) ΟβΊ ("πππΊππΎπππΎ _" [30] 29)
πthen :: βΉ('a,'b) Ο β ('c,'d) Ο β ('c,'d) ΟβΊ (infixr "πππΎπ" 28)
πcommute :: βΉ'Οβ©F β 'Οβ©G β ('c,'a) ΟβΊ ("πΌππππππΎ")
Οreasoner_group To_ToA = (100, [0,4000]) for βΉx β¦ T πππΊπππΏππππ y β¦ U πππ»π y. r x y ππππ P @tag to UβΊ
βΉRules of To-Transformation that transforms βΉx β¦ TβΊ to βΉy β¦ UβΊ for certain βΉyβΊ constrained by a
relation with βΉxβΊ.βΊ
and To_ToA_fail = (0, [0,0]) in To_ToA and in fail
βΉFailure report in To-TransformationβΊ
and To_ToA_system_fallback = (1, [1,1]) in To_ToA > To_ToA_fail
βΉSystem To-Transformation rules falling back to normal transformation.βΊ
and To_ToA_fallback = (10, [2,20]) in To_ToA > To_ToA_system_fallback
βΉA general group allocating priority space for fallbacks of To-Transformation.βΊ
and To_ToA_derived = (50, [30,70]) in To_ToA > To_ToA_fallback and < default
βΉAutomatically derived To-Transformation rulesβΊ
and To_ToA_cut = (1000, [1000,1100]) in To_ToA
βΉCutting To-Transformation rulesβΊ
and To_ToA_success = (4000, [4000,4000]) in To_ToA > To_ToA_cut
βΉImmediate successβΊ
and To_ToA_user = (100, [80, 120]) in To_ToA and < To_ToA_cut and > To_ToA_system_fallback
βΉdefault group for user rulesβΊ
ML βΉfun mk_pattern_for_To_ToAformation ctxt term =
let val idx = Term.maxidx_of_term term + 1
fun chk_P (Const(\<^const_name>βΉTrueβΊ, _)) = Var(("P",idx), HOLogic.boolT)
| chk_P X = error ("To-Transformation should not contain a ππππ clause, but given\n" ^
Context.cases Syntax.string_of_term_global Syntax.string_of_term ctxt X)
val i = Unsynchronized.ref idx
fun relax (Const(N, _)) = (i := !i + 1; Const(N, TVar(("t",!i), [])))
| relax (A $ B) = relax A $ relax B
| relax (Abs(N,_,X)) = (i := !i + 1; Abs(N, TVar(("t",!i),[]), relax X))
| relax (Free X) = Free X
| relax (Var v) = Var v
| relax (Bound i) = Bound i
in case term
of Trueprop $ (Action_Tag $ (Trans $ X $ _ $ P) $ To_Tag) =>
SOME [Trueprop $ (Action_Tag
$ (relax Trans $ X $ Var(("Y",idx), TVar(("model",idx),[])) $ chk_P P)
$ relax To_Tag)]
endβΊ
declare [[
Οreason_default_pattern_ML βΉ?X πππΊπππΏππππ (y β¦ ?U πππ»π y. ?R y) ππππ ?P @tag to ?TβΊ β
βΉmk_pattern_for_To_ToAformationβΊ (100),
Οreason_default_pattern
βΉ?X @tag to ?AβΊ β βΉERROR TEXT(βΉMalformed To-Transformation: βΊ (?X @tag to ?A) β
βΉExpect: βΉ_ πππΊπππΏππππ (y β¦ ?Y πππ»π y. ?r y) @tag to _βΊβΊ)βΊ (1),
Οdefault_reasoner_group βΉ_ @tag to _βΊ : %To_ToA_user (100)
]]
subsubsection βΉSimplification ProtectβΊ
definition [simplification_protect]:
βΉΟTo_Transformation_Simp_Protect X U r A β‘ X πππΊπππΏππππ y β¦ U πππ»π y. r y @tag to AβΊ
lemma ΟTo_Transformation_Simp_Protect_cong[cong]:
βΉ X β‘ X'
βΉ U β‘ U'
βΉ r β‘ r'
βΉ ΟTo_Transformation_Simp_Protect X U r A β‘ ΟTo_Transformation_Simp_Protect X' U' r' A βΊ
by simp
subsubsection βΉExtracting PureβΊ
lemma [Οreason %extract_pure]:
βΉ πEIF A P
βΉ πEIF (A @tag to T) P βΊ
unfolding Action_Tag_def .
lemma [Οreason %extract_pure]:
βΉ πESC P A
βΉ πESC P (A @tag to T) βΊ
unfolding Action_Tag_def .
subsubsection βΉEntry PointβΊ
lemma to_Οapp:
βΉ ππΊππΊπ T
βΉ X πππΊπππΏππππ Ya ππππ P @tag π_leading_item (to T)
βΉ Ya πππΊπππΏππππ Y @tag π_apply_simplication
βΉ X πππΊπππΏππππ Y ππππ P βΊ
unfolding Do_def Action_Tag_def Transformation_def
by simp
lemmas "πππΊπππΏππππ_ππ_Οapp" = to_Οapp
subsubsection βΉTerminationβΊ
lemma ToA_trivial:
βΉx β¦ T πππΊπππΏππππ x' β¦ T πππ»π x'. x' = x @tag to anyβΊ
unfolding Action_Tag_def
by (simp add: ExBI_defined)
lemma [Οreason no explorative backtrack %To_ToA_fail for βΉ_ πππΊπππΏππππ _ ππππ _ @tag to _βΊ]:
βΉ TRACE_FAIL TEXT(βΉFail to transformβΊ X βΉtoβΊ T)
βΉ X πππΊπππΏππππ Y ππππ P @tag to TβΊ
unfolding Action_Tag_def TRACE_FAIL_def by blast
lemma [Οreason default %To_ToA_system_fallback]:
βΉ x β¦ T πππΊπππΏππππ y' β¦ U ππππ P
βΉ x β¦ T πππΊπππΏππππ y β¦ U πππ»π y. y = y' β§ P @tag to UβΊ
unfolding Action_Tag_def
by (simp add: ExBI_defined)
lemma [Οreason %To_ToA_success]:
βΉ x β¦ T πππΊπππΏππππ x' β¦ T πππ»π x'. x' = x @tag to TβΊ
unfolding Action_Tag_def
by (simp add: ExBI_defined)
subsubsection βΉSpecial FormsβΊ
lemma [Οreason %To_ToA_cut]:
βΉ (πΌπππ½πππππ C βΉ A πππΊπππΏππππ y β¦ Ua πππ»π y. ra y @tag to T)
βΉ (πΌπππ½πππππ Β¬ C βΉ B πππΊπππΏππππ y β¦ Ub πππ»π y. rb y @tag to T)
βΉ If C A B πππΊπππΏππππ y β¦ If C Ua Ub πππ»π y. (if C then ra y else rb y) @tag to TβΊ
unfolding Action_Tag_def Premise_def
by (cases C; simp)
lemma [Οreason %To_ToA_cut]:
βΉ (πΌπππ½πππππ C βΉ x β¦ A πππΊπππΏππππ y β¦ Ua πππ»π y. ra y @tag to T)
βΉ (πΌπππ½πππππ Β¬ C βΉ x β¦ B πππΊπππΏππππ y β¦ Ub πππ»π y. rb y @tag to T)
βΉ x β¦ If C A B πππΊπππΏππππ y β¦ If C Ua Ub πππ»π y. (if C then ra y else rb y) @tag to TβΊ
unfolding Action_Tag_def Premise_def
by (cases C; simp)
lemma [Οreason %To_ToA_cut for βΉ1 πππΊπππΏππππ _ ππππ _ @tag to _βΊ]:
βΉ () β¦ β πππΊπππΏππππ Y @tag to T
βΉ 1 πππΊπππΏππππ Y @tag to T βΊ
by simp
subsubsection βΉNo ChangeβΊ
consts πNO_CHANGE :: βΉ('a,'b) ΟβΊ ("ππ-πΌππΊπππΎ")
lemma [Οreason %To_ToA_cut]:
βΉx β¦ T πππΊπππΏππππ x' β¦ T πππ»π x'. x' = x @tag to ππ-πΌππΊπππΎ βΊ
unfolding Action_Tag_def
by (simp add: ExBI_defined)
lemma [Οreason !10]:
βΉx β¦ β πππΊπππΏππππ y β¦ β πππ»π y. True @tag to ππ-πΌππΊπππΎβΊ
unfolding Action_Tag_def Transformation_def
by simp
subsubsection βΉPatternβΊ
Οreasoner_group To_ToA_pattern_shortcut = (3000, [3000,3000]) in To_ToA and > To_ToA_cut βΉβΊ
context begin
private lemma π_strip_traverse:
βΉ X πππΊπππΏππππ Y @tag to A
βΉ X πππΊπππΏππππ Y @tag to (πππΊππΎπππΎ A) βΊ
unfolding Action_Tag_def .
private lemma π_pattern_meet:
βΉ x β¦ T πππΊπππΏππππ Y @tag to U
βΉ x β¦ T πππΊπππΏππππ Y @tag to (ππΊπππΎππ T β U) βΊ
unfolding Action_Tag_def .
private lemma π_pattern_meetβ©1:
βΉ x β¦ T p πππΊπππΏππππ Y @tag to (U p)
βΉ x β¦ T p πππΊπππΏππππ Y @tag to (ππΊπππΎππ T β U) βΊ
unfolding Action_Tag_def .
private lemma π_pattern_not_meet:
βΉ X πππΊπππΏππππ Y @tag to ππ-πΌππΊπππΎ
βΉ X πππΊπππΏππππ Y @tag to π βΊ
unfolding Action_Tag_def .
private lemma π_pattern_meet_this:
βΉ x β¦ T πππΊπππΏππππ Y @tag to U
βΉ x β¦ T πππΊπππΏππππ Y @tag to (ππΊπππΎππ T β U πππΎπ
ππΎ others) βΊ
unfolding Action_Tag_def .
private lemma π_pattern_meet_thisβ©1:
βΉ x β¦ T p πππΊπππΏππππ Y @tag to (U p)
βΉ x β¦ T p πππΊπππΏππππ Y @tag to (ππΊπππΎππ T β U πππΎπ
ππΎ others) βΊ
unfolding Action_Tag_def .
private lemma π_pattern_meet_that:
βΉ X πππΊπππΏππππ Y @tag to that
βΉ X πππΊπππΏππππ Y @tag to (this πππΎπ
ππΎ that) βΊ
unfolding Action_Tag_def .
Οreasoner_ML πpattern %To_ToA_pattern_shortcut
( βΉ_ β¦ _ πππΊπππΏππππ _ ππππ _ @tag to (ππΊπππΎππ _ β _)βΊ
| βΉ_ β¦ _ πππΊπππΏππππ _ ππππ _ @tag to (_ πππΎπ
ππΎ _)βΊ
| βΉ_ β¦ _ πππΊπππΏππππ _ ππππ _ @tag to (πππΊππΎπππΎ _)βΊ ) =
βΉfn (_, (ctxt, sequent)) => Seq.make (fn () =>
let fun parse_patterns (Const(\<^const_name>βΉsynt_orelseβΊ, _) $ X $ Y)
= parse_patterns X @ parse_patterns Y
| parse_patterns (Const(\<^const_name>βΉπpatternβΊ, _) $ Pat $ _) = [Pat]
| parse_patterns _ = []
val (bvs, ToA) = Phi_Help.strip_meta_hhf_bvs (Phi_Help.leading_antecedent' sequent)
val (T, A) = case ToA of _ $ (_
$ (Const _ $ (_ $ _ $ T) $ _ $ _)
$ (_ $ A))
=> (T, A)
val (is_traverse, A') = case A of Const(\<^const_name>βΉπtraverseβΊ, _) $ A' => (true, A')
| A' => (false, A')
val pats = parse_patterns A'
in if null pats then NONE
else
let val idx = Thm.maxidx_of sequent
val bvtys = map snd bvs
fun reconstruct_pattern redex =
let val param_redex = rev (#1 (dest_parameterized_phi_ty (fastype_of1 (bvtys,redex))))
fun reconstruct _ [] redex = Envir.beta_eta_contract redex
| reconstruct i (ty::param_tys) redex =
let val var = Var(("π",i+idx), bvtys ---> ty)
|> fold_index (fn (i, _) => fn X => X $ Bound i) bvtys
in reconstruct (i+1) param_tys (redex $ var)
end
in (length param_redex, reconstruct 0 param_redex redex)
end
val pats = map reconstruct_pattern pats
val len = length pats
val thy = Proof_Context.theory_of ctxt
fun meet_pattern rules (i,len) th =
if i = 0
then let val rule = if i = len - 1 then #1 rules else #2 rules
in rule RS th
end
else meet_pattern rules (i-1,len-1) (@{thm' π_pattern_meet_that} RS th)
fun meet_pattern' A i th =
meet_pattern A (i,len) (if is_traverse then @{thm' π_strip_traverse} RS th else th)
fun bad_pattern pat = error ("Bad Pattern: " ^ Syntax.string_of_term ctxt pat)
val const_heads = map_filter ((fn Const(N, _) => SOME N | _ => NONE) o Term.head_of o snd) pats
val free_heads = map_filter ((fn Free(N, _) => SOME N | _ => NONE) o Term.head_of o snd) pats
val cannot_shortcut = Phi_Syntax.exists_parameters_that_are_phi_types
(fn Const (N', _) => member (op =) const_heads N'
| Free (N', _) => member (op =) free_heads N'
| _ => false)
in case get_index (fn (param_num, pat) =>
if PLPR_Pattern.matches thy (K false) bvs (pat, T)
then SOME (case param_num of 0 => (@{thm' π_pattern_meet}, @{thm' π_pattern_meet_this})
| 1 => (@{thm' π_pattern_meetβ©1}, @{thm' π_pattern_meet_thisβ©1})
| _ => raise THM ("right now we only support patterns of upto 1 parameter", 1, [sequent]))
else NONE) pats
of NONE => if cannot_shortcut T then NONE
else (SOME ((ctxt, @{thm' ToA_trivial} RS sequent), Seq.empty)
handle THM _ =>
SOME ((ctxt, @{thm' π_pattern_not_meet} RS sequent), Seq.empty))
| SOME (i, rules) => SOME ((ctxt, meet_pattern' rules i sequent), Seq.empty)
end end
)βΊ
end
subsubsection βΉProductβΊ
text βΉBy default, the To-Transformation does not recognize βΉto (A β B β C)βΊ as a request of
permutation for instance βΉC β B β AβΊ (the search cost is huge!).
Instead, it recognizes the request as transforming βΉCβΊ to βΉAβΊ, βΉBβΊ to βΉBβΊ, and βΉCβΊ to βΉAβΊ element-wisely.
If you want to make the βΉA β B β CβΊ as a whole so that the system can do the permutation,
write it as βΉto (id (A β B β C))βΊ and a fallback will be encountered reducing the problem to
normal transformation.βΊ
lemma Prod_ToTransform[Οreason %To_ToA_cut]:
βΉ fst x β¦ T πππΊπππΏππππ x' β¦ T' πππ»π x'. ra x' @tag to A
βΉ snd x β¦ U πππΊπππΏππππ y' β¦ U' πππ»π y'. rb y' @tag to B
βΉ x β¦ (T β U) πππΊπππΏππππ xy' β¦ (T' β U') πππ»π xy'. ra (fst xy') β§ rb (snd xy') @tag to (A β B)βΊ
unfolding Action_Tag_def Transformation_def
by (cases x; simp; blast)
lemma Prod_ToTransform_rev:
βΉ fst x β¦ T πππΊπππΏππππ x' β¦ T' πππ»π x'. ra x' @tag to B
βΉ snd x β¦ U πππΊπππΏππππ y' β¦ U' πππ»π y'. rb y' @tag to A
βΉ x β¦ (T β U) πππΊπππΏππππ xy' β¦ (T' β U') πππ»π xy'. ra (fst xy') β§ rb (snd xy') @tag to (A β B)βΊ
unfolding Action_Tag_def Transformation_def
by (cases x; simp; blast)
lemma [Οreason %To_ToA_cut+10]:
βΉ fst x β¦ T πππΊπππΏππππ x' β¦ T' πππ»π x'. ra x' @tag to (πππΊππΎπππΎ Target)
βΉ snd x β¦ U πππΊπππΏππππ y' β¦ U' πππ»π y'. rb y' @tag to (πππΊππΎπππΎ Target)
βΉ x β¦ (T β U) πππΊπππΏππππ xy' β¦ (T' β U') πππ»π xy'. ra (fst xy') β§ rb (snd xy') @tag to (πππΊππΎπππΎ Target)βΊ
unfolding Action_Tag_def Transformation_def
by (cases x; simp; blast)
subsubsection βΉTo ItselfβΊ
declare [[Οreason_default_pattern
βΉ?X πππΊπππΏππππ (y β¦ _ πππ»π y. _) ππππ _ @tag to ItselfβΊ β βΉ?X πππΊπππΏππππ _ ππππ _ @tag to ItselfβΊ (200)
]]
lemma [Οreason default %To_ToA_fallback]:
βΉx β¦ T πππΊπππΏππππ v β¦ (Itself :: ('v,'v) Ο) πππ»π v. v β¨ (x β¦ T) @tag to (Itself :: ('v,'v) Ο)βΊ
unfolding Action_Tag_def Transformation_def
by simp
lemma [Οreason %To_ToA_cut]:
βΉ fst x β¦ T πππΊπππΏππππ x β¦ Itself πππ»π x. ra x @tag to (Itself :: ('c,'c) Ο)
βΉ snd x β¦ U πππΊπππΏππππ x β¦ Itself πππ»π x. rb x @tag to (Itself :: ('c,'c) Ο)
βΉ x β¦ T β U πππΊπππΏππππ x β¦ (Itself :: ('c::sep_magma,'c) Ο) πππ»π x.
(βa b. x = a * b β§ a ## b β§ rb b β§ ra a) @tag to (Itself :: ('c,'c) Ο) βΊ
unfolding Action_Tag_def Transformation_def
by (cases x; simp; blast)
paragraph βΉSpecial FormsβΊ
lemma [Οreason %To_ToA_cut]:
βΉ 1 πππΊπππΏππππ (y::'b::one) β¦ Itself πππ»π y. y = 1 @tag to (Itself :: ('b, 'b) Ο) βΊ
unfolding Action_Tag_def Transformation_def
by simp
lemma [Οreason %To_ToA_cut]:
βΉ (πΌπππ½πππππ C βΉ x β¦ A πππΊπππΏππππ (y :: 'a) β¦ Itself πππ»π y. ra y @tag to (Itself :: ('a,'a) Ο))
βΉ (πΌπππ½πππππ Β¬ C βΉ x β¦ B πππΊπππΏππππ y β¦ Itself πππ»π y. rb y @tag to (Itself :: ('a,'a) Ο))
βΉ x β¦ If C A B πππΊπππΏππππ y β¦ Itself πππ»π y. (if C then ra y else rb y) @tag to (Itself :: ('a,'a) Ο)βΊ
unfolding Action_Tag_def Transformation_def Premise_def
by simp
lemma [Οreason %To_ToA_cut]:
βΉx β¦ β€β©Ο πππΊπππΏππππ v β¦ Itself πππ»π v. True @tag to ItselfβΊ
unfolding Action_Tag_def Transformation_def
by simp
subsubsection βΉThen: Subsequent ExecutionβΊ
lemma [Οreason %To_ToA_cut]:
βΉ X πππΊπππΏππππ y β¦ U πππ»π y. r y @tag to π
βΉ (βy. πΌπππ½πππππ r y βΉ y β¦ U πππΊπππΏππππ z β¦ W πππ»π z. r' y z @tag to β¬)
βΉ X πππΊπππΏππππ z β¦ W πππ»π z. (βy. r y β§ r' y z) @tag to (π πππΎπ β¬) βΊ
unfolding Action_Tag_def Premise_def Transformation_def
by clarsimp blast
subsection βΉAsβΊ
lemma as_Οapp:
" ππΊππΊπ (y β¦ U)
βΉ x β¦ T πππΊπππΏππππ y' β¦ U πππ»π y'. P y' @tag to U
βΉ Object_Equiv U eq
βΉ πππΎππππΎ (βy'. P y' βΆ eq y' y)
βΉ x β¦ T πππΊπππΏππππ y β¦ U "
unfolding Premise_def Action_Tag_def Object_Equiv_def Transformation_def
by simp blast
subsection βΉCase AnalysisβΊ
consts πcase :: action
subsubsection βΉFrameworkβΊ
declare [[
Οreason_default_pattern
βΉ ?X πππΊπππΏππππ _ ππππ _ @tag πcase βΊ β βΉ ?X πππΊπππΏππππ _ ππππ _ @tag πcase βΊ (100)
and βΉ ?X ππππΏππ _ ππππ _ @tag πcase βΊ β βΉ ?X ππππΏππ _ ππππ _ @tag πcase βΊ (100)
and βΉ ππππΌ _ β¦ ?X βΌ _ β¦ ππππππ _ @tag πcase βΊ β βΉ ππππΌ _ β¦ ?X βΌ _ β¦ ππππππ _ @tag πcase βΊ (100)
and βΉ ?X @tag πcase βΊ β βΉERROR TEXT(βΉMalformed πcase ruleβΊ (?X @tag πcase))βΊ (0)
]]
lemma "_cases_app_rule_": βΉCall_Action (π_morphism πcase)βΊ ..
ML_file βΉlibrary/tools/induct_analysis.MLβΊ
hide_fact "_cases_app_rule_"
Οlang_parser case_analysis (%Οparser_unique, %Οlang_expr) ["case_analysis"] (βΉ_βΊ)
βΉ IDECP_Induct_Analysis.case_analysis_processor βΊ
subsubsection βΉCase RulesβΊ
lemma [Οreason 1000]:
βΉ πππΎπ A ππππΏππ Yβ©A
βΉ πππΎπ B ππππΏππ Yβ©B
βΉ π½π πππππ
ππΏπ[assertion_simps SOURCE] Y : Yβ©A + Yβ©B
βΉ B + A ππππΏππ Y @tag πcase βΊ
unfolding Argument_def Action_Tag_def Simplify_def View_Shift_def Do_def
by (simp add: distrib_right)
lemma [Οreason 1000]:
βΉ πππΎπ A πππΊπππΏππππ Yβ©A
βΉ πππΎπ B πππΊπππΏππππ Yβ©B
βΉ π½π πππππ
ππΏπ[assertion_simps SOURCE] Y : Yβ©A + Yβ©B
βΉ B + A πππΊπππΏππππ Y @tag πcase βΊ
unfolding Argument_def Action_Tag_def Simplify_def View_Shift_def Transformation_def Do_def
by simp
lemma [Οreason 1000]:
βΉ πππΎπ ππππΌ fβ©A β¦ A βΌ Yβ©A β¦ ππππππ Eβ©A
βΉ πππΎπ ππππΌ fβ©B β¦ B βΌ Yβ©B β¦ ππππππ Eβ©B
βΉ π½π πΌπππ½πππππ[procedure_ss] fβ©A = fβ©B
βΉ π½π πππππ
ππΏπ[assertion_simps SOURCE] Y : Yβ©A + Yβ©B
βΉ π½π πππππ
ππΏπ[assertion_simps ABNORMAL] E : Eβ©A + Eβ©B
βΉ ππππΌ fβ©A β¦ B + A βΌ Y β¦ ππππππ E @tag πcase βΊ
unfolding Action_Tag_def Simplify_def Premise_def Argument_def Do_def
by (simp, metis ΟCASE ΟCONSEQ add.commute plus_fun view_shift_refl view_shift_union(1))
lemma [Οreason 1000]:
βΉ (πππΎππππΎ P βΉ πππΎπ A ππππΏππ Ya)
βΉ (πππΎππππΎ Β¬ P βΉ πππΎπ B ππππΏππ Yb)
βΉ π½π If P Ya Yb πππΊπππΏππππ Y @tag invoke_br_join
βΉ If P A B ππππΏππ Y @tag πcaseβΊ
unfolding Argument_def Action_Tag_def Premise_def Do_def
apply (cases P; simp)
using Οview_trans view_shift_by_implication apply fastforce
using View_Shift_def view_shift_by_implication by force
lemma [Οreason 1000]:
βΉ (πππΎππππΎ P βΉ πππΎπ A πππΊπππΏππππ Ya)
βΉ (πππΎππππΎ Β¬ P βΉ πππΎπ B πππΊπππΏππππ Yb)
βΉ π½π If P Ya Yb πππΊπππΏππππ Y @tag invoke_br_join
βΉ If P A B πππΊπππΏππππ Y @tag πcaseβΊ
unfolding Argument_def Action_Tag_def Premise_def Do_def
apply (cases P; simp)
using transformation_trans apply fastforce
using transformation_trans by fastforce
lemma [Οreason default 0]:
βΉ FAIL TEXT(βΉDon't know how to case-splitβΊ X)
βΉ X πππΊπππΏππππ Y @tag πcaseβΊ
unfolding FAIL_def
by blast
subsection βΉOpen \& Make AbstractionβΊ
subsubsection βΉOpen AbstractionβΊ
definition OPEN :: βΉnat β 'x β 'xβΊ where βΉOPEN i X β‘ XβΊ
declare [[
Οreason_default_pattern
βΉ?X πππΊπππΏππππ ?Y ππππ ?P @tag OPEN ?i ?AβΊ β
βΉERROR TEXT(βΉMalformed ruleβΊ (?X πππΊπππΏππππ ?Y ππππ ?P @tag OPEN ?i ?A))βΊ (1)
and βΉ_ β¦ ?T πππΊπππΏππππ _ @tag OPEN _ π―π«βΊ β βΉ_ β¦ ?T πππΊπππΏππππ _ @tag OPEN _ π―π« βΊ (100)
and βΉ?var β¦ ?T πππΊπππΏππππ _ @tag OPEN _ π―π«'βΊ β βΉ_ β¦ ?T πππΊπππΏππππ _ @tag OPEN _ π―π«' βΊ (100)
]]
paragraph βΉSyntaxβΊ
syntax πππΎπ :: βΉlogicβΊ ("πππΎπ")
πππΎπ' :: βΉnat β logicβΊ ("πππΎπ'(_')")
parse_ast_translation βΉlet open Ast in [
(\<^syntax_const>βΉπππΎπβΊ, fn ctxt => fn args =>
Appl [Constant \<^const_syntax>βΉOPENβΊ,
Appl [Constant "_constrain", Constant \<^const_syntax>βΉPure.dummy_patternβΊ, Variable "\^E\^Fposition\^E<position>\^E\^F\^E"],
Appl [Constant "_constrain", Constant \<^const_syntax>βΉPure.dummy_patternβΊ, Variable "\^E\^Fposition\^E<position>\^E\^F\^E"]] ),
(\<^syntax_const>βΉπππΎπ'βΊ, fn ctxt => fn args =>
Appl [Constant \<^const_syntax>βΉOPENβΊ,
hd args,
Appl [Constant "_constrain", Constant \<^const_syntax>βΉPure.dummy_patternβΊ, Variable "\^E\^Fposition\^E<position>\^E\^F\^E"]] )
] endβΊ
paragraph βΉApplicationβΊ
lemma
[Οreason default %To_ToA_fallback for βΉ_ β¦ _ πππΊπππΏππππ _ ππππ _ @tag to (OPEN _ _)βΊ]:
βΉ FAIL TEXT(βΉFail to destruct Ο-typeβΊ T)
βΉ x β¦ Any πππΊπππΏππππ Y ππππ P @tag to (OPEN i T) βΊ
unfolding FAIL_def
by blast
paragraph βΉTransformationβΊ
Οreasoner_group
ToA_open_entry = (%ToA_splitting-30, [%ToA_splitting-30, %ToA_splitting-30]) βΉβΊ
and ToA_open_to_entry = (%To_ToA_derived-10, [%To_ToA_derived-10, %To_ToA_derived-10]) βΉβΊ
and ToA_open_all = (100, [10, 3000]) βΉβΊ
and ToA_open = (1020,[1000,1040]) in ToA_open_all βΉβΊ
and ToA_open_red = (2500, [2500, 2600]) in ToA_open_all and > ToA_open βΉβΊ
and ToA_open_fail = (10, [10,10]) in ToA_open_all and < ToA_open βΉβΊ
subparagraph βΉSystemβΊ
lemma [Οreason %ToA_open_to_entry for βΉ_ β¦ _ πππΊπππΏππππ _ ππππ _ @tag to (OPEN _ _)βΊ]:
βΉ x β¦ T πππΊπππΏππππ y' β¦ U @tag OPEN i π―π«'
βΉ x β¦ T πππΊπππΏππππ y β¦ U πππ»π y. y = y' @tag to (OPEN i T) βΊ
unfolding Action_Tag_def Simplify_def πGuard_def Premise_def
by simp
lemma [Οreason %ToA_open_red]:
βΉ x β¦ T πππΊπππΏππππ y β¦ U @tag OPEN i π―π«'
βΉ x β¦ ππΊπ
[v] T πππΊπππΏππππ y β¦ ππΊπ
[v] U @tag OPEN i π―π«' βΊ
unfolding Action_Tag_def Transformation_def
by simp
lemma [Οreason %ToA_open_entry]:
βΉ x β¦ T πππΊπππΏππππ OP @tag OPEN i π―π«
βΉ OP πππΊπππΏππππ Y ππππ P @tag π―π«
βΉ x β¦ OPEN i T πππΊπππΏππππ Y ππππ P @tag π―π« βΊ
unfolding Action_Tag_def OPEN_def
using mk_elim_transformation by blast
lemma [Οreason %ToA_open_entry]:
βΉ x β¦ T πππΊπππΏππππ OP @tag OPEN i π―π«
βΉ OP * W πππΊπππΏππππ Y ππππ P @tag π―π«
βΉ (x β¦ OPEN i T) * W πππΊπππΏππππ Y ππππ P @tag π―π« βΊ
unfolding Action_Tag_def OPEN_def
using mk_elim_transformation transformation_right_frame by blast
lemma [Οreason %ToA_open_entry]:
βΉ fst x β¦ T πππΊπππΏππππ m β¦ M @tag OPEN i π―π«'
βΉ (m, snd x) β¦ M βΌ W πππΊπππΏππππ R ππππ P @tag π―π«'
βΉ x β¦ OPEN i T βΌ W πππΊπππΏππππ R ππππ P @tag π―π«' βΊ
unfolding Action_Tag_def OPEN_def ΟProd'_def
by (smt (z3) ΟProd_expn' prod.exhaust_sel transformation_right_frame transformation_trans)
lemma [Οreason %ToA_open_red for βΉ_ πππΊπππΏππππ _ ππππ _ @tag OPEN undefined _βΊ]:
βΉ x β¦ T πππΊπππΏππππ Y ππππ P @tag OPEN some A
βΉ x β¦ T πππΊπππΏππππ Y ππππ P @tag OPEN undefined A βΊ
unfolding Action_Tag_def
by simp
lemma [Οreason %ToA_open_red for βΉ_ πππΊπππΏππππ _ ππππ _ @tag OPEN (Suc 0) _βΊ]:
βΉ x β¦ T πππΊπππΏππππ Y ππππ P @tag OPEN 1 A
βΉ x β¦ T πππΊπππΏππππ Y ππππ P @tag OPEN (Suc 0) A βΊ
unfolding Action_Tag_def
by simp
lemma [Οreason default %ToA_open_fail for βΉ_ πππΊπππΏππππ _ ππππ _ @tag OPEN _ _βΊ]:
βΉ ERROR TEXT(βΉtheβΊ i βΉth constructor ofβΊ T βΉis unknownβΊ)
βΉ x β¦ T πππΊπππΏππππ Y ππππ P @tag OPEN i A βΊ
unfolding ERROR_def by simp
paragraph βΉReasoning SetupβΊ
ML βΉ
structure Gen_Open_Abstraction_SS = Simpset (
val initial_ss = Simpset_Configure.Minimal_SS
val binding = SOME \<^binding>βΉgen_open_abstraction_simpsβΊ
val comment = "Simplification rules used when generating open-abstraction rules"
val attribute = NONE
val post_merging = I
) βΊ
setup βΉContext.theory_map (Gen_Open_Abstraction_SS.map (fn ctxt =>
ctxt addsimprocs [\<^simproc>βΉdefined_ExβΊ, \<^simproc>βΉdefined_AllβΊ, \<^simproc>βΉNO_MATCHβΊ]
addsimps @{thms' HOL.simp_thms}
|> Simplifier.add_cong @{thm' mk_symbol_cong}))βΊ
paragraph βΉRules of Various ReasoningβΊ
lemma [Οreason %extract_pure]:
βΉ x β¦ T ππππ
ππΎπ P
βΉ x β¦ OPEN i T ππππ
ππΎπ P βΊ
unfolding OPEN_def .
lemma [Οreason %extract_pure]:
βΉ P πππΏπΏππΌπΎπ x β¦ T
βΉ P πππΏπΏππΌπΎπ x β¦ OPEN i T βΊ
unfolding OPEN_def .
lemma [Οreason %abstract_domain]:
βΉ Abstract_Domain T D
βΉ Abstract_Domain (OPEN i T) D βΊ
unfolding OPEN_def .
lemma abstract_domain_OPEN:
βΉ (βx. x β¦ T πππΊπππΏππππ y β¦ U' πππ»π y. r x y @tag to (OPEN i T))
βΉ Abstract_Domain U' D
βΉ Abstract_Domain (OPEN i T) (Ξ»x. βy. r x y β§ D y) βΊ
unfolding OPEN_def Abstract_Domain_def Action_Tag_def πEIF_def Transformation_def Satisfiable_def
by clarsimp blast
lemma [Οreason %abstract_domain]:
βΉ Abstract_Domainβ©L T D
βΉ Abstract_Domainβ©L (OPEN i T) D βΊ
unfolding OPEN_def .
lemma [Οreason %identity_element_cut]:
βΉ Identity_Elementsβ©I T D P
βΉ Identity_Elementsβ©I (OPEN i T) D P βΊ
unfolding OPEN_def .
lemma [Οreason %identity_element_cut]:
βΉ Identity_Elementsβ©E T D
βΉ Identity_Elementsβ©E (OPEN i T) D βΊ
unfolding OPEN_def .
lemma Identity_Elementsβ©I_OPEN:
βΉ (βx. x β¦ T πππΊπππΏππππ y β¦ U πππ»π y. r x y @tag to (OPEN i T))
βΉ Identity_Elementsβ©I U D P
βΉ Identity_Elementsβ©I (OPEN i T) (Ξ»x. βy. r x y β§ D y) (Ξ»x. βy. r x y β§ P y) βΊ
unfolding Identity_Elementsβ©I_def Identity_Elementβ©I_def Transformation_def Action_Tag_def OPEN_def
by clarsimp blast
lemma [Οreason %Οfunctionality]:
βΉ Functionality T P
βΉ Functionality (OPEN i T) P βΊ
unfolding Functionality_def OPEN_def
by clarsimp
lemma Functionality_OPEN:
βΉ (βx. x β¦ T πππΊπππΏππππ y β¦ U πππ»π y. r x y @tag to (OPEN i T))
βΉ Functionality U P
βΉ Functionality (OPEN i T) (Ξ»x. (βy. r x y βΆ P y) β§ (βyβ©1 yβ©2. r x yβ©1 β§ r x yβ©2 βΆ yβ©1 = yβ©2)) βΊ
unfolding Functionality_def Action_Tag_def OPEN_def Transformation_def
by clarsimp metis
bundle Functionality_OPEN = Functionality_OPEN[Οreason %Οfunctionality+10]
lemma [Οreason %carrier_set_cut]:
βΉ Carrier_Set T D
βΉ Carrier_Set (OPEN i T) D βΊ
unfolding Carrier_Set_def Within_Carrier_Set_def Action_Tag_def OPEN_def
by clarsimp
lemma Carrier_Set_OPEN[Οreason %carrier_set_cut]:
βΉ (βx. x β¦ T πππΊπππΏππππ y β¦ U πππ»π y. r x y @tag to (OPEN i T))
βΉ Carrier_Set U D
βΉ Carrier_Set (OPEN i T) (Ξ»x. βy. r x y βΆ D y) βΊ
unfolding Carrier_Set_def Within_Carrier_Set_def Action_Tag_def Transformation_def OPEN_def
by clarsimp blast
bundle Carrier_Set_OPEN = Carrier_Set_OPEN[Οreason %carrier_set_cut+10]
subsubsection βΉMake AbstractionβΊ
text βΉApplies one step of constructingβΊ
definition MAKE :: βΉnat β 'x β 'xβΊ
where [assertion_simps_source, Οprogramming_simps]: βΉMAKE i X β‘ XβΊ
declare [[
Οreason_default_pattern
βΉ?X πππΊπππΏππππ ?Y ππππ ?P @tag MAKE ?i ?AβΊ β
βΉERROR TEXT(βΉMalformed ruleβΊ (?X πππΊπππΏππππ ?Y ππππ ?P @tag MAKE ?i ?A))βΊ (1)
and βΉ_ πππΊπππΏππππ _ β¦ ?T @tag MAKE _ π―π«βΊ β βΉ_ πππΊπππΏππππ _ β¦ ?T @tag MAKE _ π―π« βΊ (100)
and βΉ?var β¦ _ πππΊπππΏππππ _ β¦ ?T @tag MAKE _ π―π«'βΊ β βΉ_ β¦ _ πππΊπππΏππππ _ β¦ ?T @tag MAKE _ π―π«' βΊ (100)
]]
declare [[
Οreason_default_pattern βΉ?X πππΊπππΏππππ (y β¦ ?U πππ»π y. ?R y) ππππ _ @tag to (MAKE _ _)βΊ β
βΉERROR TEXT(βΉThere is no need to declare a To-Transformation rule for MAKE. Just use the normal ToA and synthesisβΊ)βΊ (200)
and βΉ_ πππΊπππΏππππ _ β¦ MAKE _ ?T ππππ _ @tag π―π« βΊ β βΉ_ πππΊπππΏππππ _ β¦ MAKE _ ?T ππππ _ @tag π―π« βΊ (700)
and βΉ_ πππΊπππΏππππ _ β¦ MAKE _ ?T ππΎππΊπππ _ ππππ _ @tag π―π« βΊ β
βΉ_ πππΊπππΏππππ _ β¦ MAKE _ ?T ππΎππΊπππ _ ππππ _ @tag π―π« βΊ (700)
and βΉ_ πππΊπππΏππππ _ β¦ β MAKE _ ?T ππππ _ @tag π―π« βΊ β βΉ_ πππΊπππΏππππ _ β¦ β MAKE _ ?T ππππ _ @tag π―π« βΊ (700)
and βΉ_ πππΊπππΏππππ _ β¦ β MAKE _ ?T ππΎππΊπππ _ ππππ _ @tag π―π« βΊ β
βΉ_ πππΊπππΏππππ _ β¦ β MAKE _ ?T ππΎππΊπππ _ ππππ _ @tag π―π« βΊ (700)
]]
Οreasoner_group ToA_Make_all = (100, [10, 3000]) βΉβΊ
and ToA_Make = (1020, [1000, 1040]) in ToA_Make_all βΉβΊ
and ToA_Make_fallback = (20, [10,30]) in ToA_Make_all and < ToA_Make βΉβΊ
and ToA_Make_norm = (2000, [2000,2200]) in ToA_Make_all and > ToA_Make βΉβΊ
and ToA_Make_top = (2800, [2800,2830]) in ToA_Make_all and > ToA_Make_norm βΉβΊ
and ToA_Make_entry = (%ToA_splitting_source+30, [%ToA_splitting_source+30, %ToA_splitting_source+30])
in ToA and > ToA_splitting_source and < ToA_splitting_target
βΉTransformation rules that making the annotated Ο-type. The tag βΉMAKEβΊ emphasizes the user's intention
to apply the Ο-type construction rules which are normally not activated in the usual reasoning.βΊ
ML_file βΉlibrary/syntax/make_and_open.MLβΊ
paragraph βΉSugarβΊ
Οlang_parser ππΊππΎπ (%Οparser_unique, 0) ["ππΊππΎπ"] (βΉPROP _βΊ)
βΉ fn s => Args.$$$ "ππΊππΎπ" |-- Scan.option (\<^keyword>βΉ(βΊ |-- Parse.nat --| \<^keyword>βΉ)βΊ) --
Parse.position (Parse.group (fn () => "term") (Parse.inner_syntax (Parse.cartouche || Parse.number)))
>> (fn (n,term) =>
phi_synthesis_parser s (fn _ => fn term =>
let val make = Const(\<^const_name>βΉMAKEβΊ, dummyT)
$ (case n of NONE => Term.dummy
| SOME N => HOLogic.mk_number \<^Type>βΉnatβΊ N)
fun mark ((t1 as Const(\<^const_name>βΉΟTypeβΊ, _)) $ t2 $ t3)
= t1 $ t2 $ (make $ t3)
| mark t3 = make $ t3
in mark term
end) term ) βΊ
paragraph βΉSystemβΊ
lemma [Οreason %ToA_Make_entry]:
βΉ M πππΊπππΏππππ x β¦ T @tag MAKE i π―π«
βΉ X πππΊπππΏππππ M ππππ P @tag π―π«
βΉ X πππΊπππΏππππ x β¦ MAKE i T ππππ P @tag π―π« βΊ
unfolding Action_Tag_def MAKE_def
using mk_intro_transformation by blast
lemma [Οreason %ToA_Make_entry]:
βΉ M πππΊπππΏππππ x β¦ T @tag MAKE i π―π«
βΉ πππππ
ππΏπ[assertion_simps TARGET] M' : Ξ¨[Some] M
βΉ X πππΊπππΏππππ M' ππππ P @tag π―π«
βΉ X πππΊπππΏππππ x β¦ β MAKE i T ππππ P @tag π―π« βΊ
unfolding Action_Tag_def MAKE_def Transformation_def Simplify_def
by simp blast
lemma [Οreason %ToA_Make_entry]:
βΉ M πππΊπππΏππππ x β¦ T @tag MAKE i π―π«
βΉ X πππΊπππΏππππ M ππΎππΊπππ R ππππ P @tag π―π«
βΉ X πππΊπππΏππππ x β¦ MAKE i T ππΎππΊπππ R ππππ P @tag π―π« βΊ
unfolding Action_Tag_def MAKE_def
by (smt (z3) REMAINS_expn Transformation_def sep_conj_expn)
lemma [Οreason %ToA_Make_entry]:
βΉ M πππΊπππΏππππ x β¦ T @tag MAKE i π―π«
βΉ πππππ
ππΏπ[assertion_simps TARGET] M' : Ξ¨[Some] M
βΉ X πππΊπππΏππππ M' ππΎππΊπππ R ππππ P @tag π―π«
βΉ X πππΊπππΏππππ x β¦ β MAKE i T ππΎππΊπππ R ππππ P @tag π―π« βΊ
unfolding Action_Tag_def MAKE_def Transformation_def Simplify_def
by simp meson
lemma [Οreason %ToA_Make_entry]:
βΉ fst m β¦ M πππΊπππΏππππ x β¦ T @tag MAKE i π―π«'
βΉ X πππΊπππΏππππ m β¦ M βΌ R @tag π―π«'
βΉ X πππΊπππΏππππ (x, snd m) β¦ MAKE i T βΌ R @tag π―π«' βΊ
unfolding Action_Tag_def MAKE_def ΟProd'_def
apply (simp add: ΟProd_expn'' ΟProd_expn')
using mk_intro_transformation transformation_right_frame by blast
lemma [Οreason default %ToA_Make_fallback for βΉ_ πππΊπππΏππππ _ @tag MAKE _ _βΊ]:
βΉ ERROR TEXT(βΉtheβΊ i βΉth constructor ofβΊ T βΉis unknownβΊ)
βΉ M πππΊπππΏππππ x β¦ T @tag MAKE i A βΊ
unfolding ERROR_def by simp
lemma [Οreason %ToA_Make_norm for βΉ_ πππΊπππΏππππ _ @tag MAKE undefined _βΊ]:
βΉ M πππΊπππΏππππ N @tag MAKE some A
βΉ M πππΊπππΏππππ N @tag MAKE undefined A βΊ
unfolding Action_Tag_def
by simp
lemma [Οreason %ToA_Make_norm for βΉ_ πππΊπππΏππππ _ @tag MAKE (Suc 0) _βΊ]:
βΉ M πππΊπππΏππππ N @tag MAKE 1 A
βΉ M πππΊπππΏππππ N @tag MAKE (Suc 0) A βΊ
unfolding Action_Tag_def
by simp
paragraph βΉReductions in SourceβΊ
text βΉβΉMAKEβΊ tag in source is senselessβΊ
lemma [Οreason %ToA_red]:
βΉ x β¦ T πππΊπππΏππππ Y ππππ P
βΉ x β¦ MAKE i T πππΊπππΏππππ Y ππππ P βΊ
unfolding MAKE_def
by simp
lemma [Οreason %ToA_red]:
βΉ x β¦ T βΌ W πππΊπππΏππππ Y ππππ P
βΉ x β¦ MAKE i T βΌ W πππΊπππΏππππ Y ππππ P βΊ
unfolding MAKE_def
by simp
paragraph βΉRules of Various ReasoningβΊ
lemma [Οreason %extract_pure]:
βΉ x β¦ T ππππ
ππΎπ P
βΉ x β¦ MAKE i T ππππ
ππΎπ P βΊ
unfolding MAKE_def .
lemma [Οreason %extract_pure]:
βΉ P πππΏπΏππΌπΎπ x β¦ T
βΉ P πππΏπΏππΌπΎπ x β¦ MAKE i T βΊ
unfolding MAKE_def .
lemma abstract_domain_MAKE:
βΉ (βx. X x πππΊπππΏππππ x β¦ MAKE i T ππππ PP)
βΉ (βx. D x πππΏπΏππΌπΎπ X x)
βΉ Abstract_Domainβ©L (MAKE i T) D βΊ
unfolding MAKE_def Abstract_Domainβ©L_def πESC_def Transformation_def Action_Tag_def Satisfiable_def
by clarsimp blast
Οreasoner_group abstract_domain_OPEN_MAKE = (%abstract_domain+100, [%abstract_domain+100, %abstract_domain+100])
in abstract_domain_all and > abstract_domain βΉβΊ
bundle abstract_domain_OPEN_MAKE =
abstract_domain_MAKE[Οadding_property = false,
Οreason %abstract_domain_OPEN_MAKE,
Οadding_property = true]
abstract_domain_OPEN[Οadding_property = false,
Οreason %abstract_domain_OPEN_MAKE,
Οadding_property = true]
lemma [Οreason %abstract_domain]:
βΉ Abstract_Domain T D
βΉ Abstract_Domain (MAKE i T) D βΊ
unfolding MAKE_def .
lemma [Οreason %identity_element_cut]:
βΉ Identity_Elementsβ©I T D P
βΉ Identity_Elementsβ©I (MAKE i T) D P βΊ
unfolding MAKE_def .
lemma [Οreason %identity_element_cut]:
βΉ Identity_Elementsβ©E T D
βΉ Identity_Elementsβ©E (MAKE i T) D βΊ
unfolding MAKE_def .
lemma Identity_Elementsβ©E_MAKE:
βΉ (βx. X x πππΊπππΏππππ x β¦ MAKE i T ππππ PP)
βΉ (βx. πππππ
ππΏπ[mode_embed_into_Οtype] (f x β¦ U) : X x)
βΉ Identity_Elementsβ©E U D
βΉ Identity_Elementsβ©E (MAKE i T) (D o f) βΊ
unfolding Identity_Elementsβ©E_def Simplify_def Transformation_def Identity_Elementβ©E_def
apply clarsimp
by metis
bundle Identity_Elements_OPEN_MAKE =
Identity_Elementsβ©I_OPEN [Οadding_property = false,
Οreason %identity_element_OPEN_MAKE,
Οadding_property = true]
Identity_Elementsβ©E_MAKE [Οadding_property = false,
Οreason %identity_element_OPEN_MAKE,
Οadding_property = true]
lemma [Οreason %carrier_set_cut]:
βΉ Carrier_Set T D
βΉ Carrier_Set (MAKE i T) D βΊ
unfolding Carrier_Set_def Within_Carrier_Set_def Action_Tag_def MAKE_def
by clarsimp
lemma [Οreason %Οfunctionality]:
βΉ Functionality T P
βΉ Functionality (MAKE i T) P βΊ
unfolding Functionality_def MAKE_def
by clarsimp
paragraph βΉSetup Synthesis ModuleβΊ
lemma [Οreason default %Οsynthesis_cut for βΉππππΌ _ β¦ _ βΌ Ξ»v. ?x β¦ MAKE ?i ?T ππΎππΊπππ ?R β¦ ππππππ _ @tag synthesisβΊ]:
βΉ S1 πππΊπππΏππππ x β¦ MAKE i T ππΎππΊπππ S2 ππππ Any
βΉ ππππΌ Return ΟV_none β¦ S1 βΌ Ξ»v. x β¦ MAKE i T ππΎππΊπππ S2 β¦ @tag synthesisβΊ
unfolding MAKE_def Action_Tag_def
using Ο__Return_rule__ view_shift_by_implication by blast
subsection βΉSplitβΊ
consts πassoc :: βΉ'a β 'b β modeβΊ
πscalar :: βΉ'a β 'b β modeβΊ
πsplit :: βΉmode β ('a,'b) ΟβΊ ("πππ
ππ[_]" [100] 1000)
abbreviation πsplit_default ("πππ
ππ")
where βΉπsplit_default β‘ πsplit defaultβΊ
abbreviation πsplit_assoc ("πππ
ππ-πΊππππΌ")
where βΉπsplit_assoc a b β‘ πsplit (πassoc a b)βΊ
abbreviation πsplit_scalar ("πππ
ππ-ππΌπΊπ
πΊπ")
where βΉπsplit_scalar a b β‘ πsplit (πscalar a b)βΊ
text βΉSyntax:
βͺ \<^term>βΉto (List (πππ
ππ β other))βΊ splits for instance \<^term>βΉList ((A β B) β other)βΊ into
\<^term>βΉList (A β other)βΊ and \<^term>βΉList (B β other)βΊ, leaving the \<^term>βΉotherβΊ unchanged.
βͺ \<^term>βΉto (πππΊππΎπππΎ ππΊπππΎππ pat β πππ
ππ)βΊ splits any sub-Οtype matching the pattern
βΊ
lemma [Οreason %To_ToA_cut]:
βΉ x β¦ T β U πππΊπππΏππππ x' β¦ T ββ©π U πππ»π x'. x' = x @tag to πππ
ππ βΊ
unfolding Action_Tag_def Transformation_def Bubbling_def
by (simp add: ExBI_defined)
subsection βΉDuplicate \& ShrinkβΊ
consts action_dup :: βΉactionβΊ
action_shrink :: βΉactionβΊ
action_drop :: βΉactionβΊ
lemma dup_Οapp:
βΉCall_Action (π_transformation (π_leading_item (π_structural_1_2 action_dup)))βΊ ..
lemma shrink_Οapp:
βΉCall_Action (π_transformation (multi_arity (π_structural_2_1 action_shrink)))βΊ ..
lemma drop_Οapp:
βΉCall_Action (π_view_shift_or_imp (multi_arity action_drop))βΊ ..
section βΉSupplementary of ReasoningβΊ
subsection βΉMake Abstraction from Raw RepresentationβΊ
text βΉPreviously, we introduced βΉto ItselfβΊ transformation which gives the mechanism reducing
an abstraction back to the concrete raw representation.
To be its counterpart, this section presents the mechanism recovering abstractions
from a raw concrete representation.βΊ
end