Theory IDE_CP_Reasoning1
chapter โนReasoning Processes in IDE-CP - Part Iโบ
text โนThe part includes small process that can be built without infrastructure of
IDE-CP, and declarations of other large process.โบ
theory IDE_CP_Reasoning1
imports Spec_Framework Phi_BI.Phi_BI
abbrevs "<subj-reasoning>" = "๐๐๐ป๐-๐๐พ๐บ๐๐๐๐๐๐"
begin
section โนAnnotations Guiding the Reasoningโบ
subsection โนSmall Annotationsโบ
subsubsection โนMatchesโบ
definition Assertion_Matches :: โน'a BI โ 'a BI โ 'a BIโบ (infixl "<matches>" 18)
where โน(S <matches> pattern) = Sโบ
text โนThe annotation marking on a target \<^term>โนY <matches> Aโบ in a ToA or a view shift
restricts that the source have to first match pattern โนAโบ.โบ
lemma [ฯreason 2000]:
โนMatches X A โน X ๐๐๐บ๐๐๐ฟ๐๐๐๐ Y ๐๐๐๐ P โน X ๐๐๐บ๐๐๐ฟ๐๐๐๐ (Y <matches> A) ๐๐๐๐ Pโบ
unfolding Assertion_Matches_def .
lemma [ฯreason 2000]:
โนMatches X A โน X ๐๐๐๐ฟ๐๐ Y ๐๐๐๐ P โน X ๐๐๐๐ฟ๐๐ (Y <matches> A) ๐๐๐๐ Pโบ
unfolding Assertion_Matches_def .
subsubsection โนUseless Tagโบ
definition USELESS :: โนbool โ boolโบ where โนUSELESS x = xโบ
lemma [simp]: โนUSELESS Trueโบ unfolding USELESS_def ..
text โนSimplification plays an important role in the programming in IDE_CP.
We use it to simplify the specification and evaluate the abstract state.
It is powerful as a transformation preserving all information,
but sometimes we expect the transformation is weaker and unequal by disposing
some useless information that we do not need.
For example, we want to rewrite \<^term>โนx โฆ Tโบ to \<^term>โนy โฆ Uโบ but the rewrite may be held
only with an additional proposition \<^term>โนUselessโบ which is useless for us,
\[ \<^prop>โนx โฆ T โก y โฆ U ๐๐๐ป๐ Uselessโบ \]
In cases like this, we can wrap the useless proposition by tag โนโนUSELESSโบโบ,
as \<^prop>โนx โฆ T โก y โฆ U ๐๐๐ป๐ USELESS Uselessโบ. The equality is still held because
\<^prop>โนUSELESS P โก Pโบ, but IDE-CP is configured to drop the \<^prop>โนUselessโบ
so the work space will not be polluted by helpless propositions.
โบ
subsubsection โนGenerated Rules during Reasoning or Programmingโบ
text โนAnnotate a rule generated during the programming, to differentiate from the normal
contextual facts. The normal facts are stored in โนฯlemmataโบ while the generated rules
are in โนฯgeneratedโบ (or maybe a better name like ฯgenerated_rules?)โบ
text โนTODO: update this
Note, the argument here means any ฯ-Type in the pre-condition, not necessary argument value.
If in a procedure or an implication rule or a view shift rule,
there is an argument where the procedure or the rule retains its structure,
this argument can be marked by \<^term>โนSMORPH argโบ.
Recall when applying the procedure or the rule, the reasoner extracts \<^term>โนargโบ from the
current ฯ-BI specification \<^term>โนXโบ of the current sequent.
This extraction may break \<^term>โนXโบ especially when the \<^term>โนargโบ to be extracted is
scattered and embedded in multiple ฯ-Types in \<^term>โนXโบ.
For example, extract \<^term>โน(x1, y2) โฆ (A1 * B2)โบ from
\<^term>โน((x1, x2) โฆ (A1 * A2)) * ((y1, (y2, y3)) โฆ (B1 * (B2 * B3)))โบ.
After the application, the following sequent will have broken structures because
the original structure of \<^term>โนXโบ is destroyed in order to extract \<^term>โนargโบ.
However, the structure of the new \<^term>โนarg'โบ may not changes.
If so, by reversing the extraction, it is possible to recovery the original structure of \<^term>โนXโบ,
only with changed value of the corresponding part of \<^term>โนargโบ in \<^term>โนXโบ.
The system supports multiple arguments to be marked by \<^term>โนSMORPH argโบ.
And the system applies the reverse morphism in the correct order.
A requirement is,
those structural-retained argument should locate at the end of the procedure's or the rule's
argument list. Or else, because the reasoner does not record the extraction morphism of
arguments not marked by \<^term>โนSMORPH argโบ, those arguments which occur after the
structural-retained arguments change the ฯ-BI specification by their extraction
causing the recorded morphism of previous \<^term>โนSMORPH argโบ mismatch the current
ฯ-BI specification and so possibly not able to be applied any more.
โบ
subsubsection โนBeta-reduction Hint for ฯ-Typeโบ
definition ฮฒ_Hint_for_ฯ (binder "ฮปโฉฮฒ " 10)
where โนฮฒ_Hint_for_ฯ f โก fโบ
text โนOccasionally, it can be convenient technically to use โนx โฆ (ฮปa. S a)โบ that will be ฮฒ-reduced
transparently to โนSโบ. The tag \<^const>โนฮฒ_Hint_for_ฯโบ allowing syntax โนx โฆ (ฮปโฉฮฒ a. S a)โบ hints
the reasoner to ฮฒ-reduce the ฯ-type term.โบ
lemma ฮฒ_Hint_for_ฯ[simp]:
โนx โฆ (ฮปโฉฮฒ y. S y) โก S xโบ
unfolding ฮฒ_Hint_for_ฯ_def ฯType_def .
paragraph โนIdentity_Elementโบ
lemma [ฯreason %cutting]:
โน Identity_ElementโฉI (S x) P
โน Identity_ElementโฉI (x โฆ (ฮปโฉฮฒ y. S y)) P โบ
by simp
lemma [ฯreason %cutting]:
โน Identity_ElementโฉE (S x)
โน Identity_ElementโฉE (x โฆ (ฮปโฉฮฒ y. S y)) โบ
by simp
paragraph โนTransformation Rulesโบ
lemma [ฯreason 1000]:
โน S x ๐๐๐บ๐๐๐ฟ๐๐๐๐ Y ๐๐๐๐ P
โน x โฆ (ฮปโฉฮฒ y. S y) ๐๐๐บ๐๐๐ฟ๐๐๐๐ Y ๐๐๐๐ P โบ
by simp
lemma [ฯreason 1000]:
โน S x ๐๐๐บ๐๐๐ฟ๐๐๐๐ Y ๐๐๐๐ P @tag ๐
โน x โฆ (ฮปโฉฮฒ y. S y) ๐๐๐บ๐๐๐ฟ๐๐๐๐ Y ๐๐๐๐ P @tag ๐ โบ
by simp
lemma [ฯreason 1000]:
โน S x * R ๐๐๐บ๐๐๐ฟ๐๐๐๐ Y ๐๐๐๐ P
โน (x โฆ (ฮปโฉฮฒ y. S y)) * R ๐๐๐บ๐๐๐ฟ๐๐๐๐ Y ๐๐๐๐ P โบ
by simp
lemma [ฯreason 1000]:
โน S x * R ๐๐๐บ๐๐๐ฟ๐๐๐๐ Y ๐๐๐๐ P @tag ๐
โน (x โฆ (ฮปโฉฮฒ y. S y)) * R ๐๐๐บ๐๐๐ฟ๐๐๐๐ Y ๐๐๐๐ P @tag ๐ โบ
by simp
lemma [ฯreason 1000]:
โน X ๐๐๐บ๐๐๐ฟ๐๐๐๐ S x ๐๐๐๐ P
โน X ๐๐๐บ๐๐๐ฟ๐๐๐๐ x โฆ (ฮปโฉฮฒ y. S y) ๐๐๐๐ P โบ
by simp
lemma [ฯreason 1000]:
โน X ๐๐๐บ๐๐๐ฟ๐๐๐๐ S x ๐๐๐๐ P @tag ๐
โน X ๐๐๐บ๐๐๐ฟ๐๐๐๐ x โฆ (ฮปโฉฮฒ y. S y) ๐๐๐๐ P @tag ๐ โบ
by simp
lemma [ฯreason 1000]:
โน X ๐๐๐บ๐๐๐ฟ๐๐๐๐ S x ๐๐พ๐๐บ๐๐๐ R ๐๐๐๐ P
โน X ๐๐๐บ๐๐๐ฟ๐๐๐๐ x โฆ (ฮปโฉฮฒ y. S y) ๐๐พ๐๐บ๐๐๐ R ๐๐๐๐ P โบ
by simp
lemma [ฯreason 1000]:
โน X ๐๐๐บ๐๐๐ฟ๐๐๐๐ S x ๐๐พ๐๐บ๐๐๐ R ๐๐๐๐ P @tag ๐
โน X ๐๐๐บ๐๐๐ฟ๐๐๐๐ x โฆ (ฮปโฉฮฒ y. S y) ๐๐พ๐๐บ๐๐๐ R ๐๐๐๐ P @tag ๐ โบ
by simp
section โนSmall Reasoning Processโบ
subsection โนAuxiliariesโบ
subsubsection โนSemantic Expansion of ฯ-Typesโบ
consts MODE_ฯEXPN :: mode
abbreviation ฯexpn_Premise ("<ฯexpn> _" [26] 26) where โนฯexpn_Premise โก Premise MODE_ฯEXPNโบ
ฯreasoner_ML ฯexpn_Premise 10 (โน<ฯexpn> ?Pโบ) = โน
Seq.ORELSE (
Phi_Reasoners.wrap (PLPR_Simplifier.simplifier (K Seq.empty) (fn ctxt =>
ctxt addsimps (Useful_Thms.get ctxt)) {fix_vars=false}),
Phi_Reasoners.wrap (PLPR_Simplifier.simplifier (K Seq.empty) (fn ctxt =>
Phi_Expansions.enhance (ctxt addsimps (Useful_Thms.get ctxt))) {fix_vars=false})) o snd
โบ
lemma Premise_MODE_ฯEXPN[iff]: โน<ฯexpn> Trueโบ
unfolding Premise_def ..
text โนAntecedent \<^prop>โน<ฯexpn> Pโบ indicates the reasoner solving the premise \<^prop>โนPโบ using
simplification rules of โนฯexpnsโบ.โบ
subsubsection โนName tag by typeโบ