Theory Spec_Framework
chapter โนSpecification Frameworkโบ
theory Spec_Framework
imports Phi_BI.Phi_BI "Phi_Semantics_Framework.Phi_Semantics_Framework"
keywords "fiction_space" :: thy_goal
abbrevs "<shifts>" = "๐๐๐๐ฟ๐๐"
and "<val>" = "๐๐บ๐
"
and "<vals>" = "๐๐บ๐
๐"
and "<typeof>" = "๐๐๐๐พ๐๐ฟ"
begin
subsubsection โนConfigurationโบ
declare [[ฯreason_default_pattern โนValid_Proc ?Fโบ โ โนValid_Proc ?Fโบ (100)]]
declare Valid_Proc_bind[ฯreason 1200]
declare ฯarg.simps[ฯsafe_simp] ฯarg.sel[ฯsafe_simp]
optional_translations (do_notation)
"_do_then t" <= "_do_bind (_constrain _idtdummy TY) t"
"_do_cons A (_do_cons B C)" <= "_do_cons (_do_cons A B) C"
syntax "_ฯV3" :: โนlogic โ logicโบ ("_โฉ'(โฉ3โฉ')")
"_ฯV4" :: โนlogic โ logicโบ ("_โฉ'(โฉ4โฉ')")
"_ฯV5" :: โนlogic โ logicโบ ("_โฉ'(โฉ5โฉ')")
"_ฯV6" :: โนlogic โ logicโบ ("_โฉ'(โฉ6โฉ')")
"_ฯV7" :: โนlogic โ logicโบ ("_โฉ'(โฉ7โฉ')")
optional_translations (do_notation)
"xโฉ(โฉ2โฉ)" <= "xโฉ(โฉ2โฉ)โฉ(โฉ1โฉ)"
"xโฉ(โฉ3โฉ)" <= "xโฉ(โฉ2โฉ)โฉ(โฉ2โฉ)"
"xโฉ(โฉ4โฉ)" <= "xโฉ(โฉ2โฉ)โฉ(โฉ3โฉ)"
"xโฉ(โฉ5โฉ)" <= "xโฉ(โฉ2โฉ)โฉ(โฉ4โฉ)"
"xโฉ(โฉ6โฉ)" <= "xโฉ(โฉ2โฉ)โฉ(โฉ5โฉ)"
"xโฉ(โฉ7โฉ)" <= "xโฉ(โฉ2โฉ)โฉ(โฉ6โฉ)"
"x" <= "CONST ฯarg x"
print_translation โน[
(\<^const_syntax>โนbind_doโบ, fn _ => (
fn [A, Const ("_abs", _) $ _ $ _] => raise Match
| [_, Abs _] => raise Match
| [A, B] =>
Const(\<^const_syntax>โนbind_doโบ, dummyT)
$ A
$ (case Syntax_Trans.atomic_abs_tr' ("_", dummyT, Term.incr_boundvars 1 B $ Bound 0)
of (f,x) => Const(\<^syntax_const>โน_absโบ, dummyT) $ f $ x) ))
]โบ
section โนFictionโบ
unspecified_type FIC
unspecified_type FIC_N
type_synonym fiction = โนFIC_N โ FICโบ
type_synonym 'a assertion = โน'a BIโบ
type_synonym assn = โนfiction BIโบ
type_synonym rassn = โนresource BIโบ
type_synonym 'T fiction_entry = "(FIC_N, FIC, 'T) Resource_Space.kind"
setup โนSign.mandatory_path "FIC"โบ
consts DOMAIN :: โนFIC_N โ FIC sep_homo_setโบ
debt_axiomatization sort: โนOFCLASS(FIC, sep_algebra_class)โบ
setup โนSign.parent_pathโบ
instance FIC :: sep_algebra using FIC.sort .
instantiation FIC :: sep_carrier_1 begin
definition mul_carrier_FIC :: โนFIC โ boolโบ where โนmul_carrier_FIC = (ฮป_. True)โบ
instance by (standard; simp add: mul_carrier_FIC_def)
end
consts INTERPRET :: โนFIC_N โ (FIC, resource) unital_homo_interpโบ
interpretation FIC: fictional_space FIC.DOMAIN INTERPRET .
definition "INTERP_RES fic โก BI_lift RES.SPACE โ FIC.INTERP fic ๐๐๐ป๐ fic โ FIC.SPACE"
lemma In_INTERP_RES:
โนr โจ INTERP_RES fic โท r โ RES.SPACE โง fic โ FIC.SPACE โง r โจ FIC.INTERP ficโบ
unfolding INTERP_RES_def by simp blast
definition INTERP_SPEC :: โนassn โ rassnโบ
where "INTERP_SPEC T = BI_Monad_Comb (INTERP_RES `โฉI T)"
lemma INTERP_SPEC:
โนres โจ INTERP_SPEC T โท (โfic. fic โจ T โง res โจ INTERP_RES fic)โบ
unfolding INTERP_SPEC_def
by simp blast
lemma INTERP_SPEC_sub[intro, simp]: โนA โค B โน INTERP_SPEC A โค INTERP_SPEC Bโบ
unfolding INTERP_SPEC_def less_eq_BI_iff by simp blast
lemma INTERP_SPEC_plus[iff]:
โนINTERP_SPEC (A + B) = INTERP_SPEC A + INTERP_SPEC Bโบ
unfolding BI_eq_iff
by (simp add: INTERP_SPEC) blast
lemma INTERP_SPEC_0[iff]:
โน INTERP_SPEC 0 = 0 โบ
unfolding BI_eq_iff
by (simp add: INTERP_SPEC)
ML_file โนlibrary/spec_framework/fiction_space.MLโบ
ML_file โนlibrary/spec_framework/fiction_space_more.MLโบ
ML โนFiction_Space.define_command \<^command_keyword>โนfiction_spaceโบ "extend fictions"โบ
section โนSpecification of Valueโบ
type_synonym value_assertion = โนVAL BIโบ
subsection โนPrimitive ฯ-Typesโบ
subsubsection โนValueโบ
definition Val :: โนVAL ฯarg โ (VAL, 'a) ฯ โ ('x::one, 'a) ฯโบ ("๐๐บ๐
[_] _" [22,22] 21)
where โนVal val T = (ฮปx. 1 ๐๐๐ป๐ ฯarg.dest val โจ (x โฆ T))โบ
definition Vals :: โนVAL list ฯarg โ (VAL list, 'a) ฯ โ ('x::one, 'a) ฯโบ ("๐๐บ๐
๐[_] _" [22,22] 21)
where โนVals vals T = (ฮปx. 1 ๐๐๐ป๐ ฯarg.dest vals โจ (x โฆ T))โบ
lemma Val_expn [simp, ฯexpns]:
โนv โจ (x โฆ Val val T) โท v = 1 โง ฯarg.dest val โจ (x โฆ T)โบ
unfolding Val_def ฯType_def by simp
lemma Vals_expn [simp, ฯexpns]:
โนv โจ (x โฆ Vals val T) โท v = 1 โง ฯarg.dest val โจ (x โฆ T)โบ
unfolding Vals_def ฯType_def by simp
lemma Val_inh_rewr:
โนSatisfiable (x โฆ Val val T) โก ฯarg.dest val โจ (x โฆ T)โบ
unfolding Satisfiable_def by clarsimp
lemma Vals_inh_rewr:
โนSatisfiable (x โฆ Vals val T) โก ฯarg.dest val โจ (x โฆ T)โบ
unfolding Satisfiable_def by clarsimp
paragraph โนSyntaxโบ
consts anonymous :: 'a
syntax val_syntax :: "logic โ logic" ("๐๐บ๐
_" [22] 21)
vals_syntax :: "logic โ logic" ("๐๐บ๐
๐ _" [22] 21)
translations
"๐๐บ๐
x โฆ T" => "x โฆ CONST Val (CONST anonymous) T"
"๐๐บ๐
T" => "CONST Val (CONST anonymous) T"
"๐๐บ๐
๐ x โฆ T" => "x โฆ CONST Vals (CONST anonymous) T"
"๐๐บ๐
๐ T" => "CONST Vals (CONST anonymous) T"
ML_file โนlibrary/syntax/value.MLโบ
subsubsection โนAbnormalโบ
definition AbnormalObj :: โนVAL ฯarg โ (VAL, 'a) ฯ โ ('x::one, 'a) ฯโบ
where โนAbnormalObj โก Valโบ
subsection โนSemantic Typeโบ
consts Type_Of_syntax :: โน'a โ TYโบ ("๐๐๐๐พ๐๐ฟ")
definition Semantic_Type :: โน(VAL, 'x) ฯ โ TY โ boolโบ
where โนSemantic_Type T TY โก (โx v. v โจ (x โฆ T) โถ v โ Well_Type TY) โบ
definition Semantic_Type' :: โนVAL BI โ TY โ boolโบ
where โนSemantic_Type' A TY โก (โv. v โจ A โถ v โ Well_Type TY) โบ
definition SType_Of :: โน(VAL, 'x) ฯ โ TYโบ
where โนSType_Of T = (
if Inhabited T โง (โTY. Semantic_Type T TY)
then (@TY. Semantic_Type T TY)
else ๐๐๐๐๐๐ )โบ
definition SType_Of' :: โนVAL BI โ TYโบ
where โนSType_Of' A = (
if Satisfiable A โง (โTY. Semantic_Type' A TY)
then (@TY. Semantic_Type' A TY)
else ๐๐๐๐๐๐ )โบ
adhoc_overloading Type_Of_syntax SType_Of SType_Of'
lemma SType_Of'_implies_SType_Of:
โน (โx. ๐๐๐๐พ๐๐ฟ (x โฆ T) = TY)
โน ๐๐๐๐พ๐๐ฟ T = TYโบ
unfolding SType_Of_def SType_Of'_def Inhabited_def Semantic_Type_def Semantic_Type'_def
by (auto, smt (verit) Satisfiable_def Well_Type_unique tfl_some,
smt (verit, best) tfl_some)
lemma SType_Of'_implies_SType_Of''':
โน Abstract_Domain T D
โน Abstract_DomainโฉL T DโฉL
โน (โx. D x โจ (โy. ยฌ DโฉL y) โน ๐๐๐๐พ๐๐ฟ (x โฆ T) = TY)
โน ๐๐๐๐พ๐๐ฟ T = TYโบ
unfolding SType_Of_def SType_Of'_def Inhabited_def Abstract_DomainโฉL_def
Action_Tag_def ๐ESC_def ๐EIF_def Abstract_Domain_def Satisfiable_def
Semantic_Type_def Semantic_Type'_def
by (auto,
smt (verit, ccfv_SIG) Well_Type_unique someI,
smt (verit, ccfv_SIG) someI)
lemma SType_Of_not_poison:
โน ๐๐๐๐พ๐๐ฟ T = TY โง TY โ ๐๐๐๐๐๐ โท Inhabited T โง (โx v. v โจ (x โฆ T) โถ v โ Well_Type TY) โบ
unfolding SType_Of_def Inhabited_def Satisfiable_def
Semantic_Type_def Semantic_Type'_def
by (auto, smt (verit, best) someI2_ex, insert Well_Type_disjoint, blast)
lemma SType_Of'_not_poison:
โน ๐๐๐๐พ๐๐ฟ A = TY โง TY โ ๐๐๐๐๐๐ โท Satisfiable A โง (โv. v โจ A โถ v โ Well_Type TY) โบ
unfolding SType_Of'_def Satisfiable_def Semantic_Type_def Semantic_Type'_def
by (auto, smt (verit, best) someI2_ex, insert Well_Type_disjoint, blast)
ฯreasoner_group ฯsem_type_infer_all = (100, [1, 2000]) for (โนSType_Of T = _ @tag ๐inferโบ, โนSType_Of' T = _ @tag ๐inferโบ )โนโบ
and ฯsem_type_infer_fallback = (1, [1, 1]) in ฯsem_type_infer_all โนโบ
and ฯsem_type_infer_brute = (10, [10,20]) in ฯsem_type_infer_all
and > ฯsem_type_infer_fallback โนโบ
and ฯsem_type_infer_cut = (1000, [1000, 1030]) in ฯsem_type_infer_all โนโบ
and ฯsem_type_infer_derived = (50, [50,60]) in ฯsem_type_infer_all
and > ฯsem_type_infer_brute โนโบ
ฯreasoner_group Semantic_Type_all = (100, [10, 2000]) for (โนSemantic_Type _ _โบ, โนSemantic_Type' _ _โบ) โนโบ
and Semantic_Type = (1000, [1000,1030]) in Semantic_Type_all โนโบ
and Semantic_Type_default = (50, [30,80]) in Semantic_Type_all โนโบ
and Semantic_Type_fallback = (15, [10,20]) in Semantic_Type_all and < Semantic_Type_default โนโบ
declare [[
ฯreason_default_pattern โนSemantic_Type ?T _โบ โ โนSemantic_Type ?T ?varโบ (100)
and โนSemantic_Type' ?T _โบ โ โนSemantic_Type' ?T ?varโบ (100),
ฯdefault_reasoner_group โนSemantic_Type _ _โบ : %Semantic_Type (100),
ฯdefault_reasoner_group โนSemantic_Type' _ _โบ : %Semantic_Type (100),
ฯreason_default_pattern โนSType_Of ?T = _ @tag ๐inferโบ โ โนSType_Of ?T = _ @tag ๐inferโบ (100)
and โนSType_Of' ?T = _ @tag ๐inferโบ โ โนSType_Of' ?T = _ @tag ๐inferโบ (100),
ฯdefault_reasoner_group โนSType_Of ?T = _ @tag ๐inferโบ : %ฯsem_type_infer_cut (100),
ฯdefault_reasoner_group โนSType_Of' ?T = _ @tag ๐inferโบ : %ฯsem_type_infer_cut (100)
]]
paragraph โนBasic Rulesโบ
lemma [ฯreason %ฯsem_type_infer_fallback]:
โน ๐๐๐๐๐
๐๐ฟ๐ TY : ๐๐๐๐พ๐๐ฟ A
โน ๐๐๐๐พ๐๐ฟ A = TY @tag ๐infer โบ
for A :: โนVAL BIโบ
unfolding Action_Tag_def Simplify_def
by blast
lemma ฯSemType_Itself_brute:
โน ๐๐๐พ๐๐๐๐พ v โ Well_Type TY
โน ๐๐๐๐พ๐๐ฟ (v โฆ Itself) = TY @tag ๐infer โบ
unfolding SType_Of'_def Inhabited_def Satisfiable_def Premise_def Action_Tag_def
Semantic_Type_def Semantic_Type'_def
by (auto, insert Well_Type_unique, blast)
lemma ฯsem_type_by_sat:
โน ๐๐๐พ๐๐๐๐พ ((โv. v โจ S โถ v โ Well_Type TY) โง (ยฌ Satisfiable S โถ TY = ๐๐๐๐๐๐))
โน ๐๐๐๐พ๐๐ฟ S = TY @tag ๐infer โบ
unfolding Premise_def ๐Guard_def SType_Of'_def Satisfiable_def Action_Tag_def
Semantic_Type_def Semantic_Type'_def
by (auto simp: split_ifs, insert Well_Type_unique, blast)
bundle ฯsem_type_sat_EIF = ฯsem_type_by_sat[ฯreason default %ฯsem_type_infer_brute]
ฯSemType_Itself_brute[ฯreason %ฯsem_type_infer_cut]
paragraph โนOver Logic Connectivesโบ
lemma ๐๐๐๐พ๐๐ฟ_plus[simp]:
โน ๐๐๐๐พ๐๐ฟ T = ๐๐๐๐พ๐๐ฟ U
โน ๐๐๐๐พ๐๐ฟ (T + U) = ๐๐๐๐พ๐๐ฟ T โบ
for T :: โนVAL BIโบ
unfolding SType_Of'_def Inhabited_def Satisfiable_def subset_iff Semantic_Type_def Semantic_Type'_def
using Well_Type_unique by (clarsimp, smt (z3) someI)
lemma [ฯreason add]:
โน ๐๐๐๐พ๐๐ฟ T = TYโฉ1 @tag ๐infer
โน ๐๐๐๐พ๐๐ฟ U = TYโฉ2 @tag ๐infer
โน ๐๐๐พ๐๐๐๐พ TYโฉ1 = TYโฉ2
โน ๐๐๐๐พ๐๐ฟ (T + U) = TYโฉ1 @tag ๐infer โบ
for T :: โนVAL BIโบ
unfolding Action_Tag_def Premise_def
by simp
lemma ๐๐๐๐พ๐๐ฟ_bot[simp]:
โน ๐๐๐๐พ๐๐ฟ โฅโฉBโฉI = ๐๐๐๐๐๐ โบ
unfolding SType_Of'_def
by auto
lemma [ฯreason add]:
โน ๐ผ๐๐๐ฝ๐๐๐๐๐ P โถ ๐๐๐๐พ๐๐ฟ X = TY @tag ๐infer
โน ๐๐๐๐พ๐๐ฟ (X ๐๐๐ป๐ P) = (if P then TY else ๐๐๐๐๐๐) @tag ๐infer โบ
unfolding Action_Tag_def Premise_def
by auto
lemma ๐๐๐๐พ๐๐ฟ_๐๐๐ป๐[simp]:
โน ๐๐๐๐พ๐๐ฟ (X ๐๐๐ป๐ P) = (if P then ๐๐๐๐พ๐๐ฟ X else ๐๐๐๐๐๐) โบ
by auto
lemma [ฯreason add]:
โน (โx. ๐๐๐๐พ๐๐ฟ (X x) = TY @tag ๐infer)
โน ๐๐๐๐พ๐๐ฟ (ExBI X) = TY @tag ๐infer โบ
unfolding Action_Tag_def SType_Of'_def Inhabited_def Satisfiable_def subset_iff
by (auto,
metis (no_types, lifting) ExBI_expn Semantic_Type'_def Well_Type_unique verit_sko_ex',
metis ExBI_expn Satisfaction_def Semantic_Type'_def tfl_some)
subsubsection โนAuxiliary Reasonersโบ
paragraph โนCheck Type Literalโบ
definition โนIs_Type_Literal (TY::TY) โก Trueโบ
ฯreasoner_group Is_Type_Literal = (1000, [10, 2000]) for โนIs_Type_Literal TYโบ โนโบ
and Is_Type_Literal_default = (10, [10, 20]) in Is_Type_Literal โนโบ
declare [[ ฯdefault_reasoner_group โนIs_Type_Literal _โบ : %Is_Type_Literal (100) ]]
lemma Is_Type_Literal_I[intro!]: โนIs_Type_Literal Xโบ
unfolding Is_Type_Literal_def ..
ฯreasoner_ML Is_Type_Literal_Free default %Is_Type_Literal_default (โนIs_Type_Literal _โบ) = โน
fn (_,(ctxt,sequent)) =>
case Thm.major_prem_of sequent
of Trueprop $ (Const(\<^const_name>โนIs_Type_Literalโบ, _) $ (Const(\<^const_name>โนSType_Ofโบ, _) $ Free _)) =>
Seq.single (ctxt, @{thm' Is_Type_Literal_I} RS sequent)
| _ => Seq.empty
โบ
paragraph โนUnfolding โน๐๐๐๐พ๐๐ฟ Tโบโบ
ฯreasoner_group eval_sem_typ = (100, [75, 2000]) > lambda_unify__default
โนUnfolding โน๐๐๐๐พ๐๐ฟ Tโบ exhausitively, with checking the result is not a poison.โบ
subsubsection โนReasoningโบ
lemma [ฯreason default %Semantic_Type_fallback+5]:
โน Abstract_Domain T D
โน (๐ผ๐๐๐ฝ๐๐๐๐๐ Ex D โน ๐๐๐๐๐
๐๐ฟ๐ TY : ๐๐๐๐พ๐๐ฟ T)
โน ๐ผ๐๐๐ฝ๐๐๐๐๐ (Ex D โถ TY โ ๐๐๐๐๐๐) ๐๐ ๐ฟ๐บ๐๐
TEXT(โนFail to evaluateโบ (๐๐๐๐พ๐๐ฟ T) โน: fail to showโบ (TY โ ๐๐๐๐๐๐))
โน Semantic_Type T TY โบ
unfolding Semantic_Type_def Simplify_def Premise_def OR_FAIL_def Abstract_Domain_def Premise_def
by (auto simp add: Satisfiable_def ๐EIF_def, metis SType_Of_not_poison)
lemma [ฯreason default %Semantic_Type_fallback for โนSemantic_Type _ _โบ
except โนSemantic_Type _ ?varโบ]:
โน Semantic_Type T TY'
โน ๐ผ๐๐๐ฝ๐๐๐๐๐ TY = TY' ๐๐ ๐ฟ๐บ๐๐
TEXT(โนExpectingโบ (๐๐๐๐พ๐๐ฟ T) โนto beโบ TY โนbut actuallyโบ TY')
โน Semantic_Type T TY โบ
unfolding OR_FAIL_def Premise_def
by simp
lemma [ฯreason default %Semantic_Type_fallback+5]:
โน Semantic_Type T TY
โน Semantic_Type' (x โฆ T) TY โบ
unfolding Semantic_Type'_def Semantic_Type_def
by auto
lemma [ฯreason default %Semantic_Type_fallback for โนSemantic_Type' _ _โบ
except โนSemantic_Type' _ ?varโบ]:
โน Semantic_Type' A TY'
โน ๐ผ๐๐๐ฝ๐๐๐๐๐ TY = TY' ๐๐ ๐ฟ๐บ๐๐
TEXT(โนExpectingโบ (๐๐๐๐พ๐๐ฟ A) โนto beโบ TY โนbut actuallyโบ TY')
โน Semantic_Type' A TY โบ
unfolding OR_FAIL_def Premise_def
by simp
lemma [ฯreason default %Semantic_Type_default]:
โน ๐๐๐พ๐๐๐๐พ (v โ Well_Type TY)
โน Semantic_Type' (v โฆ Itself) TY โบ
unfolding Premise_def Semantic_Type'_def
by auto
lemma [ฯreason add]:
โน (๐ผ๐๐๐ฝ๐๐๐๐๐ P โน Semantic_Type' A TY)
โน Semantic_Type' (A ๐๐๐ป๐ P) TY โบ
unfolding Semantic_Type'_def
by auto
lemma [ฯreason add]:
โน (โx. Semantic_Type' (A x) TY)
โน Semantic_Type' (โ*x. A x) TY โบ
unfolding Semantic_Type'_def
by auto
subsubsection โนMultiple Valuesโบ
definition Well_Typed_Vals :: โนTY list โ 'a::VALs ฯarg setโบ
where โนWell_Typed_Vals TYs = {vs. list_all2 (ฮปv T. v โ Well_Type T) (to_vals (ฯarg.dest vs)) TYs}โบ
definition Semantic_Types :: โน('a::VALs ฯarg โ assn) โ TY list โ boolโบ
where โนSemantic_Types spec TYs = (โv. Satisfiable (spec v) โถ v โ Well_Typed_Vals TYs)โบ
definition โนSemantic_Types_i = Semantic_Typesโบ
declare [[
ฯreason_default_pattern โนSemantic_Types_i ?S _โบ โ โนSemantic_Types_i ?S _โบ (100)
and โนSemantic_Types ?S _โบ โ โนSemantic_Types ?S _โบ (100),
ฯdefault_reasoner_group โนSemantic_Types _ _โบ : %ฯsem_type_infer_cut (100),
ฯdefault_reasoner_group โนSemantic_Types_i _ _โบ : %ฯsem_type_infer_cut (100)
]]
lemma [ฯreason add]:
โน (โv. S v ๐๐๐๐
๐๐พ๐ P v)
โน ๐ผ๐๐๐ฝ๐๐๐๐๐ (โx. P x) โถ Semantic_Types_i S TYs
โน Semantic_Types S TYs โบ
unfolding Semantic_Types_i_def Semantic_Types_def Premise_def ๐EIF_def
by auto
subsection โนZero Valueโบ
definition Semantic_Zero_Val :: "TY โ (VAL,'a) ฯ โ 'a โ bool"
where "Semantic_Zero_Val ty T x โท (ty โ ๐๐๐๐๐๐ โถ (โv. Zero ty = Some v โง v โจ (x โฆ T)))"
declare [[ฯreason_default_pattern โนSemantic_Zero_Val _ ?T _โบ โ โนSemantic_Zero_Val _ ?T ?varzโบ (100) ]]
ฯreasoner_group semantic_zero_val_all = (100, [0, 3000]) for โนSemantic_Zero_Val TY T xโบ
โนgiving the semantic zero value on the abstraction sideโบ
and semantic_zero_val_fail = (0, [0,0]) in semantic_zero_val_all
โนfailureโบ
and semantic_zero_val_fallback = (10, [1,20]) in semantic_zero_val_all and > semantic_zero_val_fail
โนreducing to semantic level, only used in deriving rulesโบ
and semantic_zero_val_cut = (1000, [1000, 1000]) in semantic_zero_val_all
โนcutting rulesโบ
and semantic_zero_val_derived = (50, [50,50]) in semantic_zero_val_all
and < semantic_zero_val_cut
and > semantic_zero_val_fallback
โนderived rulesโบ
subsubsection โนBasic Rulesโบ
lemma [ฯreason default %semantic_zero_val_fail]:
โน FAIL TEXT(โนDon't know any semantic zero value satisfying ฯ-typeโบ T)
โน Semantic_Zero_Val TY T x โบ
unfolding FAIL_def
by blast
lemma [ฯreason %extract_pure]:
โน Abstract_Domain T P
โน ๐EIF (Semantic_Zero_Val TY T x) (TY โ ๐๐๐๐๐๐ โถ P x) โบ
unfolding Abstract_Domain_def Semantic_Zero_Val_def ๐EIF_def Satisfiable_def
by blast
lemma Semantic_Zero_Val_EIF_sat:
โน ๐EIF (Semantic_Zero_Val TY T x) (TY โ ๐๐๐๐๐๐ โถ (โv. Zero TY = Some v โง v โจ (x โฆ T))) โบ
unfolding ๐EIF_def Semantic_Zero_Val_def
by blast
bundle Semantic_Zero_Val_EIF_brute =
Semantic_Zero_Val_EIF_sat[ฯreason %extract_pure+10]
lemma [ฯreason %semantic_zero_val_cut for โนSemantic_Zero_Val (๐๐๐๐พ๐๐ฟ (_ :: (VAL,_) ฯ)) _ _โบ ]:
โน ๐๐๐บ๐๐ฝ ๐๐๐๐๐
๐๐ฟ๐[๐ผ๐๐บ๐๐๐พ๐ฝ default] TY : ๐๐๐๐พ๐๐ฟ T
โน Semantic_Zero_Val TY U z
โน Semantic_Zero_Val (๐๐๐๐พ๐๐ฟ T) U z โบ
for T :: โน(VAL,'x) ฯโบ
unfolding ๐Guard_def Simplify_def
by simp
subsection โนEqualityโบ
definition ฯEqual :: "(VAL,'a) ฯ โ ('a โ 'a โ bool) โ ('a โ 'a โ bool) โ bool"
where "ฯEqual T can_eq eq โท (โp1 p2 x1 x2 res.
can_eq x1 x2 โง p1 โจ (x1 โฆ T) โง p2 โจ (x2 โฆ T)
โถ Can_EqCompare res p1 p2 โง (EqCompare p1 p2 = eq x1 x2))"
declare [[ฯreason_default_pattern โนฯEqual ?TY ?can_eq ?eqโบ โ โนฯEqual ?TY _ _โบ (100) ]]
subsection โนFunctionalโบ
definition Is_Functional :: โน'a BI โ boolโบ
where โนIs_Functional S โท (โx y. x โจ S โง y โจ S โถ x = y)โบ
definition Functionality :: โน('c,'a) ฯ โ ('a โ bool) โ boolโบ
where โนFunctionality T p โท (โx u v. p x โง u โจ (x โฆ T) โง v โจ (x โฆ T) โถ u = v)โบ
declare [[ฯreason_default_pattern โนIs_Functional ?Sโบ โ โนIs_Functional ?Sโบ (100)
and โนFunctionality ?T _โบ โ โนFunctionality ?T _โบ (100)]]
ฯreasoner_group ฯfunctionality_all = (%cutting, [1,3000]) for (โนIs_Functional Sโบ, โนFunctionality T pโบ)
โนAll reasoning rules giving functionality of ฯ-types, meaning if the assertion uniquely fixes
a concrete object for each abstract object.โบ
and ฯfunctionality = (%cutting, [%cutting, %cutting+30]) in ฯfunctionality_all
โนDefault rules are cuttingโบ
and derived_ฯfunctionality = (50, [40,60]) in ฯfunctionality_all and < ฯfunctionality
โนDerived rulesโบ
and ฯfunctional_to_functionality = (10, [10,10]) in ฯfunctionality_all and < derived_ฯfunctionality
โนTrunning โนIs_Functional (x : T)โบ to โนFunctionality T pโบโบ
and ฯfunctionality_brute = (2, [2,2]) in ฯfunctionality_all and < ฯfunctional_to_functionality
โนreducing to concrete semantics, and only used in deriving rulesโบ
subsubsection โนBasic Rulesโบ
lemma functional_concretize:
โน Functionality T ((=) x)
โน v โจ (x โฆ T)
โน v = concretize T x โบ
unfolding concretize_def ฯType_def Functionality_def
by (simp add: some_equality)
lemma concretize_eq:
โน Abstract_DomainโฉL T ((=) x)
โน Functionality U ((=) y)
โน x โฆ T ๐๐๐บ๐๐๐ฟ๐๐๐๐ y โฆ U
โน concretize T x = concretize U y โบ
unfolding Transformation_def Abstract_DomainโฉL_def ๐ESC_def
by (simp add: concretize_SAT functional_concretize)
lemma :
โนIs_Functional S โก (โu v. u โจ S โง v โจ S โถ u = v) โง Trueโบ
unfolding Is_Functional_def atomize_eq
by blast
lemma :
โนFunctionality T P โก (โx u v. P x โง u โจ (x โฆ T) โง v โจ (x โฆ T) โถ u = v) โง Trueโบ
unfolding Functionality_def atomize_eq
by blast
lemma Functionality_sub:
โน (โx. P' x โถ P x)
โน Functionality T P
โน Functionality T P' โบ
unfolding Functionality_def
by auto
lemma Is_Functional_I[intro!]:
โน (โx y. x โจ A โน y โจ A โน x = y)
โน Is_Functional A โบ
unfolding Is_Functional_def by blast
lemma Is_Functional_imp:
โน S ๐๐๐บ๐๐๐ฟ๐๐๐๐ S'
โน Is_Functional S'
โน Is_Functional Sโบ
unfolding Transformation_def Is_Functional_def
by blast
lemma [ฯreason no explorative backtrack 0]:
โน TRACE_FAIL TEXT(โนFail to showโบ S โนis functionalโบ)
โน Is_Functional Sโบ
unfolding TRACE_FAIL_def
by blast
lemma [ฯreason default %ฯfunctional_to_functionality]:
โน Functionality T p
โน ๐๐๐พ๐๐๐๐พ p x
โน Is_Functional (x โฆ T)โบ
unfolding Premise_def Is_Functional_def Functionality_def
by simp
lemma Is_Functional_brute:
โน ๐๐๐พ๐๐๐๐พ (โu v. u โจ S โง v โจ S โถ u = v)
โน Is_Functional S โบ
unfolding Is_Functional_def Premise_def
by blast
lemma Is_Functional_EIF_brute:
โน ๐EIF (Is_Functional S) (โu v. u โจ S โง v โจ S โถ u = v) โบ
unfolding ๐EIF_def Is_Functional_def
by blast
lemma Functionality_EIF_brute:
โน ๐EIF (Functionality T D) (โx u v. D x โง u โจ (x โฆ T) โง v โจ (x โฆ T) โถ u = v) โบ
unfolding ๐EIF_def Functionality_def
by blast
bundle Is_Functional_brute = Is_Functional_brute[ฯreason default %ฯfunctionality_brute]
Is_Functional_EIF_brute[ฯreason %extract_pure+10]
Functionality_EIF_brute[ฯreason %extract_pure+10]
subsubsection โนBasic Types and Connectivesโบ
lemma [ฯreason %ฯfunctionality]:
โนFunctionality Itself (ฮป_. True)โบ
unfolding Functionality_def
by clarsimp
lemma [ฯreason %ฯfunctionality]:
โน Is_Functional 1 โบ
unfolding Is_Functional_def
by simp
lemma [ฯreason %ฯfunctionality]:
โน Is_Functional 0 โบ
unfolding Is_Functional_def
by simp
lemma [ฯreason %ฯfunctionality]:
โน Is_Functional A
โน Is_Functional B
โน Is_Functional (A โ B) โบ
unfolding Is_Functional_def
by simp
lemma [ฯreason %ฯfunctionality]:
โน (๐ผ๐๐๐ฝ๐๐๐๐๐ P โน Is_Functional S)
โน Is_Functional (S ๐๐๐ป๐ P) โบ
unfolding Is_Functional_def Premise_def
by simp
lemma [ฯreason %ฯfunctionality]:
โน Is_Functional A
โน Is_Functional B
โน Is_Functional (A * B)โบ
unfolding Is_Functional_def set_eq_iff
by (simp add: set_mult_expn, blast)
lemma [ฯreason %ฯfunctionality]:
โน Is_Functional A
โน Is_Functional B
โน Is_Functional (A ๐๐พ๐๐บ๐๐๐ B)โบ
unfolding Is_Functional_def set_eq_iff REMAINS_def
by (simp add: set_mult_expn, blast)
lemma [ฯreason %ฯfunctionality]:
โน Functionality T pโฉT
โน Functionality U pโฉU
โน Functionality (T โผ U) (ฮป(x,y). pโฉT x โง pโฉU y)โบ
unfolding Functionality_def ฯProd'_def
by clarsimp blast
lemma [ฯreason %ฯfunctionality]:
โน (โiโS. Is_Functional (A i))
โน Is_Functional (โฑiโS. A i) โบ
unfolding Is_Functional_def Mul_Quant_def atomize_Ball Ball_def
proof clarsimp
fix x y
assume prems: โนโx. x โ S โถ (โxa y. xa โจ A x โง y โจ A x โถ xa = y)โบ (is ?A)
โนx โจ prod A Sโบ (is ?B)
โนy โจ prod A Sโบ (is ?C)
and โนfinite Sโบ
have โน?A โง ?B โง ?C โถ x = yโบ
by (induct arbitrary: x y rule: finite_induct[OF โนfinite Sโบ]; clarsimp; blast)
then show โนx = yโบ
using prems by blast
qed
subsection โนCarrier Set of Separation Algebraโบ
definition Within_Carrier_Set :: โน'c::sep_carrier BI โ boolโบ
where โนWithin_Carrier_Set A โท (โv. v โจ A โถ mul_carrier v)โบ
definition Carrier_Set :: โน('c::sep_carrier,'a) ฯ โ ('a โ bool) โ boolโบ
where โนCarrier_Set T D โท (โx. D x โถ Within_Carrier_Set (x โฆ T))โบ
declare [[ฯreason_default_pattern
โนWithin_Carrier_Set ?Aโบ โ โนWithin_Carrier_Set ?Aโบ (100)
and โนCarrier_Set ?T _โบ โ โนCarrier_Set ?T _โบ (100)
]]
ฯreasoner_group carrier_set = (100, [10,3000]) for โนWithin_Carrier_Set Aโบ
โนRules reasoning if the given assertion โนAโบ with all its concrete objects falls in the carrier set of the separation algebraโบ
and carrier_set_cut = (1000, [1000, 1030]) for โนWithin_Carrier_Set Aโบ in carrier_set
โนCutting rulesโบ
and carrier_set_red = (2500, [2500, 2530]) for โนWithin_Carrier_Set Aโบ in carrier_set and > carrier_set_cut
โนLiteral Reductionโบ
and derived_carrier_set = (50, [50,50]) for (โนWithin_Carrier_Set Aโบ, โนCarrier_Set T Dโบ)
in carrier_set and < carrier_set_cut
โนDerived rulesโบ
and carrier_set_to_within_carrier_set = (10, [10,10]) for (โนWithin_Carrier_Set Aโบ, โนCarrier_Set T Dโบ)
in carrier_set and < derived_carrier_set
โนTurning โนWithin_Carrier_Set (x : T)โบ to โนCarrier_Set T Dโบโบ
subsubsection โนExtracting Pure Factsโบ
context begin
private lemma EIF_Within_Carrier_Set:
โน ๐EIF (Within_Carrier_Set A) (โv. v โจ A โถ mul_carrier v) โบ
unfolding Within_Carrier_Set_def ๐EIF_def
by blast
private lemma ESC_Within_Carrier_Set:
โน ๐ESC (โv. v โจ A โถ mul_carrier v) (Within_Carrier_Set A) โบ
unfolding Within_Carrier_Set_def ๐ESC_def
by blast
private lemma EIF_Carrier_Set:
โน ๐EIF (Carrier_Set T D) (โx v. D x โง v โจ (x โฆ T) โถ mul_carrier v) โบ
unfolding Carrier_Set_def Within_Carrier_Set_def ๐EIF_def
by blast
private lemma ESC_Carrier_Set:
โน ๐ESC (โx v. D x โง v โจ (x โฆ T) โถ mul_carrier v) (Carrier_Set T D) โบ
unfolding Carrier_Set_def Within_Carrier_Set_def ๐ESC_def
by blast
bundle =
EIF_Within_Carrier_Set [ฯreason %extract_pure_sat]
ESC_Within_Carrier_Set [ฯreason %extract_pure_sat]
EIF_Carrier_Set [ฯreason %extract_pure_sat]
ESC_Carrier_Set [ฯreason %extract_pure_sat]
end
subsubsection โนRules for Logical Connectivesโบ
lemma [ฯreason default %carrier_set_to_within_carrier_set]:
โน Carrier_Set T P
โน ๐๐๐พ๐๐๐๐พ P x
โน Within_Carrier_Set (x โฆ T) โบ
unfolding Carrier_Set_def Premise_def
by blast
lemma [ฯreason %carrier_set_cut]:
โน Within_Carrier_Set A
โน Within_Carrier_Set B
โน Within_Carrier_Set (A * B)โบ
unfolding Within_Carrier_Set_def
by (clarsimp simp add: mul_carrier_closed)
text โนThough the above rule is reasonable enough, it is not reversible, essentially because
the set of concrete objects satisfying โนA * Bโบ is far smaller than either of that satisfying โนAโบ or โนBโบ.โบ
lemma
โนWithin_Carrier_Set (A * B) โน Within_Carrier_Set A โง Within_Carrier_Set Bโบ
oops
lemma [ฯreason %carrier_set_cut]:
โน (โiโI. Within_Carrier_Set (A i))
โน Within_Carrier_Set (โฑiโI. A i) โบ
for A :: โน'i โ 'c :: {sep_algebra,sep_carrier_1} BIโบ
unfolding Within_Carrier_Set_def Mul_Quant_def meta_Ball_def Premise_def
proof clarsimp
fix v
assume โนfinite Iโบ
show โน(โx. x โ I โน โv. v โจ A x โถ mul_carrier v) โน v โจ prod A I โน mul_carrier vโบ
by (induct arbitrary: v rule: finite_induct[OF โนfinite Iโบ]; clarsimp; metis mul_carrier_closed)
qed
lemma [ฯreason %carrier_set_cut]:
โน Within_Carrier_Set A
โน Within_Carrier_Set B
โน Within_Carrier_Set (A + B)โบ
unfolding Within_Carrier_Set_def
by clarsimp
lemma
โน Within_Carrier_Set (A + B) โน Within_Carrier_Set A โง Within_Carrier_Set B โบ
unfolding Within_Carrier_Set_def
by clarsimp
lemma [ฯreason %carrier_set_cut]:
โน (โx. Within_Carrier_Set (A x))
โน Within_Carrier_Set (ExBI A) โบ
unfolding Within_Carrier_Set_def
by clarsimp
lemma
โน Within_Carrier_Set (ExBI A) โน Within_Carrier_Set (A x) โบ
unfolding Within_Carrier_Set_def
by clarsimp blast
lemma [ฯreason %carrier_set_cut]:
โน Within_Carrier_Set A
โน Within_Carrier_Set B
โน Within_Carrier_Set (A โ B)โบ
unfolding Within_Carrier_Set_def
by clarsimp
text โนThe above rule is also not reversible. Essentially the rules for conjunctive connectives are not
reversible due to the same reason as โน*โบ. โบ
lemma โน Within_Carrier_Set (A โ B) โน Within_Carrier_Set A โง Within_Carrier_Set B โบ
oops
lemma [ฯreason %carrier_set_cut]:
โน (๐ผ๐๐๐ฝ๐๐๐๐๐ P โน Within_Carrier_Set A)
โน Within_Carrier_Set (A ๐๐๐ป๐ P)โบ
unfolding Within_Carrier_Set_def
by clarsimp
lemma [ฯreason %carrier_set_cut]:
โน Within_Carrier_Set 0 โบ
unfolding Within_Carrier_Set_def
by simp
lemma [ฯreason %carrier_set_cut]:
โน Within_Carrier_Set (1 :: 'a::sep_carrier_1 BI) โบ
unfolding Within_Carrier_Set_def
by simp
paragraph โนCase Splitโบ
subparagraph โนReductionโบ
lemma [ฯreason %carrier_set_red]:
โน Within_Carrier_Set (P a)
โน Within_Carrier_Set (case_sum P Q (Inl a)) โบ
by simp
lemma [ฯreason %carrier_set_red]:
โน Within_Carrier_Set (Q b)
โน Within_Carrier_Set (case_sum P Q (Inr b)) โบ
by simp
subparagraph โนCase Splitโบ
lemma [ฯreason %carrier_set_cut]:
โน (โa. ๐ผ๐๐๐ฝ๐๐๐๐๐ x = Inl a โน Within_Carrier_Set (P a))
โน (โb. ๐ผ๐๐๐ฝ๐๐๐๐๐ x = Inr b โน Within_Carrier_Set (Q b))
โน Within_Carrier_Set (case_sum P Q x) โบ
unfolding Premise_def
by (cases x; clarsimp)
text โนAlso not reversible in non-trivial cases.โบ
subsubsection โนRules for Basic ฯ-Typesโบ
lemma [ฯreason 1000]:
โนCarrier_Set Itself mul_carrierโบ
unfolding Carrier_Set_def Within_Carrier_Set_def
by simp
lemma [ฯreason 1000]:
โนCarrier_Set (โ :: ('c::sep_carrier_1, unit) ฯ) (ฮป_. True)โบ
unfolding Carrier_Set_def Within_Carrier_Set_def
by clarsimp
subsection โนSeparationally Functionalโบ
definition Sep_Functional :: โน'a::sep_magma BI โ boolโบ
where โนSep_Functional S โท (โx y. x โจ S โง y โจ S โง x ## y โถ x = y) โบ
declare [[ฯreason_default_pattern โนSep_Functional ?Sโบ โ โนSep_Functional ?Sโบ (100)]]
lemma [ฯreason no explorative backtrack 1]:
โน Is_Functional S
โน Sep_Functional S โบ
unfolding Sep_Functional_def Is_Functional_def
by simp
lemma [ฯreason no explorative backtrack 0]:
โน TRACE_FAIL TEXT(โนFail to showโบ S โนis separationally functionalโบ)
โน Sep_Functional Sโบ
unfolding TRACE_FAIL_def
by blast
lemma [ฯreason 1200]:
โน Sep_Functional A
โน Sep_Functional B
โน Sep_Functional (A โ B) โบ
unfolding Sep_Functional_def
by simp
lemma [ฯreason 1200]:
โน Sep_Functional A
โน Sep_Functional B
โน Sep_Functional (A * B)โบ
for A :: โน'a::sep_ab_semigroup BIโบ
unfolding Sep_Functional_def
by (clarsimp; metis sep_disj_commute sep_disj_multD1 sep_disj_multD2)
lemma [ฯreason 1200]:
โน Sep_Functional (fst x โฆ T)
โน Sep_Functional (snd x โฆ U)
โน Sep_Functional (x โฆ T โ U)โบ
for T :: โน('c::sep_ab_semigroup, 'a) ฯโบ
unfolding Sep_Functional_def
by (cases x; clarsimp;
metis sep_disj_commute sep_disj_multD1 sep_disj_multD2)
subsection โนReflexive Separationโบ
text โน\<^prop>โนx ## xโบ is used to represented โนxโบ is in the carrier set in some algebras like permission algebra.โบ
definition Sep_Reflexive :: โน'a::sep_magma BI โ boolโบ
where โนSep_Reflexive S โท (โu. u โจ S โถ u ## u) โบ
lemma [ฯreason 1000]:
โน Sep_Reflexive A
โน Sep_Reflexive B
โน Sep_Reflexive (A * B) โบ
for A :: โน'a::sep_refl BIโบ
unfolding Sep_Reflexive_def
by (clarsimp simp add: sep_refl_mult_I)
lemma [ฯreason 1000]:
โน Sep_Reflexive (fst x โฆ T)
โน Sep_Reflexive (snd x โฆ U)
โน Sep_Reflexive (x โฆ T โ U) โบ
for T :: โน('c::sep_refl, 'a) ฯโบ
unfolding Sep_Reflexive_def
by (clarsimp simp add: sep_refl_mult_I)
lemma [ฯreason 1000]:
โน Sep_Reflexive A
โน Sep_Reflexive B
โน Sep_Reflexive (A + B) โบ
unfolding Sep_Reflexive_def
by clarsimp
lemma [ฯreason 1000]:
โน (โx. Sep_Reflexive (A x))
โน Sep_Reflexive (ExBI A) โบ
unfolding Sep_Reflexive_def
by clarsimp
lemma [ฯreason 1000]:
โน Sep_Reflexive A
โน Sep_Reflexive B
โน Sep_Reflexive (A โ B) โบ
unfolding Sep_Reflexive_def
by clarsimp
lemma [ฯreason 1000]:
โน Sep_Reflexive A
โน Sep_Reflexive (A ๐๐๐ป๐ P) โบ
unfolding Sep_Reflexive_def
by clarsimp
section โนSpecification of Monadic Statesโบ
definition StrictState :: "('ret ฯarg โ rassn)
โ (ABNM โ rassn)
โ 'ret comp BI"
where "StrictState T E = BI {s. case s of Success val x โ x โจ T val
| Abnormal val x โ x โจ E val
| Invalid โ False
| NonTerm โ False
| AssumptionBroken โ False
}"
definition LooseState :: "('ret ฯarg โ rassn)
โ (ABNM โ rassn)
โ 'ret comp BI"
where "LooseState T E = BI {s. case s of Success val x โ x โจ T val
| Abnormal val x โ x โจ E val
| Invalid โ False
| NonTerm โ True
| AssumptionBroken โ True
}"
lemma StrictState_expn[iff]:
"Success vs x โจ StrictState T E โก x โจ T vs"
"Abnormal v x โจ StrictState T E โก x โจ E v"
"ยฌ (Invalid โจ StrictState T E)"
"ยฌ (NonTerm โจ StrictState T E)"
"ยฌ (AssumptionBroken โจ StrictState T E)"
"ยฌ Itself Invalid โค StrictState T E"
"ยฌ Itself NonTerm โค StrictState T E"
"ยฌ Itself AssumptionBroken โค StrictState T E"
and LooseState_expn[iff]:
"Success vs x โจ LooseState T E โก x โจ T vs"
"Abnormal v x โจ LooseState T E โก x โจ E v"
"ยฌ (Invalid โจ LooseState T E)"
"(NonTerm โจ LooseState T E)"
"(AssumptionBroken โจ LooseState T E)"
"ยฌ Itself Invalid โค LooseState T E"
"Itself NonTerm โค LooseState T E"
"Itself AssumptionBroken โค LooseState T E"
by (simp_all add: StrictState_def LooseState_def less_eq_BI_iff)
lemma LooseState_expn' :
"x โจ LooseState T E โท x = NonTerm
โจ x = AssumptionBroken
โจ (โx' v. x = Success v x' โง x' โจ T v)
โจ (โx' v. x = Abnormal v x' โง x' โจ E v)"
by (cases x) simp_all
lemma StrictState_elim[elim]:
"s โจ StrictState T E
โน (โx v. s = Success v x โน x โจ T v โน C)
โน (โx v. s = Abnormal v x โน x โจ E v โน C)
โน C" by (cases s) auto
lemma StrictState_intro[intro]:
" x โจ T v โน Success v x โจ StrictState T E"
" x โจ E a โน Abnormal a x โจ StrictState T E"
by simp_all
lemma LooseState_E[elim]:
"s โจ LooseState T E
โน (โx v. s = Success v x โน x โจ T v โน C)
โน (โx v. s = Abnormal v x โน x โจ E v โน C)
โน (s = NonTerm โน C)
โน (s = AssumptionBroken โน C)
โน C"
by (cases s) auto
lemma LooseState_I[intro]:
"x โจ T v โน Success v x โจ LooseState T E"
"x โจ E a โน Abnormal a x โจ LooseState T E"
"NonTerm โจ LooseState T E"
"AssumptionBroken โจ LooseState T E"
by simp_all
lemma LooseState_upgrade:
"s โจ LooseState T E โน s โ AssumptionBroken โน s โ NonTerm โน s โจ StrictState T E"
by (cases s) auto
lemma StrictState_degrade: "s โจ StrictState T E โน s โจ LooseState T E" by (cases s) auto
lemma LooseState_introByStrict:
"(s โ AssumptionBroken โน s โ NonTerm โน s โจ StrictState T E) โน s โจ LooseState T E"
by (cases s) auto
lemma StrictState_subset:
โน(โv. A v โค A' v) โน (โv. E v โค E' v) โน StrictState A E โค StrictState A' E'โบ
unfolding less_eq_BI_iff StrictState_def by simp
lemma StrictState_subset'[intro]:
โน(โv. โs. s โจ A v โถ s โจ A' v) โน (โv. โs. s โจ E v โถ s โจ E' v) โน s โจ StrictState A E โน s โจ StrictState A' E'โบ
unfolding StrictState_def by (cases s; simp)
lemma LooseState_subset:
โน(โv. A v โค A' v) โน (โv. E v โค E' v) โน LooseState A E โค LooseState A' E'โบ
unfolding less_eq_BI_iff LooseState_def by simp
lemma LooseState_subset'[intro]:
โน(โv. โs. s โจ A v โถ s โจ A' v) โน (โv. โs. s โจ E v โถ s โจ E' v) โน s โจ LooseState A E โน s โจ LooseState A' E'โบ
unfolding LooseState_def by (cases s; simp)
lemma LooseState_plus[iff]:
โนLooseState X (ฮปv. EA v + EB v) = LooseState X EA + LooseState X EBโบ
unfolding BI_eq_iff LooseState_def by simp_all
lemma StrictState_plus[iff]:
โนStrictState X (ฮปv. EA v + EB v) = StrictState X EA + StrictState X EBโบ
unfolding BI_eq_iff StrictState_def by simp_all
abbreviation โนVoid โก (1::assn)โบ
section โนSpecification of Fictional Resourceโบ
declare INTERP_SPEC[ฯexpns]
lemma INTERP_SPEC_subj[ฯexpns]:
โน INTERP_SPEC (S ๐๐๐ป๐ P) = (INTERP_SPEC S ๐๐๐ป๐ P) โบ
unfolding INTERP_SPEC_def by (simp add: BI_eq_iff, blast)
lemma INTERP_SPEC_ex[ฯexpns]:
โน INTERP_SPEC (ExBI S) = (โ* x. INTERP_SPEC (S x)) โบ
unfolding INTERP_SPEC_def by (simp add: BI_eq_iff, blast)
abbreviation COMMA :: โนassn โ assn โ assnโบ ("_โ/ _" [17,16] 16)
where โนCOMMA โก (*)โบ
section โนSpecification of Computationโบ
definition ฯProcedure :: "'ret proc
โ assn
โ ('ret ฯarg โ assn)
โ (ABNM โ assn)
โ bool"
where "ฯProcedure f T U E โท
(โcomp R. comp โจ INTERP_SPEC (T * R) โถ
BI_lift (f comp) โค LooseState (ฮปv. INTERP_SPEC (U v * R)) (ฮปv. INTERP_SPEC (E v * R)))"
abbreviation ฯProcedure_no_exception
where โนฯProcedure_no_exception f T U โก ฯProcedure f T U 0โบ
notation (input)
ฯProcedure ("๐๐๐๐ผ (2_)/ (0โฆ _/ โผ _ โฆ)/ ๐๐๐๐๐๐ (_)/ " [10,2,2,100] 100)
and ฯProcedure_no_exception ("๐๐๐๐ผ (2_)/ โฆ (2_) โผ/ (2_) โฆ/ " [10,2,2] 100)
notation ฯProcedure_no_exception
("(โนconsistentโบ๐๐๐๐ผ (_)/ ๐๐๐๐๐ (_)/ ๐๐๐๐๐๐ (_))" [2,2,2] 100)
and ฯProcedure
("(โนconsistentโบ๐๐๐๐ผ (_)/ ๐๐๐๐๐ (_)/ ๐๐๐๐๐๐ (_)/ ๐๐๐๐๐๐ (_))" [2,2,2,100] 100)
translations
"CONST ฯProcedure p X Y E" <= "CONST ฯProcedure (_do_block p) X Y E"
"CONST ฯProcedure_no_exception p X Y" <= "CONST ฯProcedure_no_exception (_do_block p) X Y"
lemma ฯProcedure_alt:
โน๐๐๐๐ผ f โฆ T โผ U โฆ ๐๐๐๐๐๐ E
โท (โcomp r. comp โจ INTERP_SPEC (T * Itself r)
โถ BI_lift (f comp) โค LooseState (ฮปv. INTERP_SPEC (U v * Itself r)) (ฮปv. INTERP_SPEC (E v * Itself r)))โบ
apply rule
apply ((unfold ฯProcedure_def)[1], blast)
unfolding ฯProcedure_def INTERP_SPEC subset_iff
apply (clarsimp simp add: less_eq_BI_iff times_set_def split_comp_All INTERP_SPEC_def)
by fastforce
lemmas ฯProcedure_I = ฯProcedure_alt[THEN iffD2]
lemma ฯProcedure_protect_body:
โน T โก T'
โน U โก U'
โน E โก E'
โน ฯProcedure f T U E โก ฯProcedure f T' U' E'โบ
by simp
subsubsection โนSyntaxโบ
ML_file โนlibrary/syntax/procedure.MLโบ
section โนView Shiftโบ
definition View_Shift
:: "assn โ assn โ bool โ bool" ("(2_/ ๐๐๐๐ฟ๐๐ _/ ๐๐๐๐ _)" [13,13,13] 12)
where "View_Shift T U P โท (โx R. x โจ INTERP_SPEC (T * R) โถ x โจ INTERP_SPEC (U * R) โง P)"
abbreviation Simple_View_Shift
:: "assn โ assn โ bool" ("(2_/ ๐๐๐๐ฟ๐๐ _)" [13,13] 12)
where โนSimple_View_Shift T U โก View_Shift T U Trueโบ
declare [[ฯreason_default_pattern
โน?X ๐๐๐๐ฟ๐๐ ?Y ๐๐๐๐ _โบ โ โน?X ๐๐๐๐ฟ๐๐ ?Y ๐๐๐๐ _โบ (10)
and โน?X ๐๐๐๐ฟ๐๐ _ โฆ ?U ๐๐๐๐ _โบ โ โน?X ๐๐๐๐ฟ๐๐ ?var_y โฆ ?U ๐๐๐๐ _โบ (20)
and โน?X ๐๐๐๐ฟ๐๐ ?Y ๐๐พ๐๐บ๐๐๐ _ ๐๐๐๐ _โบ โ โน?X ๐๐๐๐ฟ๐๐ ?Y ๐๐พ๐๐บ๐๐๐ _ ๐๐๐๐ _โบ (20)
and โน?X ๐๐๐๐ฟ๐๐ _ โฆ ?U ๐๐พ๐๐บ๐๐๐ _ ๐๐๐๐ _โบ โ โน?X ๐๐๐๐ฟ๐๐ ?var_y โฆ ?U ๐๐พ๐๐บ๐๐๐ _ ๐๐๐๐ _โบ (30)
]]
subsection โนBasic Rulesโบ
lemma View_Shift_imply_P:
โน X ๐๐๐๐ฟ๐๐ Y ๐๐๐๐ P1
โน (P1 โถ P2)
โน X ๐๐๐๐ฟ๐๐ Y ๐๐๐๐ P2โบ
unfolding View_Shift_def
by blast
lemma view_shift_by_implication[intro?, ฯreason 10]:
โน A ๐๐๐บ๐๐๐ฟ๐๐๐๐ B ๐๐๐๐ P
โน A ๐๐๐๐ฟ๐๐ B ๐๐๐๐ Pโบ
unfolding Transformation_def View_Shift_def INTERP_SPEC_def
by clarsimp blast
lemma view_shift_0[simp]:
โน 0 ๐๐๐๐ฟ๐๐ X ๐๐๐๐ any โบ
by (blast intro: view_shift_by_implication zero_implies_any)
lemma [ฯreason 2000 for โน0 ๐๐๐๐ฟ๐๐ ?X ๐๐๐๐ ?Pโบ]:
โน 0 ๐๐๐๐ฟ๐๐ X ๐๐๐๐ False โบ
by simp
lemma view_shift_refl[ฯreason 2000 for โน?A ๐๐๐๐ฟ๐๐ ?B ๐๐๐๐ ?Pโบ]:
"A ๐๐๐๐ฟ๐๐ A"
by (blast intro: view_shift_by_implication transformation_refl)
lemma [ฯreason 800 for โน?x โฆ ?T ๐๐๐๐ฟ๐๐ ?y โฆ ?T' ๐๐๐๐ ?Pโบ]:
" Object_Equiv T eq
โน ๐๐๐พ๐๐๐๐พ eq x y
โน x โฆ T ๐๐๐๐ฟ๐๐ y โฆ T"
unfolding Object_Equiv_def Premise_def
by (insert view_shift_by_implication, presburger)
lemma view_shift_union[ฯreason 800]:
โน A ๐๐๐๐ฟ๐๐ X ๐๐๐๐ P
โน A ๐๐๐๐ฟ๐๐ X + Y ๐๐๐๐ Pโบ
โน A ๐๐๐๐ฟ๐๐ Y ๐๐๐๐ P
โน A ๐๐๐๐ฟ๐๐ X + Y ๐๐๐๐ Pโบ
by (simp add: View_Shift_def distrib_right)+
lemma ฯview_shift_trans:
"A ๐๐๐๐ฟ๐๐ B ๐๐๐๐ P
โน (P โน B ๐๐๐๐ฟ๐๐ C ๐๐๐๐ Q)
โน A ๐๐๐๐ฟ๐๐ C ๐๐๐๐ P โง Q"
unfolding View_Shift_def by blast
lemma ฯframe_view:
โน A ๐๐๐๐ฟ๐๐ B ๐๐๐๐ P
โน A * R ๐๐๐๐ฟ๐๐ B * R ๐๐๐๐ Pโบ
unfolding View_Shift_def
by (metis (no_types, lifting) mult.assoc)
lemma ฯview_shift_intro_frame:
"U' ๐๐๐๐ฟ๐๐ U ๐๐๐๐ P โน U' * R ๐๐๐๐ฟ๐๐ U * R ๐๐๐๐ P "
by (simp add: ฯframe_view)
lemma ฯview_shift_intro_frame_R:
"U' ๐๐๐๐ฟ๐๐ U ๐๐๐๐ P โน R * U' ๐๐๐๐ฟ๐๐ R * U ๐๐๐๐ P "
by (metis ฯframe_view mult.commute)
section โนHoare Rules \& SL Rulesโบ
subsection โนFundamental Rulesโบ
lemma ฯSKIP[simp,intro!]: "๐๐๐๐ผ det_lift (Success v) โฆ T v โผ T โฆ"
unfolding ฯProcedure_def det_lift_def less_eq_BI_iff by clarsimp
lemma ฯSEQ:
"๐๐๐๐ผ f โฆ A โผ B โฆ ๐๐๐๐๐๐ E
โน (โvs. ๐๐๐๐ผ g vs โฆ B vs โผ C โฆ ๐๐๐๐๐๐ E)
โน ๐๐๐๐ผ (f โค (ฮปv. g v)) โฆ A โผ C โฆ ๐๐๐๐๐๐ E"
unfolding ฯProcedure_def bind_def apply (clarsimp simp add: less_eq_BI_iff)
subgoal for comp R x s
apply (cases s; clarsimp; cases x; clarsimp; blast) . .
lemma ฯframe:
" ๐๐๐๐ผ f โฆ A โผ B โฆ ๐๐๐๐๐๐ E
โน ๐๐๐๐ผ f โฆ A * R โผ ฮปret. B ret * R โฆ ๐๐๐๐๐๐ (ฮปex. E ex * R) "
unfolding ฯProcedure_def less_eq_BI_iff
apply clarify subgoal premises prems for comp R' s
using prems(1)[THEN spec[where x=comp], THEN spec[where x=โนR * R'โบ],
simplified mult.assoc[symmetric], THEN mp, OF prems(2)] prems(3)
by blast .
lemma ฯSatisfiable:
โน(Satisfiable X โน ๐๐๐๐ผ f โฆ X โผ Y โฆ ๐๐๐๐๐๐ E)
โน ๐๐๐๐ผ f โฆ X โผ Y โฆ ๐๐๐๐๐๐ Eโบ
unfolding ฯProcedure_def Satisfiable_def
by (meson INTERP_SPEC sep_conj_expn)
subsubsection โนView Shiftโบ
lemma ฯframe_view_right:
โน A ๐๐๐๐ฟ๐๐ B ๐๐๐๐ P
โน A * R ๐๐๐๐ฟ๐๐ B * R ๐๐๐๐ Pโบ
unfolding View_Shift_def
by (metis (no_types, lifting) mult.assoc mult.commute)
lemma ฯview_trans:
โน A ๐๐๐๐ฟ๐๐ B ๐๐๐๐ P1
โน (P1 โน B ๐๐๐๐ฟ๐๐ C ๐๐๐๐ P2)
โน A ๐๐๐๐ฟ๐๐ C ๐๐๐๐ P1 โง P2โบ
unfolding View_Shift_def by blast
lemma ฯCONSEQ:
"๐๐๐๐ผ f โฆ A โผ B โฆ ๐๐๐๐๐๐ E
โน A' ๐๐๐๐ฟ๐๐ A ๐๐๐๐ Any1
โน (โret. B ret ๐๐๐๐ฟ๐๐ B' ret ๐๐๐๐ Any2)
โน (โex. E ex ๐๐๐๐ฟ๐๐ E' ex ๐๐๐๐ Any3)
โน ๐๐๐๐ผ f โฆ A' โผ B' โฆ ๐๐๐๐๐๐ E' "
unfolding ฯProcedure_def View_Shift_def less_eq_BI_iff
by (clarsimp, smt (verit, del_insts) LooseState_expn')
subsection โนHelper Rulesโบ
lemma ฯframe0:
"๐๐๐๐ผ f โฆ A โผ B โฆ โน ๐๐๐๐ผ f โฆ A * R โผ ฮปret. B ret * R โฆ"
using ฯframe[where E=0, simplified, folded zero_fun_def] .
lemma ฯCONSEQ'E:
"(โv. E v ๐๐๐๐ฟ๐๐ E' v ๐๐๐๐ P3)
โน ๐๐๐๐ผ f โฆ A โผ B โฆ ๐๐๐๐๐๐ E
โน ๐๐๐๐ผ f โฆ A โผ B โฆ ๐๐๐๐๐๐ E' "
using ฯCONSEQ view_shift_refl by blast
lemmas ฯCONSEQ'E0 = ฯCONSEQ'E[OF view_shift_0, unfolded zero_fun_eta]
subsubsection โนCase Analysisโบ
lemma ฯCASE:
โน ๐๐๐๐ผ f โฆ A โผ C โฆ ๐๐๐๐๐๐ E
โน ๐๐๐๐ผ f โฆ B โผ C โฆ ๐๐๐๐๐๐ E
โน ๐๐๐๐ผ f โฆ A + B โผ C โฆ ๐๐๐๐๐๐ Eโบ
unfolding ฯProcedure_def
by(simp add: distrib_right)
lemma ฯCASE_VS:
โน A ๐๐๐๐ฟ๐๐ Y ๐๐๐๐ P1
โน B ๐๐๐๐ฟ๐๐ Y ๐๐๐๐ P2
โน B + A ๐๐๐๐ฟ๐๐ Y ๐๐๐๐ P2 โจ P1โบ
unfolding View_Shift_def
by (simp add: distrib_right)
lemma ฯCASE_IMP:
โน A ๐๐๐บ๐๐๐ฟ๐๐๐๐ Y ๐๐๐๐ P1
โน B ๐๐๐บ๐๐๐ฟ๐๐๐๐ Y ๐๐๐๐ P2
โน B + A ๐๐๐บ๐๐๐ฟ๐๐๐๐ Y ๐๐๐๐ P2 โจ P1โบ
unfolding Transformation_def
by (simp add: distrib_left)
subsubsection โนNormalization in Preconditionโบ
lemma norm_precond_conj:
"(๐๐๐๐ผ f โฆ T ๐๐๐ป๐ P โผ Y โฆ ๐๐๐๐๐๐ E) = (P โถ ๐๐๐๐ผ f โฆ T โผ Y โฆ ๐๐๐๐๐๐ E )"
unfolding ฯProcedure_def
by (simp add: INTERP_SPEC_subj) blast
lemmas norm_precond_conj_metaeq[unfolded atomize_eq[symmetric]] = norm_precond_conj
lemma norm_precond_ex:
"(๐๐๐๐ผ f โฆ ExBI X โผ Y โฆ ๐๐๐๐๐๐ E) = (โx. ๐๐๐๐ผ f โฆ X x โผ Y โฆ ๐๐๐๐๐๐ E)"
unfolding ฯProcedure_def
by (simp add: INTERP_SPEC_ex) blast
ML_file โนlibrary/syntax/syntax0.MLโบ
section โนReasoning Configurationโบ
subsection โนNormalization of Assertionsโบ
consts semantic_mode :: mode
ABNORMAL :: mode
ML โน
structure Assertion_SS_Abnormal = Simpset (
val initial_ss = Simpset_Configure.Empty_SS
val binding = SOME \<^binding>โนassertion_simps_abnormalโบ
val comment = "Simp rules normalizing particularly the abnormal spec of a triple."
val attribute = NONE
val post_merging = I
)
โบ
ฯreasoner_ML assertion_simp_abnormal 1300
(โนSimplify (assertion_simps ABNORMAL) ?X' ?Xโบ)
= โนPhi_Reasoners.wrap (PLPR_Simplifier.simplifier_by_ss' (K Seq.empty) (fn ctxt =>
Raw_Simplifier.merge_ss (Assertion_SS.get' ctxt, Assertion_SS_Abnormal.get' ctxt)) {fix_vars=false}) o sndโบ
ฯreasoner_ML semantic_simps 1200
(โนPremise semantic_mode _โบ | โนSimplify semantic_mode ?X' ?Xโบ
)
= โนPhi_Reasoners.wrap (PLPR_Simplifier.simplifier (K Seq.empty) (fn ctxt =>
Simplifier.clear_simpset ctxt addsimps @{thms ฯV_simps ฯarg.sel ฯarg.collapse}) {fix_vars=false}) o sndโบ
lemmas [assertion_simps] =
ฯV_simps
end